Algorithm Search⌘K

Definitionadvanced

Join dependency

Also called JD.

A constraint that a relation equals the natural join of its projections on given sets of attributes; an MVD is the case of two sets.

A join dependency says that a relation is the natural join of its projections on some given sets of attributes, so it can be stored as those projections and rebuilt without loss. A multivalued dependency is the case of two sets, and join dependencies with three or more sets express constraints that no MVD or FD can. The normalization page mentions them only as the basis of 5NF, and BCNF does not see them at all. This page defines join dependencies, shows when they are trivial and how they relate to MVDs, and gives the standard example.

Definition

Let UU be a finite set of attributes and let X1,…,Xk⊆UX_1, \ldots, X_k \subseteq U with X1∪⋯∪Xk=UX_1 \cup \cdots \cup X_k = U. We use set semantics.

Definition. A relation rr over UU satisfies the join dependency (JD) ⋈[X1,…,Xk]\bowtie[X_1, \ldots, X_k] if

r=πX1(r)⋈πX2(r)⋈⋯⋈πXk(r).r = \pi_{X_1}(r) \bowtie \pi_{X_2}(r) \bowtie \cdots \bowtie \pi_{X_k}(r).

Each tuple of rr is in the join of its own projections, so the condition is that the join adds no tuple. In tuple form: for any t1,…,tk∈rt_1, \ldots, t_k \in r and any tuple tt over UU with t[Xi]=ti[Xi]t[X_i] = t_i[X_i] for each ii, also t∈rt \in r. So a JD is a full tuple-generating dependency. The sets XiX_i are the components, and they form a hypergraph on UU.

Trivial JDs. ⋈[X1,…,Xk]\bowtie[X_1, \ldots, X_k] holds in every relation over UU if and only if some Xi=UX_i = U.

Proof. If Xi=UX_i = U, each tuple tt of the join has t=t[Xi]∈πU(r)=rt = t[X_i] \in \pi_U(r) = r. If no XiX_i is UU, let rr have the kk tuples tit_i with the value 00 on XiX_i and the value ii elsewhere. Each tit_i is 00 on XiX_i, so the all-00 tuple is in the join. It is not in rr, since each tit_i has a value i≠0i \ne 0 outside XiX_i. □\square

Two components are an MVD. With k=2k = 2, the JD ⋈[X1,X2]\bowtie[X_1, X_2] is the MVD X1∩X2↠X1X_1 \cap X_2 \twoheadrightarrow X_1, by Fagin's theorem (see Heath's theorem). Conversely, X↠YX \twoheadrightarrow Y is the JD ⋈[XY,X(U−XY)]\bowtie[XY, X(U - XY)].

Merging components weakens a JD. If rr satisfies ⋈[X1,X2,X3,…,Xk]\bowtie[X_1, X_2, X_3, \ldots, X_k], it satisfies ⋈[X1∪X2,X3,…,Xk]\bowtie[X_1 \cup X_2, X_3, \ldots, X_k]. Proof. A tuple tt of the second join has t[X1X2]∈πX1X2(r)t[X_1 X_2] \in \pi_{X_1 X_2}(r), so t[X1]∈πX1(r)t[X_1] \in \pi_{X_1}(r) and t[X2]∈πX2(r)t[X_2] \in \pi_{X_2}(r), and tt is in the first join, which is rr. □\square So a JD implies each MVD X1∩(X2∪⋯∪Xk)↠X1X_1 \cap (X_2 \cup \cdots \cup X_k) \twoheadrightarrow X_1 that comes from a split of its components into two groups. A component contained in another one can be dropped without changing the JD.

Implication. A set DD of FDs and JDs implies a JD σ\sigma if every relation that satisfies DD satisfies σ\sigma. The chase decides this (Maier, Mendelzon and Sagiv 1979), with a start tableau of one row per component of σ\sigma. With FDs only in DD, this is the tableau test for a lossless join, which runs in polynomial time. With JDs in DD, the tableau can grow, and the chase page gives what is known about the cost.

