FD Slide2 09
FD Slide2 09
( AC)+ =ABCDE,
A+ = A, and
C+ = CD,
IDEA:
• Focus on "necessary" attributes that will definitely appear in
ANY candidate key of R.
• Ignore "useless" attribute that will NEVER be part of a can-
didate key.
Necessary attributes:
An attribute A is said to be a necessary attribute if
(a) A occurs only in the L.H.S. (left hand side) of the fd’s
in F; or
(b) A is an attribute in relation R, but A does not occur in
either L.H.S. or R.H.S. of any fd in F.
In other words, necessary attributes NEVER occur in the R.H.S. of
any fd in F.
Useless attributes:
An attribute A is a useless attribute if A occurs ONLY in the
R.H.S. of fd’s in F.
Middle-ground attributes:
An attribute A in relation R is a middle-ground attribute if A is nei-
ther necessary nor useless.
Example.
Consider the relation R(ABCDEG) with set of fd’s F = {AB → C,
C → D, AD → E}
Step1.
Set F′ to a minimal cover of F (This is needed because
otherwise we may not detect all useless attributes).
Step2.
Partition all attributes in R into necessary, useless and
middle-ground attribute sets according to F′. Let X={
C 1 , . . . , C l } be the necessary attribute set, Y = {B1 , ...,
B k } be the useless attribute set, and M = { A1 , ..., An }
− (X ∪ Y) be the middle-ground attribute set.
If X={}, then go to step4.
Step3.
Compute X + . If X + =R, then set K= {X}, terminate.
-6-
Step4.
Let L = 〈Z 1 , Z 2 , . . . , Z m 〉 be the list of all non-empty
subsets of M (the middle-ground attributes) such that
L is arranged in ascending order of the size of Z i .
Add all attributes in X (necessary attributes) to each Z i
in L.
Set K = {}.
i ← 0.
WHILE L ≠ empty do
BEGIN
i ← i + 1.
Remove the first element Z from L.
Compute Z + .
If Z + = R,
then
begin
set K ← K ∪ {Z };
for any Z j ∈ L, if Z ⊂ Z j
then L ← L − {Z j }.
end
END
♣
-7-
i Z Z+ L K
〈AG, BG, CG, DG, ABG, ACG, {}
0 − −
ADG, BCG, BDG, CDG, ABCG,
ABDG, ACDG, BCDG, ABCDG〉
GOALS OF NORMALIZATION
LOSS-LESS-JOIN DECOMPOSITION
The decomposition
R = R1 ⊗ R2 ⊗ . . . ⊗R m
is always loss-less.
-11-
either X is a superkey
or A is a prime.
BERNSTEIN’S ALGORITHM
Algorithm:
1.
Group together all fd’s which have the same L.H.S. If
X → Y 1 , X → Y 2 , ..., X → Y k are all the fd’s with the
SAME L.H.S. X, then replace all of them by the single
fd X →Y 1Y 2 ... Y k .
3.
IF X′Y′ ⊂ XY, then remove the relation (X′Y′) from
the decomposition.
4.
If none of the relations obtained after step (3) contains
a candidate key of the original relation R, then find a
candidate key K of R and add the relation (K) to the
decomposition.
-15-
by C → D
R1 (CD) R′(ABCE)
by B → C
R2 (BC) R3 (ABE)
R(ABCDEHG)
by AH → C
R1 (AHC) R′(ABDEHG)
by E → AD
R2 (EAD) R′′(BEHG)
by B → EH
R3 (BEH) R4 (BG)