Algorithm Search⌘K

Definitioncore

Inclusion dependency

Also called IND, referential integrity constraint.

A constraint that the projection of one relation on some attributes is a subset of the projection of another, as a foreign key states.

An inclusion dependency (IND) says that each combination of values that occurs in some columns of one relation also occurs in some columns of another relation, or of the same relation. A foreign key is the common case: each customer number in the orders table must be the number of a customer in the customers table. Casanova, Fagin and Papadimitriou (1984) studied INDs as a class of dependencies. For INDs alone, implication has a short complete set of rules and is PSPACE-complete. Together with functional dependencies, implication becomes undecidable, and a dependency can follow on all finite databases without following on all databases.

Definition

We use set semantics: a relation is a finite set of tuples. For a tuple tt and a list X=A1…AnX = A_1 \ldots A_n of attributes, t[X]t[X] is the tuple (t[A1],…,t[An])(t[A_1], \ldots, t[A_n]).

Definition (Casanova, Fagin and Papadimitriou 1984). Let RR and SS be relation names, which may be equal. Let X=A1…AnX = A_1 \ldots A_n be a list of distinct attributes of RR and Y=B1…BnY = B_1 \ldots B_n a list of distinct attributes of SS, of the same length nn. The inclusion dependency R[X]⊆S[Y]R[X] \subseteq S[Y] holds in a database DD if

πX(RD)⊆πY(SD),\pi_X(R^D) \subseteq \pi_Y(S^D),

with the columns matched in order: for each t∈RDt \in R^D there is s∈SDs \in S^D with t[Ai]=s[Bi]t[A_i] = s[B_i] for i=1,…,ni = 1, \ldots, n. The number nn is the width of the IND, and the IND is unary if n=1n = 1. It is trivial if R=SR = S and X=YX = Y.

As a first-order sentence. With one variable per attribute, R[X]⊆S[Y]R[X] \subseteq S[Y] is the tuple-generating dependency

∀xˉ (R(xˉ)→∃zˉ  S(wˉ)),\forall \bar x \, \big( R(\bar x) \rightarrow \exists \bar z \; S(\bar w) \big),

where wˉ\bar w has the variable of AiA_i at the place of BiB_i, and a new variable of zˉ\bar z at each other place. It has one atom on each side, and the variables of zˉ\bar z are existential when SS has attributes outside YY.

Key-based INDs and foreign keys. If YY is a key of SS (see candidate key), the IND is key-based. A foreign key in SQL, FOREIGN KEY (X) REFERENCES S (Y), is a key-based IND, and referential integrity is the property that all foreign keys hold. So a referential integrity constraint is a special case of an IND, not every IND.

Inference rules (Casanova, Fagin and Papadimitriou 1984). The following three rules are sound and complete for implication of INDs by INDs.

  1. Reflexivity. R[X]⊆R[X]R[X] \subseteq R[X].
  2. Projection and permutation. From R[A1…An]⊆S[B1…Bn]R[A_1 \ldots A_n] \subseteq S[B_1 \ldots B_n] infer R[Ai1…Aik]⊆S[Bi1…Bik]R[A_{i_1} \ldots A_{i_k}] \subseteq S[B_{i_1} \ldots B_{i_k}] for any list i1,…,iki_1, \ldots, i_k of distinct indices.
  3. Transitivity. From R[X]⊆S[Y]R[X] \subseteq S[Y] and S[Y]⊆T[Z]S[Y] \subseteq T[Z] infer R[X]⊆T[Z]R[X] \subseteq T[Z].

Deciding whether a set of INDs implies an IND is PSPACE-complete. For INDs alone, implication on finite databases and implication on all databases are the same. A set of unary INDs is a directed graph on the pairs (R,A)(R, A), and a unary IND follows from it exactly when there is a path, so this case takes linear time.

