Algorithm Search⌘K

Theoremcore

Heath's theorem

Also called lossless decomposition by a functional dependency.

If X -> Y holds in a relation over the attributes XYZ, the relation is the join of its projections on XY and XZ. Fagin showed that the exact condition is the MVD X ->> Y.

Heath's theorem says that a functional dependency X→YX \to Y lets you split a relation into its projections on XYXY and on XX with the other attributes, and get it back with a natural join. Fagin (1977) found the exact condition for this, the multivalued dependency X↠YX \twoheadrightarrow Y. Both are statements about one relation. The lossless join page is about a schema and a set of FDs, and proves that a split in two parts is lossless under FDs exactly when the common attributes fix one part. The tableau test handles any number of parts.

Statement

Let UU be a finite set of attributes, let X,Y⊆UX, Y \subseteq U, and let Z=U−XYZ = U - XY, where XYXY means X∪YX \cup Y. We use set semantics: a relation rr over UU is a finite set of tuples, and projection and join remove duplicates. Write J(r)=πXY(r)⋈πXZ(r)J(r) = \pi_{XY}(r) \bowtie \pi_{XZ}(r).

Theorem (Heath 1971). If rr satisfies X→YX \to Y, then r=J(r)r = J(r).

Theorem (Fagin 1977). r=J(r)r = J(r) if and only if rr satisfies X↠YX \twoheadrightarrow Y, that is: for any two tuples u,v∈ru, v \in r with u[X]=v[X]u[X] = v[X], there is a tuple w∈rw \in r with w[XY]=u[XY]w[XY] = u[XY] and w[Z]=v[Z]w[Z] = v[Z].

In plain words

Suppose each value in some columns fixes the value in some other columns, for example each department has one manager. Then you can cut the table into two narrower tables that share the deciding columns: one with the deciding columns and the fixed columns, one with the deciding columns and everything else. Joining the two narrow tables on the shared columns gives back exactly the rows you started with, no more and no fewer.

Fagin found the precise rule. The split works exactly when, for each value of the shared columns, the two halves combine freely: every left half that goes with that value pairs with every right half that goes with it. A fixed value is one special case of free combination, because there is only one left half to pair.

Proof

Lemma. r⊆J(r)r \subseteq J(r). A tuple tt over UU is in J(r)J(r) if and only if there are u,v∈ru, v \in r with u[XY]=t[XY]u[XY] = t[XY] and v[XZ]=t[XZ]v[XZ] = t[XZ].

Proof. The natural join of πXY(r)\pi_{XY}(r) and πXZ(r)\pi_{XZ}(r) is joined on the common attributes XY∩XZ=XXY \cap XZ = X, since Y∩Z=∅Y \cap Z = \emptyset. A tuple tt over XY∪XZ=UXY \cup XZ = U is in it exactly when t[XY]∈πXY(r)t[XY] \in \pi_{XY}(r) and t[XZ]∈πXZ(r)t[XZ] \in \pi_{XZ}(r), which is the condition with uu and vv. For t∈rt \in r, take u=v=tu = v = t. □\square

Proof of Heath's theorem. By the lemma it is enough to show J(r)⊆rJ(r) \subseteq r. Let t∈J(r)t \in J(r), with u,v∈ru, v \in r as in the lemma. Then u[X]=t[X]=v[X]u[X] = t[X] = v[X]. Since rr satisfies X→YX \to Y, v[Y]=u[Y]=t[Y]v[Y] = u[Y] = t[Y]. So vv agrees with tt on XX, on YY and on ZZ, that is on UU, and t=v∈rt = v \in r. □\square

Proof of Fagin's theorem. If. Let rr satisfy X↠YX \twoheadrightarrow Y and let t∈J(r)t \in J(r), with u,vu, v as in the lemma. Then u[X]=t[X]=v[X]u[X] = t[X] = v[X], so there is w∈rw \in r with w[XY]=u[XY]=t[XY]w[XY] = u[XY] = t[XY] and w[Z]=v[Z]=t[Z]w[Z] = v[Z] = t[Z]. So w=tw = t, and t∈rt \in r. With the lemma, r=J(r)r = J(r).

Only if. Let r=J(r)r = J(r), and let u,v∈ru, v \in r with u[X]=v[X]u[X] = v[X]. Define tt over UU by t[XY]=u[XY]t[XY] = u[XY] and t[Z]=v[Z]t[Z] = v[Z]. This is well defined, because XYXY and ZZ are disjoint and cover UU. Then t[X]=u[X]=v[X]t[X] = u[X] = v[X], so t[XZ]=v[XZ]t[XZ] = v[XZ]. By the lemma, t∈J(r)=rt \in J(r) = r, and w=tw = t is the tuple that X↠YX \twoheadrightarrow Y asks for. □\square

