hw4 Answerkey
hw4 Answerkey
a. What are some of the nontrivial FDs that can be inferred from the given FDs?
Some examples:
C -> ACD
D -> AD
AB -> ABCD
AC -> ACD
BC -> ABCD
BD -> ABCD
CD -> ACD
ABC -> ABCD
ABD -> ABCD
BCD -> ABCD
b. What are all candidate keys of R?
By calculating an attribute closure we can see the candidate keys are:
AB, BC, and BD
Attribute closure:
A -> A
B -> B
C -> ACD
D -> AD
AB -> ABCD
AC -> ACD
AD -> AD
BC -> ABCD
BD -> ABCD
CD -> ACD
ABC -> ABCD
ABD -> ABCD
ACD -> ACD
BCD -> ABCD
c. Indicate all BCNF violations for R.
C->D and D->A
d. Decompose the relations into collections of relations that are in BCNF.
(ABCD)
|
C->D
|
(CD)
\
|
|
(ABC)
|
C->A
|
(CA)
\
|
|
(AC)
\
|
|
(AD)
|
(BCD)
|
C->D
|
(CD)
\
|
|
(BC)
(Z -> W)
(decomposition rule)
XZ -> XZ
XZ -> YZ
XZ -> Y
(X -> Y)
(decomposition rule)
XZ -> YW
(union rule)
(pseudotransitivity rule)
(transitivity)
10. For the same example relation R with the two tuples as in the notes above, d
ecompose it as R1(A,B) and R2(A,C). Try and merge them back using natural join
and see if the resulting relation is the same as R. Do you think this decomposit
ion is a lossless join decomposition?
Suppose R contains two tuples (1, 2, 3) and (2, 2, 4)
R1 contains (1, 2), (2, 2)
R2 contains (1, 3), (2, 4)
Natural Join on A and we have:
(1, 2, 3), (2, 2, 4)
As you can see, we have gotten the original relations back.
Yes, it is lossless because the dependency A->B is not broken.