Normalization
Normalization
7
Normalized Tables
8
Normal Forms
Normal forms are formal guidelines (steps)
for the normalization process
DK/NF
5th Normal Form
4th Normal Form (4NF)
Boyce Codd NF (BC/NF)
3rd Normal Form (3NF)
2nd Normal Form (2NF)
1st Normal Form (1NF)
Unnormalized Form (UNF)
9
Normalization – 1NF
A table is in 1NF if
1. it satisfies the definition of a relation
Review: what are the features of a relation?
2. no “repeating groups” (columns)
10
Repeating Groups
Customer First Telephone
Surname
ID Name Number
123 Robert Ingram 555-861-2025
555-403-1659
456 Jane Wright
555-776-4100
789 Maria Fernandez 555-808-9633
12
Transforming to 1NF: Example
Another example
UNF 1NF
13
Problems in 1NF
Basically it may have the same problem as
spreadsheet tables
Redundancy, and anomalies
14
Higher Normal Forms
Normal forms higher than 1NF deal with
functional dependency
15
Functional Dependency
If each value of attribute A is associated with only one
value of attribute B, we say
A determines B
Or, B is dependent on A
Denoted as: A B
16
Functional Dependency Examples
Dependency example
For each Customer ID, there is only one corresponding first name
(or last name), so: Customer ID determines First Name, or
Customer ID First Name
Composite determinant: (First Name, Last Name) Customer ID
Non-dependency example
An Customer ID can have multiple phone numbers, so: Customer ID
does not determine Phone Number
Dependency diagram:
Dependency diagram: an example of composite determinant
A solid line indicates
determinacy
Example
18
Normalization – 2NF
A relation is in 2NF, if
It is in 1NF, and
All non-key attributes (attributes that are not part of any primary key or candidate
key) must be functionally dependent on the whole primary (candidate) key
Or, NO partial dependency
Partial dependency
A non-key attribute is dependent on part of a composite primary key
Implication
A relation with only single-attribute primary key and candidate key does not have
partial dependency problem; therefore, such a relation is in 2NF.
A B C D
Partial dependency
20
Transforming to 2NF
Steps
Identify the primary key (PK).
If PK consists of only one field, then it is in 2NF.
If PK is a composite key, then look for partial
dependency.
If there is partial dependency, move the partial
dependency involved attributes to another relation.
A B C D
A B C B D
21
Transforming to 2NF: Example
Course ID Section Title Classroom Time
CIS 2010 1 Intro to CIS ALC 201 TTH 3:00-4:15PM
CIS 2010 2 Intro to CIS ALC 310 TTH 9:30-10:45AM
CIS 2010 3 Intro to CIS Online W 7:00PM-9:40PM
CIS 3730 1 Database CS 200 W 7:00PM-9:40PM
23
Normalization – 3NF
A relation is in 3NF, if
It is in 2NF, and
All (non-key) attributes must, and only, be
functionally dependent on the primary key
Or, NO transitive dependency
Transitive dependency
A B and B C, then A C
A B C D
Transitive dependency
25
Transforming to 3NF
Move the attributes involved in a transitive
dependency to another relation
Order Order_ID Order_Date CustID Name Address
1006 10/24/2004 2 Value Furniture Plano, TX
1007 10/25/2004 6 Furniture Gallery Boulder, CO
1008 11/1/2004 2 Value Furniture Plano, TX
Order Customer
Order_ID Order_Date Customer CustID Name Address
1006 10/24/2004 2 2 Value Furniture Plano, TX
1007 10/25/2004 6 6 Furniture Gallery Boulder, CO
1008 11/1/2004 2
A B C
28
4NF Brief
Multi-value dependency
Employee Skill (determines multiple skills)
Employee Degree (determines multiple degrees)
30
Normal Forms Summary
BCNF: every attribute is dependent on the key, the whole key, and nothing but the key
3NF: every non-key attribute is dependent on the key, the whole key, and nothing but
the key
Eliminate transitive
dependencies
2NF: every non-key attribute is dependent on the key, and the whole key.
Eliminate partial
dependencies
1NF: If the tables are relations and no repeating groups
32