Heath's theorem also follows from Fagin's: if X→YX \to Y holds and u[X]=v[X]u[X] = v[X], then w=vw = v works, since v[Y]=u[Y]v[Y] = u[Y].

Consequences

  • Every FD is an MVD. If rr satisfies X→YX \to Y, then by Heath r=J(r)r = J(r), and by Fagin rr satisfies X↠YX \twoheadrightarrow Y. This is the replication rule of the axioms for FDs and MVDs.
  • Complementation. J(r)J(r) does not change when YY and ZZ swap roles, so X↠YX \twoheadrightarrow Y holds exactly when X↠ZX \twoheadrightarrow Z holds. In particular X→ZX \to Z is also enough for the split.
  • BCNF decomposition is lossless. Each step of BCNF decomposition splits a schema on a violating FD X→AX \to A into XAXA and X(U−A)X(U - A). Heath's theorem shows that each step loses nothing, and a lossless split of a part of a lossless split is still lossless.
  • 4NF decomposition is lossless. The 4NF decomposition splits on a violating MVD X↠YX \twoheadrightarrow Y into XYXY and XZXZ. Fagin's theorem is exactly what makes this step lossless.
  • Splits for 2NF and 3NF. Emp(E,D,N)\mathrm{Emp}(E, D, N) with E→DE \to D and D→ND \to N splits on D→ND \to N into DNDN and EDED with no loss, which removes the transitive dependency.
  • The schema version. Under a set FF of FDs only, the split into XYXY and XZXZ is lossless for every relation that satisfies FF exactly when F⊨X→YF \models X \to Y or F⊨X→ZF \models X \to Z. The if part is Heath's theorem. The only if part needs a two-tuple counterexample and is proved on the lossless join page.

Tightness

  • The converse of Heath's theorem is false. Over U=ABCU = ABC take X=AX = A, Y=BY = B and
    r={(x,y1,z1), (x,y1,z2), (x,y2,z1), (x,y2,z2)}.r = \{(x, y_1, z_1),\ (x, y_1, z_2),\ (x, y_2, z_1),\ (x, y_2, z_2)\}.
    Then πAB(r)⋈πAC(r)=r\pi_{AB}(r) \bowtie \pi_{AC}(r) = r, but neither A→BA \to B nor A→CA \to C holds. The MVD A↠BA \twoheadrightarrow B holds, as Fagin's theorem says it must.
  • Bag semantics breaks the theorem. Take the bag r={(x,y,z1),(x,y,z2)}r = \{(x, y, z_1), (x, y, z_2)\} over ABCABC, where A→BA \to B holds. As bags, πAB(r)\pi_{AB}(r) holds (x,y)(x, y) twice, and the bag join with πAC(r)\pi_{AC}(r) gives each of the two tuples twice, four tuples in all. In SQL, the projections must use DISTINCT, or a key must be kept in each part.
  • The common attributes must be the left side. With r={(x1,y,z1),(x2,y,z2)}r = \{(x_1, y, z_1), (x_2, y, z_2)\} over ABCABC, the FD A→BA \to B holds, but the split into ABAB and BCBC joins on BB and gives four tuples, two of them spurious. The theorem needs the part that holds YY and the part that holds ZZ to share exactly XX.
  • Three or more parts. The theorem is about two parts. A relation over SPJSPJ can be the join of its projections on SPSP, PJPJ and JSJS and satisfy no nontrivial MVD at all, so no split in two parts explains it. The right condition is a join dependency, and under FDs the tableau test decides it.

History

Heath (1971) proved the FD case in a paper on file operations that are not acceptable in a relational database, at a time when Codd's normal forms were new. Fagin (1977) introduced multivalued dependencies and fourth normal form, and proved that the MVD is the exact condition for a lossless split in two parts. Aho, Beeri and Ullman (1979) and Maier, Mendelzon and Sagiv (1979) then treated splits into many parts with tableaux and the chase.

References

  1. Ian J. Heath, Unacceptable file operations in a relational data base, Proceedings of the 1971 ACM SIGFIDET Workshop on Data Description, Access and Control, 19 to 33 (1971), a relation that satisfies a functional dependency is the join of two of its projections
  2. Ronald Fagin, Multivalued dependencies and a new normal form for relational databases, ACM Transactions on Database Systems 2(3), 262 to 278 (1977), the definition of multivalued dependencies and the theorem that a relation is the join of its projections on XY and XZ exactly when X ->> Y holds
  3. Serge Abiteboul, Richard Hull and Victor Vianu, Foundations of Databases, Addison-Wesley (1995), Chapter 8 (functional and join dependency), multivalued dependencies and lossless joins
  4. Jeffrey D. Ullman, Principles of Database and Knowledge-Base Systems, Volume I, Computer Science Press (1988), Chapter 7 (design theory for relational databases), lossless-join decompositions and multivalued dependencies

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/CHJRS4/text.yaml