CS 540 1. Assignment 5 Solutions Let R(A,B,C,D,E,G,H) be a relation schema with set of functional dependencies: F = {ABC, BD, CDE, CEGH, GA}. a. Exhibit a derivation of ABE from F. in F Reason -----------------------------------------------------ABB reflexivity rule BD in F ABD transitivity rule ABC in F ABCD union rule CDE in F ABE transitivity rule b. Exhibit a derivation sequence for BGC using only Armstrong’s Axioms. in F Reason --------------------------------------------------------GA in F BGAB augmentation rule ABC in F BGC transitivity rule c. Find AB+. AB+ contains AB AB+ contains ABC AB+ contains ABCD AB+ contains ABCDE AB+ contains ABCDEGH Hence, AB+ = ABCDEGH reflexivity ABC BD CDE CEGH 2. Let R(A,B,C,D,E,G,H) be a relation schema with set of functional dependencies: F = {ABC, BD, CDE, CEGH, GA}. Find all keys for R. Show and explain all work. The attribute B must appear in every key; but B+ = BD which is not a key. No key contains H. Since AB+ = ABCDEGH and no proper subset of AB satisfies this property, AB is a key. Since B is not a key, R does not have a unique key. BC+ = ABCDEGH and no proper subset of BC satisfies this property; thus, BC is a key. BG+ = ABCDEGH nd no proper subset of BG satisfies this property; thus, BG is a key. No other combinations are keys; thus, the only keys are AB, BC and BG. 3. Let R have arity n. Find an upper bound for the cardinality of F+ in terms of n. There are 2n – 1 subsets of the attributes of R save the empty set. Hence, there are (2n – 1)2 possible combinations XY functional dependencies using the attributes of R. 4. Show that the closure operator for a set of attributes is monotonic; i.e. if Y X, then Y+ X+. We prove that the closure operator is monotonic. Thus, let Y and X be two sets of attributes such that Y X. We show Y+ X+. Let A be an attribute in the set of attributes Y+. Then, YA derivable from F using the inference rules. Since Y X, XY is derivable from F using Armstrong's Axioms and by transitivity X A is in F+. Thus A is derivable from X and thus, A is in X+. 5. A set of attributes Y is said to be closed if Y equals its own closure, i.e. Y = Y+. Prove that, for a set of attributes X, the smallest closed set containing X is X+. Prove that, for a set of attributes X, the smallest closed set containing X is X+. We appeal to contradiction and assume that there is a closed set Z of attributes such that X Z X+. Since the closure operator is monotonic, we have X+ Z+ (X+)+. But Z is a closed set of attributes; hence, Z+ = Z. We also have proven that X+ = (X+)+. Therefore, X+ Z X+ and Z = X+. 6. Let R be a relation schema with two sets of functional dependencies G and F. Suppose G F. Prove that G+ F+, i.e. that the closure operator for functional dependencies is monotonic. We prove that G+ F+ if G F. Let XY G+. By completeness, XY can be derived from G using the inference rules. Since G F, XY can be derived from F using the inference rules. By soundness, XY F+. 7. Let R be a relation schema with set of functional dependencies F. Prove that F+ = (F+)+. To show that F+ = (F+)+, we need only show that (F+)+ F+ since F+ (F+)+, i.e. for any set of functional dependencies G, it is always the case that G G+. Thus, let XY (F+)+. By completeness, XY is derivable from F+ using the inference rules. By completeness, any functional dependency in F+ is derivable from F using the inference rules. Hence, XY is derivable from F using the inference rules. By soundness, XY F+. 8. Let R be a relation schema and F a set of functional dependencies for R. Let X, Y, W and Z be sets of attributes of R. Armstrong’s Axioms are: A1. A2. A3. if Y X then XY is in F+. if XY is in F+, then XZYZ is in F+. if XY and YZ are in F+, then XZ is in F+. The following set of inference rules has been introduced: FD1. XX is in F+. FD2. if XYZ is in F+, then XY is in F+. FD3. if XWY and YZ are in F+ then XWYZ is in F+. Prove the second set of inference rules is equivalent to Armstrong’s Axioms by proving that: a. Armstrong’s Axioms implies the second set of inference rules. FD1: XX is in F+; follows from A1 since X X. FD2: if XYZ is in F+, then XY is in F+; follows from decomposition. FD3: if XWY and YZ are in F+ then XWYZ is in F+; follows from the extended transitivity rule. b. The second set of inference rules implies Armstrong’s Axioms. Now assume that FD1, FD2 and FD 3 hold. We prove that Armstrong’s Axioms may be derived from these three rules. 9. A1: Suppose that Y X. Z such that X = YZ. Since XX is in F+, by FD2, XY is in F+. A2: XZXZ is in F+ by FD1. XY is in F+ by assumption. By FD3, XZXYZ is in F+. By FD2, XZXY is in F+. A3: Assume XY and YZ are in F+. By FD3, XYZ is in F+. By FD2, XY is in F+. We have studied functional dependencies for a relation schema R. We now define another class of dependencies for a relation schema R. Let X be a set of attributes of R; we say α(X) holds in an instance r of R if any two records of r that agree on the X attributes agree on every attribute of R. Let G be a set of these dependencies, i.e. G = {α (X1), α(X2), …}. An instance r of R is said to bevalid if every dependency, α(Xi) in G, holds in r. a. Find a set of inference rules for this class of dependencies. Consider the inference rule: if α(X) G+ and Y is any set of attributes of R, then α(XY) G+. b. Prove that your inference rules are sound. Suppose α(X) G+ and Y is any set of attributes of R. If r is a valid instance of R and any two records agree on the XY attributes, then the two records agree on the X attributes. Since α(X) G+, the two records agree on all the attributes of R. Hence, the two records agree on the XY attributes and α(XY) G+. c. Prove that your inference rules are complete. We need to prove that if α(Z) G+ for any set of attributes Z of R, then α(Xi) G such that Xi Z. We prove the contrapositive: if Xi Z for any α(Xi) G, then α(Z) G+. For each i, select an attribute Ai Xi but Ai Z. Create an instance r of R with two rows t1 and t2 such that t1 and t2 disagree on each Ai attribute but agree on all the other attributes. This instance is valid as no two records agree on any Xi attributes. However, both records agree on all the Z attributes but are distinct records. Thus, α(Z) G+ 10. Let R be a relation schema with set of functional dependencies F. If X is a set of attributes of R, we say X is closed if X = X+. It is obvious that if X is a set of attributes such that the left hand side of no functional dependency in F is a subset of X, then X is closed. Prove or disprove the converse of this statement. The converse is not true. Consider R as a set of attributes R, R is a closed set of attributes since R+ = R. But any non-trivial functional dependency in F has a left hand side as a subset of R.