Examples and non-examples

  • A three-way rule. SPJ(S,P,J)\mathrm{SPJ}(S, P, J) with supplier, part and project, and the rule: if supplier ss supplies part pp, part pp is used in project jj, and ss supplies project jj, then ss supplies pp to jj. This is the JD ⋈[SP,PJ,JS]\bowtie[SP, PJ, JS]. The relation
    r={(s1,p1,j2), (s1,p2,j1), (s2,p1,j1), (s1,p1,j1)}r = \{(s_1, p_1, j_2),\ (s_1, p_2, j_1),\ (s_2, p_1, j_1),\ (s_1, p_1, j_1)\}
    satisfies it. The first three tuples give s1p1s_1 p_1, p1j1p_1 j_1 and j1s1j_1 s_1, and the fourth tuple is the one the rule asks for.
  • Non-example: one tuple missing. Remove (s1,p1,j1)(s_1, p_1, j_1). The projections on SPSP, PJPJ and JSJS still contain s1p1s_1 p_1, p1j1p_1 j_1 and j1s1j_1 s_1, so the join of the three projections has the spurious tuple (s1,p1,j1)(s_1, p_1, j_1), and the JD fails.
  • A JD that is not an MVD. ⋈[SP,PJ,JS]\bowtie[SP, PJ, JS] implies no nontrivial MVD over SPJSPJ. The chase of each of the twelve nontrivial MVDs over three attributes, ∅↠S\emptyset \twoheadrightarrow S to J↠PJ \twoheadrightarrow P, with this JD, ends without an all-00 row. Each split of its components into two groups gives a component equal to SPJSPJ, a trivial JD, which agrees with the merging rule. So no lossless split into two projections explains rr, but the split into three does.
  • MVDs as JDs. In CTB(C,T,B)\mathrm{CTB}(C, T, B), the MVD C↠TC \twoheadrightarrow T is the JD ⋈[CT,CB]\bowtie[CT, CB].
  • Trivial JDs. ⋈[AB,ABC]\bowtie[AB, ABC] over ABCABC holds in every relation, because one component is all of UU.
  • Fifth normal form. A schema is in 5NF when each JD that holds is implied by the candidate keys. SPJ\mathrm{SPJ} with its JD is in 4NF and not in 5NF.
  • Acyclic JDs. If the hypergraph of the components is acyclic, the JD is equivalent to a set of MVDs (Beeri, Fagin, Maier and Yannakakis 1983). The hypergraph of ⋈[SP,PJ,JS]\bowtie[SP, PJ, JS] is a triangle, which is cyclic, and indeed no set of MVDs is equivalent to it.
  • Lossless decomposition. A decomposition (R1,…,Rk)(R_1, \ldots, R_k) of UU is lossless under DD exactly when DD implies ⋈[R1,…,Rk]\bowtie[R_1, \ldots, R_k]. See the lossless join page.
  • Embedded JDs. If X1∪⋯∪XkX_1 \cup \cdots \cup X_k is a proper subset of UU, the JD is required only of the projection on that union. Such embedded dependencies behave differently, and the chase need not stop for them.
  • Ternary relationships. A relationship set of degree three in the ER model is in general not the join of its binary projections. When it is, the JD lets the designer replace it by binary relationships.

References

  1. Ronald Fagin, Normal forms and relational database operators, Proceedings of the 1979 ACM SIGMOD International Conference on Management of Data, 153 to 160 (1979), join dependencies and project-join normal form
  2. Alfred V. Aho, Catriel Beeri and Jeffrey D. Ullman, The theory of joins in relational databases, ACM Transactions on Database Systems 4(3), 297 to 314 (1979), lossless joins of several projections and the tableau test
  3. David Maier, Alberto O. Mendelzon and Yehoshua Sagiv, Testing implications of data dependencies, ACM Transactions on Database Systems 4(4), 455 to 469 (1979), the chase decides implication of functional and join dependencies
  4. Catriel Beeri, Ronald Fagin, David Maier and Mihalis Yannakakis, On the desirability of acyclic database schemes, Journal of the ACM 30(3) (1983), a join dependency with an acyclic hypergraph is equivalent to a set of multivalued dependencies
  5. Serge Abiteboul, Richard Hull and Victor Vianu, Foundations of Databases, Addison-Wesley (1995), Chapter 8 (functional and join dependency), join dependencies and the chase

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/0MG279/text.yaml