I'm reading a textbook containing the following question:
Given the following relation R {A,B,C,D,E,H} and the functional
dependencies AB->CD, BC->D, C->H, D->HB, CH->AE
does the following decomposition is dependency preserving?
R1(A,C,E,H) R2(B,D,H), R3(A,B,C), R4(B,C,D)
The answer of the textbook was that it is in fact functional dependency preserving, where I thought it wasn't because of the dependency AB->D
Reading this answer made it even more confusing, because it made it seems like if there is a key inside one of the sub relations, the decomposition must be dependency preserving
A counter example that I couldn't dispute is
For the two rows
a1 b1 c1 d1 h1 e2
and
a2 b1 c2 d2 h2 e2
all the F.D of R hold, but now R3 has
a1 b1 c1 and a2 b1 c2
and R4 has
b1 c1 d1
and
b1 c2 d2
,
joining R3 and R4 on B gives a1 b1 c2 d2
which breaks the AB->D
F.D
In the example the dependencies are preserved as indicated by AntC in the comments.
The condition that a candidate key of the original relation is present in a decomposed relation is not a guarantee that dependencies are preserved.
Consider for instance the relation R(A B C D E)
with dependencies {A → E, BCE → A, D → C}
and the decomposition R1(A B D)
, R2(A E)
, R3(C D)
. The relation R1 contains one of the candidate keys of the original relation ({ABD}
), but in the decomposition the dependency {BCE → A}
is not preserved.
The fact that one of the original keys is present in one decomposed relation could be an indication that the decomposition is lossless, but in general there is no relation between lossless decomposition and dependencies preservation (see for instance this). There is however a result that connects in some way the two properties, as shown in an answer to the question cited.