Professional Documents
Culture Documents
Normalization
Lecture 4
Modeling Review
☞Consider relationships in pairs. Determine
relationship type and cardinality.
☞Collapse into one larger view. Remove many to many
relationships.
☞Assign primary and foreign keys. Determine
relationship strength.
☞Fill in remaining attributes.
Modeling Scenario
white board discussion on the Movie Busines
ate Database to track Movies and people invo
Business Scenario:
• Movies are released every year and have a specific genre
• Participants are everyone who can work on a Movie in a major
Role.
• Participants may work on many Movies
• Participants may have more than one Roles on the same or
different on Movies.
What are the entities?
What are the relationship between entities?
Normalization
Anomalies
UPDATE ANOMALY
It is helpful to know that occasionally, the data may still be subject to anomalies in 3NF. In this
case, we may have to perform further transformations:
• Transform 3NF to BCNF. Transform BCNF to 4NF. Transform 4NF to 5NF
Normalization Process
• Process involves applying a series of tests on a relation to determine whether it satisfies or
violates the requirements of a given normal form.
• When a test fails, the relation is decomposed into simpler relations that individually meet the
normalization tests.
• All these normal forms are based on the functional dependencies among the attributes of a
relation.
Example of Normalization Process
Source Data
Block
☞ It is in 1NF
☞ It has no partial dependencies
☞ Start at 1NF
☞ Make new tables to eliminate partial dependencies
☞ Assign corresponding dependent attributes
Step 2: Transform data in first normal form (1NF) into second normal form (2NF)
• - Remove partial dependencies
Step 2: Transform data in first normal form (1NF) into second normal form (2NF)
• - Remove partial dependencies
• Take each non-key attribute in turn and ask the question: is this attribute dependent on one part of the key?
• If yes, remove the attribute to a new table with a copy of the part of the key it is dependent upon. The key it
is dependent upon becomes the key in the new table. Underline the key in this new table.
• If no, check against other part of the key and repeat above process
• If still no, ie: not dependent on either part of the key, keep attribute in current table.
THIRD NORMAL FORM
☞ It is in 2NF
☞ It has no transitive dependencies
☞ Start at 2NF
☞ Make new tables to eliminate transitive dependencies
☞ Assign corresponding dependent attributes
TRANSITIVE DEPENDENCY
2NF: no partial dependencies, only PKs 3NF: no other dependencies, only PKs
Denormalization the process of
purposefully producing a table of lower
normal form for better performance
1NF – Identify PK
A B C D E F G
1NF – Identify Dependencies
1NF – Relational Schema Notation
☞ TABLE1(A, B, C, D, E, F, G)
2NF – Make new tables to Eliminate
Partial Dependencies
☞ TABLE1(A, B, C, E, F)
☞ TABLE2(B, D)
☞ TABLE3(A, G)
3NF - Make new tables to Eliminate
Transient Dependencies
☞ TABLE1(A, B, C, E)
☞ TABLE2(B, D)
☞ TABLE3(A, G)
☞ TABLE4(E, F)
TRY THIS IN CLASS
No transient dependencies
2NF => 3NF
RepairItem(RepairNumber, ItemNumber, RepairDate, RepairCost
Item(ItemNumber, Type, AcquisitionCost