View
263
Download
1
Category
Tags:
Preview:
Citation preview
What is Normalization? What is the objective of Normalization? Why is Normalization in a database
important? What are NORMAL FORMS? How do we accomplish Normalization in our
database? Are there times when Normalization is
unnecessary?
04/20/232
Overview
Normalization refers to the process of creating an efficient, reliable, flexible, and appropriate “relational” structure for storing information in a “relational” data structure.
Normalization usually involves dividing a database into two or more tables and defining the relationship between the tables.
04/20/233
What is Normalization?
The objective is to isolate data so that additions, deletions, and modifications of a field can be made in just one table and then propagated through the rest of the database via the defined relationships.
04/20/234
What is the objective of Normalization?
Normalization removes redundant data from your tables in order to improve storage efficiency.
Normalization removes redundant data and improves data integrity.
Normalization removes redundant data and helps in maintenance problems. Example: If data that exists in more than one place must be changed, the data must be changed in exactly the same way in all locations.
Finally, Normalization removes redundant data and improves the scalability of your database.
04/20/235
Why is Normalization in a database important?
A series of logical steps to normalize data tables. First Normal Form-1NF Second Normal Form-2NF Third Normal Form-3NF Fourth Normal Form-4NF Fifth Normal Form-5NF• We will learn the First, Second and Third
Normal Forms
04/20/236
What are NORMAL FORMS?
The definition of the first Normal Form is as follows
There are no repeating groups.All of the key attributes are defined.All attributes are dependent on the primary
key.Example on the next slide.
04/20/237
What is the First Normal Form?
How do we accomplish First Normal Form? Look at this example.
ProjectNumber
ProjectName
EmployeeNumber
EmployeeName-1
Rate Category-1
Hourly Rate-1
EmployeeName 2
Rate Category
Hourly Rate
1023, 1056
MadagascarTravel site andOnlineEstate Agency
11 Julius Wilson A $60 Monica Jefferson
B $50
1023 MadagascarTravel site
16 Daniel Moore C $40
1056 Online Estate Agency
17 Charles Saul D $30
04/20/23
8
Notice the repeating Groups.
ProjectNumber
ProjectName
EmployeeNumber
EmployeeName-1
Rate Category-1
Hourly Rate-1
EmployeeName 2
Rate Category
Hourly Rate
1023, 1056
MadagascarTravel site andOnlineEstate Agency
11 Julius Wilson A $60 Monica Jefferson
B $50
1023 MadagascarTravel site
16 Daniel Moore C $40
1056Online Estate Agency
17 Charles Saul D $30
04/20/23
9
This is our solution to eliminating the repeating groups
ProjectNumber
ProjectName
EmployeeNumber
EmployeeName
Rate Category
Hourly Rate
1023 MadagascarTravel site
11 Julius Wilson A $60
1023 MadagascarTravel site
12 Monica Jefferson
B $50
1023 MadagascarTravel site
16 Daniel Moore C $40
1056 Online Estate Agency
11 Julius Wilson A $60
1056 Online Estate Agency
17 Charles Saul D $30
04/20/23
10
How can we set our Primary Key?
ProjectNumber
ProjectName
EmployeeNumber
EmployeeName
Rate Category
Hourly Rate
1023 MadagascarTravel site
11 Julius Wilson A $60
1023 MadagascarTravel site
12 Monica Jefferson
B $50
1023 MadagascarTravel site
16 Daniel Moore C $40
1056 Online Estate Agency
11 Julius Wilson A $60
1056 Online Estate Agency
17 Charles Saul D $30
04/20/23
11
Can this be our Primary Key?
ProjectNumber
ProjectName
EmployeeNumber
EmployeeName
Rate Category
Hourly Rate
1023 MadagascarTravel site
11 Julius Wilson A $60
1023 MadagascarTravel site
12 Monica Jefferson
B $50
1023 MadagascarTravel site
16 Daniel Moore C $40
1056 Online Estate Agency
11 Julius Wilson A $60
1056 Online Estate Agency
17 Charles Saul D $30
04/20/23
12
Or, can this be our Primary Key?
ProjectNumber
ProjectName
EmployeeNumber
EmployeeName
Rate Category
Hourly Rate
1023 MadagascarTravel site
11 Julius Wilson A $60
1023 MadagascarTravel site
12 Monica Jefferson
B $50
1023 MadagascarTravel site
16 Daniel Moore C $40
1056 Online Estate Agency
11 Julius Wilson A $60
1056 Online Estate Agency
17 Charles Saul D $30
04/20/23
13
Solution-We need both as our Primary Keys.
ProjectNumberPrimary Key
ProjectName
EmployeeNumberPrimary Key
EmployeeName
Rate Category
Hourly Rate
1023 MadagascarTravel site
11 Julius Wilson A $60
1023 MadagascarTravel site
12 Monica Jefferson
B $50
1023 MadagascarTravel site
16 Daniel Moore C $40
1056 Online Estate Agency
11 Julius Wilson A $60
1056 Online Estate Agency
17 Charles Saul D $30
04/20/23
14
Is our table in First Normal Form?
ProjectNumberPrimary Key
ProjectName
EmployeeNumberPrimary Key
EmployeeName
Rate Category
Hourly Rate
1023 MadagascarTravel site
11 Julius Wilson A $60
1023 MadagascarTravel site
12 Monica Jefferson
B $50
1023 MadagascarTravel site
16 Daniel Moore C $40
1056 Online Estate Agency
11 Julius Wilson A $60
1056 Online Estate Agency
17 Charles Saul D $30
04/20/23
15
A table is in 2nd Normal Form if:1) It is in 1st normal form.2) It includes no partial dependencies (where
an attribute is dependent on only a part of a primary key).
04/20/2316
What is Second Normal Form
Does it include partial dependencies? Do you notice anything else?
ProjectNumberPrimary Key
ProjectName
EmployeeNumberPrimary Key
EmployeeName
Rate Category
Hourly Rate
1023 MadagascarTravel site
11 Julius Wilson A $60
1023 MadagascarTravel site
12 Monica Jefferson
B $50
1023 MadagascatTravel site
16 Daniel Moore C $40
1056 Online Estate Agency
11 Julius Wilson A $50
1056 Online Estate Agency
17 Charles Saul D $30
04/20/23
17
Look at “Project Name” Row 3. Also look at Hourly Rate? What about
data integrity?ProjectNumberPrimary Key
ProjectName
EmployeeNumberPrimary Key
EmployeeName
Rate Category
Hourly Rate
1023 MadagascarTravel site
11 Julius Wilson A $60
1023 MadagascarTravel site
12 Monica Jefferson
B $50
1023 MadagascatTravel site
16 Daniel Moore C $40
1056 Online Estate Agency
11 Julius Wilson A $50
1056 Online Estate Agency
17 Charles Saul D $30
04/20/23
18
Step One:ProjectName
EmployeeNumber
1023 11
1023 12
1023 16
1056 11
1056 17
04/20/23
19
Project Name is only Dependent on Project Number; so, we create a“Employee Project Table.”
Employee-Project Table
Step Two:
ProjectNumberPrimary Key
ProjectName
1023 MadagascarTravel site
1056 Online Estate Agency
04/20/23
20
Notice that “Project Name” is dependent on only“Project Number.”We create our “Project Table” With Project Number as our Primary Key. Look at the space we have saved. What else have we done?
Project Table
Step Three:
EmployeeNumberPrimary Key
EmployeeName
Rate Category
Hourly Rate
11 Julius Wilson A $60
12 Monica Jefferson
B $50
16 Daniel Moore C $40
17 Charles Saul D $30
04/20/23
21
Notice that Employee Name, Rate Category, and Hourly Rate are dependent onEmployee Number.We create our “Employee Table” withEmployee Number as our Primary Key.
Employee Table
Are we now in Second Normal Form?
ProjectNamePrimary Key
EmployeeNumber Primary Key
1023 11
1023 12
1023 16
1056 11
1056 17
04/20/23
22
Project Table Employee TableEmployee Project Table
Is it in First Normal Form and does it includes no partial Dependencies?
ProjectNumberPrimary Key
ProjectName
1023 MadagascarTravel site
1056 Online Estate Agency
EmployeeNumberPrimary Key
EmployeeName
Rate Category
Hourly Rate
11 Julius Wilson A $60
12 Monica Jefferson B $50
16 Daniel Moore C $40
17 Charles Saul D $30
Project Table
ProjectNamePrimary Key
EmployeeNumber Primary Key
1023 11
1023 12
1023 16
1056 11
1056 17
Employee Project Table
It is in SECOND Normal Form. It contains no transitive dependencies
(where a non-key attribute is dependent on another non-key attribute).
Let’s see where we begin.
04/20/2323
Now, What is Third Normal Form?
Let’s take another look at what we have.?
ProjectNamePrimary Key
EmployeeNumber Primary Key
1023 11
1023 12
1023 16
1056 11
1056 17
04/20/23
24
Project Table Employee TableEmployee Project Table
ProjectNumberPrimary Key
ProjectName
1023 MadagascarTravel site
1056 Online Estate Agency
EmployeeNumberPrimary Key
EmployeeName
Rate Category
Hourly Rate
11 Julius Wilson A $60
12 Monica Jefferson B $50
16 Daniel Moore C $40
17 Charles Saul D $30
Project TableEmployee Project Table
Can we do anything else with this table?
04/20/2325
Let’s look at the Employee Project Table
ProjectNamePrimary Key
EmployeeNumber Primary Key
1023 11
1023 12
1023 16
1056 11
1056 17
Employee Project Table
Let’s Look at the Project Table.
ProjectNumberPrimary Key
ProjectName
1023 MadagascarTravel site
1056
Online Estate Agency
04/20/23
26
Can we do anything else with this table?
Project Table
Can we further normalize this table?
04/20/2327
Let’s look at the Employee table
Employee Table
EmployeeNumberPrimary Key
EmployeeName
Rate Category
Hourly Rate
11 Julius Wilson A $60
12 Monica Jefferson B $50
16 Daniel Moore C $40
17 Charles Saul D $30
See what we can do with the employee table.
Let’s make an “Rate” Table
Rate CategoryPrimary Key
Hourly Rate
A $60
B $50
C $40
D $30
04/20/23
28
Employee Table
EmployeeNumberPrimary Key
EmployeeName
Rate Category
11 Julius Wilson A
12 Monica Jefferson B
16 Daniel Moore C
17 Charles Saul D
Rate Table
We have now reduced the possibility of Employees being paidIncorrectly. Our database Will have more integrity.
Recommended