Examples and non-examples

  • Foreign key. In a schema with Orders(oid,cust,date)\mathit{Orders}(\mathit{oid}, \mathit{cust}, \mathit{date}) and Customers(id,name)\mathit{Customers}(\mathit{id}, \mathit{name}), the IND Orders[cust]⊆Customers[id]\mathit{Orders}[\mathit{cust}] \subseteq \mathit{Customers}[\mathit{id}] says that each order belongs to a known customer. It is key-based, since id\mathit{id} is a key.
  • One relation. In Emp(name,manager)\mathit{Emp}(\mathit{name}, \mathit{manager}), the IND Emp[manager]⊆Emp[name]\mathit{Emp}[\mathit{manager}] \subseteq \mathit{Emp}[\mathit{name}] says that each manager is an employee.
  • Order of the columns. R[AB]⊆S[CD]R[AB] \subseteq S[CD] and R[AB]⊆S[DC]R[AB] \subseteq S[DC] are different INDs. For R={(1,2)}R = \{(1, 2)\} and S={(1,2)}S = \{(1, 2)\} the first holds and the second fails.
  • Non-example: a wide IND from narrow ones. R[AB]⊆S[CD]R[AB] \subseteq S[CD] implies R[A]⊆S[C]R[A] \subseteq S[C] and R[B]⊆S[D]R[B] \subseteq S[D], by rule 2. The converse fails: R={(1,2)}R = \{(1, 2)\} and S={(1,3),(4,2)}S = \{(1, 3), (4, 2)\} satisfy both unary INDs, but (1,2)(1, 2) is not in πCD(S)\pi_{CD}(S).
  • Finite and unrestricted implication differ with FDs. Let RR have attributes AA and BB, and let Σ={A→B, R[A]⊆R[B]}\Sigma = \{A \to B,\ R[A] \subseteq R[B]\}. On a finite relation, the FD makes πB(R)\pi_B(R) the image of a function on πA(R)\pi_A(R), so ∣πB(R)∣≤∣πA(R)∣|\pi_B(R)| \le |\pi_A(R)|, and the IND gives πA(R)⊆πB(R)\pi_A(R) \subseteq \pi_B(R). So the two sets are equal, and Σ\Sigma implies R[B]⊆R[A]R[B] \subseteq R[A] on finite databases. The infinite relation {(i+1,i):i≥0}\{ (i + 1, i) : i \ge 0 \} satisfies Σ\Sigma, but 00 is in πB\pi_B and not in πA\pi_A. So Σ\Sigma does not imply R[B]⊆R[A]R[B] \subseteq R[A] on all databases.
  • A chase that does not stop. Repair R={(a,b)}R = \{(a, b)\} for R[B]⊆R[A]R[B] \subseteq R[A] with the chase: add (b,z1)(b, z_1) with a new value z1z_1, then (z1,z2)(z_1, z_2), and so on. Each new tuple needs another one, so the chase never ends. A cyclic set of INDs can cause this, and weak acyclicity rules it out.
  • Functional dependencies together with INDs. Implication of FDs and INDs together is undecidable, as Mitchell (1983) and Chandra and Vardi (1985) showed independently. The example above shows that finite implication is a different problem for this class. Keys with key-based INDs, the common case in practice, are easier: Johnson and Klug decided containment of conjunctive queries under them.
  • Query containment. Johnson and Klug (1984) decided containment of conjunctive queries under INDs with the chase, and showed that it is PSPACE-complete. This is the basis of query optimization that uses foreign keys, such as removing a join with a table that only checks a foreign key.
  • Tuple-generating dependency. Each IND is a TGD with one atom on each side. TGDs also cover multivalued dependencies and join dependencies.
  • Equality-generating dependency. FDs and keys are EGDs. A schema with keys and foreign keys has EGDs and INDs, and the chase applies both.
  • Implication problem. The dependency implication problem asks the general question for all these classes.

References

  1. Marco A. Casanova, Ronald Fagin and Christos H. Papadimitriou, Inclusion dependencies and their interaction with functional dependencies, Journal of Computer and System Sciences 28(1), 29 to 59 (1984), the definition of inclusion dependencies, the complete set of three inference rules, the PSPACE-completeness of implication, and the interaction with functional dependencies
  2. John C. Mitchell, The implication problem for functional and inclusion dependencies, Information and Control 56(3), 154 to 173 (1983), implication of functional and inclusion dependencies together
  3. Ashok K. Chandra and Moshe Y. Vardi, The implication problem for functional and inclusion dependencies is undecidable, SIAM Journal on Computing 14(3), 671 to 677 (1985), the undecidability of implication for functional and inclusion dependencies together
  4. David S. Johnson and Anthony Klug, Testing containment of conjunctive queries under functional and inclusion dependencies, Journal of Computer and System Sciences 28(1), 167 to 189 (1984), containment of conjunctive queries under inclusion dependencies, by the chase
  5. Serge Abiteboul, Richard Hull and Victor Vianu, Foundations of Databases, Addison-Wesley (1995), Chapter 9 (inclusion dependency), the inference rules, finite and unrestricted implication, and the chase for inclusion 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/DCKXBX/text.yaml