Beruflich Dokumente
Kultur Dokumente
Normal Forms
Normal Forms
Given <R, F>, a relation schema R together with a set of
FD’s, we want to determine if R is in a “good” shape!
If not, we need to decompose R into smaller “good”
relations;
How to measure this goodness and how to achieve it?
To address these issues, we need to study normal forms
If a relation schema is in some normal form, we know that
it is in some “good” shape, in the sense that it won’t suffer
from certain kinds of (redundancy) problems.
Normal Forms
The normal forms based on FD’s are
First normal form (1NF)
Second normal form (2NF)
Third normal form (3NF)
Boyce-Codd normal form (BCNF)
These normal forms have increasingly restrictive
requirements
AB
R1 = AB R2 = ACDE
F1 = { A B } F2 = { C D }
CD
That is, we replace these k FD’s (having the same LHS) with a single equivalent
FD X A1…Ak and create just one relation instead of k relation schemas
XA1, … ,XAk
Example (3NF Decomposition)
R = ABCDE
F = { BD E, C B , CE A }
BD E
R1 = BDE R2 = ABCD
F1 = { BD E } F2 = {C B , CD A }
CB
BD E
R22 = BCD
F22 = { C B }
R21 = BDE
F21 = { BD E } CB
R221 = BC R222 = CD
F221 = { C B } F222 =
Decomposition into 3NF
Previous (binary decomposition approach):
Lossless-join √
May not be dependency preserving. If so, then add
extra relations XA, one for each FD X → A we lost
Now, the synthesis approach
Dependency preservation √
However, may not be lossless-join. If so, we need to
add to R, only one extra relation schema that includes
the attributes that form any key of R
What would be the FDs on this newly added relation?
Decomposition into 3NF (synthesis)
Consider relation schema <R, F>
The synthesis approach:
Get a canonical cover Fc of F
For each FD X A in Fc, add schema XA to R
preserved TRUE
for each FD X Y in F and while preserved == TRUE
do begin
compute X+ under F1 . . . Fn ;
if Y ⊈ X+ then preserved FALSE;
end
Example
Consider R = ( A, B, C, D ), F = { A B, B C, C D }
Is the decomposition R = {R1, R2} dependency-preserving, where
R1 = ( A, B ), F1 = { A B }, R2 = ( A, C , D), and F2 = { C D, A D, A C }?
Check if A B is preserved
• Compute A+ under { A B } { C D, A D, A C }
• A+ = { A, B, D }
• Check if B A+
• Yes
• A B is preserved
Check if B C is preserved
• Compute B+ under { A B } { C D, A D, A C }
• B+ = { B }
• Check if C B+
• No
• B C is not preserved