



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Background: Functional Dep endencies
We are always talking ab out a relation R, with a xed schema (set of attributes) and a varying instance (set of tuples).
Conventions: A; B ; : : : are attributes; : : : ; Y ; Z are sets of attributes. Concatenation means union.
FD is X! Y , where X and Y are sets of attributes. Two tuples that agree in all attributes of X must agree in all attributes of Y.
Implication: FD X! Y fol lows from F i all relation instances that satisfy F also satisfy X! Y.
Three Ways to Reason Ab out FD's
F Say F j= X! Y if every instance that satis es all FD's in F also satisfy X! Y.
F All approaches assume there is a xed relation scheme R to which the FD's p ertain.
F Deduction indicated by F ` X! Y.
Closure Test for Implication (Algorithmic Approach)
Start with X +^ = X. Adjoin V to X +^ if U! V is in F , and U X +^. At end, test if Y X +^.
Pro of that if Y X +^ , then F j= X! Y : Easy induction on the numb er of additions to X +^ that X! A for all A in X +^.
Pro of that if F implies X! Y , then Y X +^ : Prove the contrap ositive; assume Y is not a subset of X +^ and prove F do es not imply X! Y. Construct relation R with two tuples that agree on X +^ and disagree elsewhere.
Armstrong's Axioms (Logical Approach)
A sound (what may b e deduced is correct in the j= sense) and complete (what is true in the j= sense can b e deduced) axiomatization of FD's.
A1: Trivial FD's or Re exivity. X! Y always holds if Y X.
A2: Augmentation. If X! Y , then X Z! Y Z for any set of attributes Z.
A3: Transitivity. If X! Y and Y! Z , then X! Z.
Deductive Pro ofs
A series of \lines." Each line is either:
Example
Given fAB! C ; C D! E g, deduce AB D! E.
AB! C (Given) AB D! C D (A2)
C D! E (Given)
AB D! E (A3)
Pro of of Soundness
Easy observations ab out relations.
Pro of of Completeness
Pro of (2)
Induction on i that X! A 1 Ai follows.
Basis: i = 1, given.
Any set of FD's equivalent to F is a cover for F.
A cover is minimal if:
Example
Relation C T H RS G represents courses, teachers, hours, ro oms, students, and grades. The FD's: C! T ; H R! C ; H T! R; H S! R; C S! G; C H! R.
We can eliminate C H! R.
F Pro of: Using the other 5 FD's, C H +^ = C H T R.
Having done so, we cannot eliminate any attribute from any left side. F Sample pro of: Supp ose we tried to eliminate T from H T! R. We would need that C! T , H T! R, H R! C , H S! R, and C S! G imply H! R. But H +^ = H with resp ect to these 5 FD's.
Thus the remaining ve are a minimal cover of the original six.
Note: minimal cover need not b e unique, or even have the same numb er of FD's.
Lossless Join
The decomp osition of R into S 1 ; : : : ; Sn has a lossless join (with resp ect to some constraints on R) if for any instance r of R that satis es the constraints:
S 1 (r ) ./ ./ Sn (r ) = r
Motivation: We can replace R by S and T , knowing that the instance of R can b e recovered from the instances of S and T.
Theorem
A decomp osition of R into S and T has a lossless join wrt FD's F if and only if S \ T! S or S \ T! T.
Pro of
First note that r S (r ) ./ T (r ) always.
Assume S \ T! S and show that
S (r ) ./ T (r ) r
F Supp ose s is in S (r ) and t is in T (r ), and s and t join (i.e., they agree in S \ T ).
F Then t is the pro jection of a tuple t^0 of r that agrees with s on S.
F So t^0 agrees with t on T and with s on S , so t^0 is s ./ t; i.e., s ./ t is in r.
Similarly if S \ T! T.
Now assume neither FD follows from F.
F Then there is an instance r consisting of two tuples that agree on (S \ T )+^ and disagree elsewhere. This instance satis es F.
F Neither S nor T is contained in (S \ T )+ (or else one of the FD's in question would follow).
F Thus, r pro jected and rejoined yields four distinct tuples, and cannot b e r.
Theorem
We can always decomp ose a relation R with FD's F into BCNF relations with a lossless join.
Pro of
We decomp ose when we nd a BCNF violation X! Y , into X [ Y and (R Y ) [ X.
But
\ (X [ Y ) = X. Thus the intersection of the schemas functionally determines one of them, X [ Y.
To complete the pro of, we need to show that when we decomp ose further, the resulting n relations have a lossless join, but that is an easy induction on n.
Pro of that the decomp osition is always LJ will have to wait for the theory of \generalized dep endencies." F This decomp osition is obviously LJ, since AB ./ AC is lossless b ecause A! B , and then AB C ./ C D is lossless b ecause of C! D.