Professional Documents
Culture Documents
Functional Dependencies and Normal Forms (Part 2)
Functional Dependencies and Normal Forms (Part 2)
(Part 2)
Database System Concepts - 7th Edition 7.2 ©Silberschatz, Korth and Sudarshan
BCNF and Dependency Preservation
Database System Concepts - 7th Edition 7.3 ©Silberschatz, Korth and Sudarshan
Dependency Preservation
If FDs are not preserved, we must perform a join to check that the FDs
we lost are satisfied
• Much more expensive check
A C C B A B C
𝑎1 𝑐1 𝑐1 𝑏1 = 𝑎1 𝑏1 𝑐1
𝑎1 𝑐2 𝑐2 𝑏1 𝑎1 𝑏1 𝑐2
Database System Concepts - 7th Edition 7.4 ©Silberschatz, Korth and Sudarshan
Dependency Preservation - Definition
𝑅1 𝑿𝟏 , … , 𝑅𝑛 𝑿𝒏
Intuition: by only using the FDs we inherit at each relation 𝑅𝑖, we can
logically derive all FDs that could be derived from the original FDs.
• with only C -> B, AB cannot derive C, i.e., (AB) + does not contain C
Database System Concepts - 7th Edition 7.5 ©Silberschatz, Korth and Sudarshan
Third Normal Form
A relation schema <R(U), F> is in Third Normal Form (3NF) if for all
functional dependencies X -> Y in F+ that are not trivial
• X is a superkey of R, or
• Each attribute A in Y – X is contained in some candidate key for R.
For checking 3NF, we can equivalently focus just on F, and not on its closure.
Database System Concepts - 7th Edition 7.6 ©Silberschatz, Korth and Sudarshan
Transitive Dependencies
Example.
Dept Floor Building City
Physics 1 Watson New York Floor, Building -> Dept
Physics 2 Watson New York Dept -> Building
Comp. Sci. 3 Taylor Chicago Building -> City
Comp. Sci. 2 Taylor Chicago
Database System Concepts - 7th Edition 7.7 ©Silberschatz, Korth and Sudarshan
Transitive Dependencies
Example.
Dept Floor
Physics 1 Dept Building Building City
Physics 2 Physics Watson Watson New York
Comp. Sci. 3 Comp. Sci. Taylor Taylor Chicago
Comp. Sci. 2 Dept -> Building Building -> City
Database System Concepts - 7th Edition 7.9 ©Silberschatz, Korth and Sudarshan
Algorithm for 3NF decomposition
Database System Concepts - 7th Edition 7.10 ©Silberschatz, Korth and Sudarshan
Algorithm for 3NF decomposition
Database System Concepts - 7th Edition 7.11 ©Silberschatz, Korth and Sudarshan
BCNF vs 3NF decompositions
BCNF:
• + lossless
• + no redundancy
• - may not preserve FDs
3NF:
• + lossless
• - some redundancies may remain
• + preserves FDs
Database System Concepts - 7th Edition 7.12 ©Silberschatz, Korth and Sudarshan