Professional Documents
Culture Documents
Lecture Notes #6
1
Decomposition Algorithm (1/2) Decomposition Algorithm (2/2)
For every violation X → B among given 3. Find the FD’s for the decomposed
FD’s: relations.
1. Compute X+. – Project the FD’s from F = calculate all
Cannot be all attributes – why? consequents of F that involve only attributes
from X+ or only from (R−X+) ∪ X.
2. Decompose R into X+ and (R–X+) ∪ X.
R X
X+
2
Example “Elegant” Workaround
• What can go wrong if we decompose: • Define the problem away.
street zip
A = street, • A relation R is in 3NF iff for every nontrivial
545 Tech Sq. 02138
B = city, 545 Tech Sq. 02139 FD X → A, either:
C = zip. city zip 1. X is a superkey, or
Cambridge 02138
Cambridge 02139 2. A is prime = member of at least one
key.
city s treet zip
• Thus, the canonical problem goes away:
Cambridge 545 Tech Sq. 02138 you don’t have to decompose because all
Join: Cambridge 545 Tech Sq. 02139 attributes are prime.
3
MVD Rules Splitting Doesn’t Hold
• Every FD is an MVD: if X →Y, then • Sometimes you need to have several attributes on
swapping Y’s between tuples that agree the right of an MVD.
on X doesn’t create new tuples. • For example: Drinkers(name, areaCode, phones,
beersLiked, beerManf)
• Example, in Drinkers: name →→ addr.
name areaCode phones beersLiked beerManf
• Complementation: if X →→ Y, then Leo 773 555-1111 Bud A.B.
Leo 773 555-1111 Honkers G.I.
X →→ Z, where Z is all attributes not in X Leo 800 555-9999 Bud A.B.
or Y. Leo 800 555-9999 Honkers G.I.
• Example: since name →→ phones • name →→ areaCode phones holds, but neither
holds in Drinkers, so does name →→ areaCode nor name →→ phones do.
name →→ addr beersLiked.