The Closure of a set of Attributes The closure of the attributes X, with respect to the FDs F is denoted X+F = {A | F|- X A} Note: |- means provable using Armstrong’s Axioms If F is clear from the context, we simply write X+ Lemma: Let Y be a set of attributes. Then, Y X+ if and only if F |- X Y If: Suppose that F|- X->Y. Let Y = A1…Ak. By the axiom of decomposition, it follows that F|-X->Ai, for all i<=k. Therefore, Ai is in X+, for all i<=k. Thus, Y=A…Ak is a subset of X+, as required. Only if: Suppose that Y is a subset of X+. Let Y=A1…Ak. By the definition of X+, it follows that F|-X->Ai, for all i<=k. By the axiom of union, we derive that F|-X->A1..Ak, i.e., F|-X->Y, as required.
Completeness of the Axioms Completeness of the axioms means that everything that נובע is also יכיח, i.e., Equivalently, completeness means that everything that is not יכיח is also not נובע We prove that Armstrong's axioms are complete by using the second definition of completeness
Proof (1) We must show that We prove the contra-positive, i.e., if we cannot prove X Y from F using Armstrong’s axioms, then X Y does not follow from F.
Proof (2) Suppose that we cannot prove X Y from F using Armstrong’s axioms. Let X+ be the closure of X Let R be a relation with all attributes in X and Y, and F and the two tuples: t containing the value “b” for all attributes s containing the value “b” for all attributes in X+, and “a”, for all attributes in R, that are not in X+
Proof (3) We will show the following: R satisfies all functional dependencies in F R does not satisfy X Y If we can prove both of these, then X Y does not follow from F, as required.
Proof (4) We start with showing that R satisfies all functional dependencies in F Let W V be a functional dependency in F. We consider two cases: Case 1: W is not a subset of X+. Then, the two rows in R differ on W, and W V is satisfied in R. Case 2: W is a subset of X+. By the closure lemma, F|-X W. Since, W V is in F, by the axiom of transitivity, it follows that F|-X V. Again, by the closure lemma, we have that V is a subset of X+. The two rows are equal on V, and W V is satisfied in R.
Proof (5) We now show that R does not satisfy X Y By the axiom of reflexivity, we have that F|-X X. By the closure lemma, X is contained in X+. Observe that Y is not contained in X+, since otherwise, by the closure lemma we would have that F|-X Y, which contradicts our assumption. Hence, there is some attribute A in Y that is not in X+. Therefore, s,t are equal on X, but differ on Y Therefore, R does not satisfy X Y.
Problem Prove or give a counter-example: Let R be a relation containing exactly two attributes. Let F be a set of functional dependencies. Then, R is in BCNF.
Problem We are given R and F It is known that every dependency in F has one attribute on the left side. Prove or show a simple counter example: R is in BCNF if and only if R is in 3NF
Problem Find small(est) examples of R and F such that: R is in BCNF R is in 3NF, but not in BCNF R is not in 3NF
Problem R=(ABCD) F={A->B,C->D,A->D} What is the normal form of R? We have a decomposition R1=(ABC), R2=(BCD) Is this a lossless join decomposition? Is it possible to insert data into R1 and R2 while satisfying A->B and C->D, so that the natural join of R1 and R2 contradicts A->D?
Problem R=(ABC) F={A->B,BC->A} What is the normal form of R? We have a decomposition R1=(AB), R2=(AC) Is this a lossless join decomposition?
Problem 10 Let R=ABCDEG Let F={C->D, E->C, EG->A, G->B} What are all the keys of R? What is the normal form of R? Is the following decomposition lossless? R1=AEG, R2=CE, R3=BG, R4=DEG Keys: EG Normal form: not 3NF The decomposition is lossless It does not preserve C->D AEG: EG->A, CE: E->C, BG: G->B, DEG: E->D
Additional Exercises (Left over from last week)
Problem 1 Let R(A,B,C,D,E) be a table Write an SQL query that returns an empty relation if and only if ABCD holds in R.
Problem 2 Consider the following axiom system: (B1) XX (B2) XYZ then XY, XZ (B3) XYZ, ZC then XYZC Prove that this system is complete by showing how each of Armstrong’s Axioms can be proven from the axioms above
Problem 3 Axiom of difference: If XW ® YW and W ® Y then X ® W Prove this axiom using Armstrongs Axioms or show that it is not sound
Problem 4 Axiom of addition: If X ® Y and W ® V then XW ® YV Prove this axiom using Armstrongs Axioms or show that it is not sound
Problem 5 Prove or give a counter example (X+)+ = X+
Problem Let R=ABCDEG Let F={C->D, E->C, EG->A, G->B} What are all the keys of R? What is the normal form of R? Is the following decomposition lossless? R1=AEG, R2=CE, R3=BG, R4=DEG Keys: EG Normal form: not 3NF The decomposition is lossless It does not preserve C->D AEG: EG->A, CE: E->C, BG: G->B, DEG: E->D