Show that it is possible to ensure that a dependency-preserving decomposition into 3NF is a lossless decomposition by guaranteeing that at least one schema contains a candidate key for the schema being decomposed. (Hint: Show that the join of all the projections onto the schemas of the decomposition cannot have more tuples than the original relation.)
Let be a set of functional dependencies that hold on a schema . Let be a dependency-preserving 3NF decomposition of . Let be a candidate key for .
Consider a legal instance of . Let . We want to prove that .
We claim that if and are two tuples in such that , then . To prove this claim, we use the following inductive argument: Let , where each is the restriction of to the schema in . Consider the use of the algorithm in Figure 7.8 to compute the closure of under . We use induction on the number of times that the for loop in the algorithm is executed.
-
Basis: In the first step of the algorithm, result is assigned to X, and hence given that , we know that is true.
-
Induction Step: Let be true at the end of the k th execution of the for loop. Suppose the functional dependency considered in the k + 1 th execution of the for loop is , and that . implies that is true. The facts that holds for some attribute set in and that and are in imply that is also true. Since is now added to result by the algorithm, we know that is true at the end of the k + 1 th execution of the for loop.
Since is dependency-preserving and is a key for , all attributes in are in result when the algorithm terminates. Thus, is true, that is, - as claimed earlier.
Our claim implies that the size of is equal to the size of . Note also that (since is a key for ). Thus we have proved that the size of equals the size of . Using the result of Exercise 7.12, we know that . Hence we conclude that .
Note that since is trivially in 3NF, is a dependency-preserving lossless decomposition into 3NF.