Normalization
Normalization
Normalization
What is Normalization?
• Unnormalized data exists in flat files
Normalized Table
Types of Normalization
• First Normal Form
– each field contains the smallest
meaningful value
– the table does not contain
repeating groups of fields or
repeating data within the same field
• Create a separate field/table for each set of related data.
• Identify each set of related data with a primary key
Tables Violating First Normal Form
PART WAREHOUSE
(Primary ADDRESS
Key) WAREHOUSE Quantity
1608 New Field Road , 4141
Warehouse A, Warehouse B,
P0010 400, 543, 329 Greenway Drive , 171 Pine
Warehouse C
Lane
4141 Greenway Drive , 800
P0020 Warehouse B, Warehouse D 200, 278 Massey Street
Table Conforming to First Normal Form
WAREHOUSE TABLE
1
∞
WAREHOUSE (Primary Key) WAREHOUSE_ADDRESS
Warehouse A 1608 New Field Road
Warehouse B 4141 Greenway Drive
Warehouse C 171 Pine Lane
Warehouse D 800 Massey Street
• Third Normal Form
– usually used in tables with a single-
field primary key
– records do not depend on anything
other than a table's primary key
– each non-key field is a fact about the
key
– Values in a record that are not part of that record's
key do not belong in the table. In general, any time
the contents of a group of fields may apply to more
than a single record in the table, consider placing
those fields in a separate table.
Table Violating Third Normal Form
EMPLOYEE_DEPARTMENT TABLE
EMPNO
FIRSTNAME LASTNAME WORKDEPT DEPTNAME
(Primary Key)
∞
DEPARTMENT TABLE
1
E11 Operations
1022 143-01
4123 12 Anne Smith 216
1022 159-02
4123 201-01
4123 211-02
4123 214-01
• Tables in Third Normal Form
– Data Not Dependent On Key is Eliminated
1022 159-02
Table: Students
4123 201-01
Student# Advisor# StudentFName StudentLName
4123 211-02
1022 10 Jane Mayo
4123 214-01
4123 12 Mark Baker
Example 2
• Un-normalized Table:
EmpID Name Dept Dept Name Proj 1 Time Proj 2 Time Proj 3 Time
Code Proj 1 Proj 2 Proj 3
EN1-26 Sean Breen TW Technical Writing 30-T3 25% 30-TC 40% 31-T3 30%
EN1-33 Amy Guya TW Technical Writing 30-T3 50% 30-TC 35% 31-T3 60%
Employees Departments
Employees_and_Projects
EmpID DeptCode
EmpID
FirstName
ProjectNumber DeptName
LastName
TimeonProject
DeptCode
Example 3
• Un-normalized Table:
EmpID FName LName Manager Dept Sector Spouse Child1 Child2 Child3
458 Homer Simpson Mr. Burns Safety 7G Marge Bart Lisa Maggie
Table in First Normal Form
No more repeated fields
EmpID Dependent
458 Marge
458 Bart
458 Lisa
458 Maggie
Tables in Second Normal Form
Removed Repeated Data From Table
Step 2
EmpID FName LName ManagerID Dept Sector
285 Carl Carlson 2 Engineering 6G
365 Lenny 2 Marketing 8G
458 Homer Simpson 1 Safety 7G
EmpID Dependent
458 Marge ManagerID Manager
458 Bart 1 Mr. Burns
458 Lisa
2 Smithers
458 Maggie
Tables in Third Normal Form
Employees Table Manager Table
EmpID FName LName DeptCode ManagerID Manager
285 Carl Carlson EN 1 Mr. Burns
365 Lenny MK 2 Smithers
458 Homer Simpson SF
Dependents Table
Department Table
EmpID Dependent
DeptCode Department Sector ManagerID
458 Marge EN Engineering 6G 2
458 Bart MK Marketing 8G 2
458 Lisa SF Safety 7G 1
458 Maggie
Relationships for Example 3
Example 4
Un-normalized Table
Although this table is in 1NF it contains redundant data. For example, information about the supplier's location and the
location's status have to be repeated for every part supplied. Redundancy causes what are called update anomalies. Update
anomalies are problems that arise when information is inserted, deleted, or updated. For example, the following anomalies
could occur in this table:
INSERT. The fact that a certain supplier (s5) is located in a particular city (Athens) cannot be added until they supplied a part.
DELETE. If a row is deleted, then not only is the information about quantity and part lost but also information about the supplier.
UPDATE. If supplier s1 moved from London to New York, then two rows would have to be updated with this new information.
Tables in 2NF
Suppliers Parts
Tables in 2NF but not in 3NF still contain modification anomalies. In the example of Suppliers, they are:
INSERT. The fact that a particular city has a certain status (Rome has a status of 50) cannot be inserted until
there is a supplier in the city.
DELETE. Deleting any row in SUPPLIER destroys the status information about the city as well as the
association between supplier and city.
Tables in 3NF
INSERT. Facts about the status of a city, Rome has a status of 50, can be added even though there is not supplier in that city.
Likewise, facts about new suppliers can be added even though they have not yet supplied parts.
DELETE. Information about parts supplied can be deleted without destroying information about a supplier or a city.
UPDATE. Changing the location of a supplier or the status of a city requires modifying only one row.
Additional Notes About Example 3
• Going to extremes can create too many tables which in
turn can make it difficult to manage your data. The key to
developing an efficient database is to determine your
needs.
• A postal carrier may need an Address field broken down
into smaller fields for sorting and grouping purposes, but
do you?
• Another good example is Example 3 - leaving the Dept
Code field in our completed table design. If you also
wanted to track information such as pay rate, health
insurance, etc., then a new table that contains company
related data for the employee would be necessary. If all
you need is to track the department an employee
belongs to then leaving it in the Employees table is fine.
In Summary
• If you type a data value more than once then
consider placing the field in another table.
• Consider your sorting and grouping needs. If
you need to sort or group on a portion of a field,
then the field is not broken down into its smallest
meaningful value.
• If you have multiple groups of fields, such as
several telephone numbers, then consider
eliminating those fields and turning them into
records in another table. Think vertically—not
horizontally!
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: