Schema Normalization
From FD’s to Keys to 3NF (or higher)
Review: Functional Dependency
Given the attributes: A1 A2 … An → B1 B2 … Bn
Usually the right side is a single attribute
Attributes are optionally separated by commas
FD’s are useful to identify keys in the database!
Review: Keys
CAR( VIN, Make, Model, Year, State, LicPlateNum, OwnerID )
Some superkeys: {VIN, Make, Model, Year}, {VIN, State, OwnerID},
{VIN, State, LicPlateNum, OwnerID}, etc.
Candidate keys: {VIN}, {State, LicPlateNum}
Primary key: {VIN}
Review: Normal Forms
Principles for improving database design:
See Example 3.10.9 from the textbook
Example 1
R(A, B, C, D, E)
{CD → AB, B → E}
Example 1
R(A, B, C, D, E)
{CD → AB, B → E}
Example 1
R1(C, D, A, B)
R2(B, E)
Finding Keys
Look at the left and right sides of the functional dependencies
For example: AB → C, C→ B, C→ D
Left | Both | Right |
A | BC | D |
Example 2
R(A, B, C, D, E, F, G, H)
{DE → C, E → A, D → BF, F → GH}
Example 2
R(A, B, C, D, E, F, G, H)
{DE → C, E → A, D → BF, F → GH}
Example 2
R1(D, E, C), R2(E, A), R3(D, B, F, G, H)
R1(D, E, C), R2(E, A)
R3(D, B, F), R4(F, G, H)
Boyce-Codd Normal Form (BCNF) and higher
See Example 3.11.4 from the textbook
Article: Difference Between 3NF and BCNF
Normalization and denormalization
Example 3
{R1(A, B, C, D, E, F, G, H, K), R2(A, X, Y, Z)}
{AB → CD, E → GH, A → F,D → K, A → XY, Y → Z}
Example 3
{R1(A, B, C, D, E, F, G, H, K), R2(A, X, Y, Z)}
{AB → CD, E → GH, A → F,D → K, A → XY, Y → Z}
Example 3
R1 (A, B, C, D, K) - 2NF
R12 (E, G, H) - 3NF
R13 (A, F) - 3NF
R2 (A, X, Y, Z) - 2NF
R1 (A, B, C, D) - 3NF
R12 (E, G, H) - 3NF
R13 (A, F) - 3NF
R14 (D, K) - 3NF
R2 (A, X, Y) - 3NF
R21 (Y, Z) - 3NF
Example 3
R1 (A, B, C, D) - 3NF
R12 (E, G, H) - 3NF
R14 (D, K) - 3NF
R2 (A, X, Y, F) - 3NF
R21 (Y, Z) - 3NF
Synthesis Algorithm for 3NF
Shortcut (not always optimal)