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 and a list of attributes, is the tuple .
Definition (Casanova, Fagin and Papadimitriou 1984). Let and be relation names, which may be equal. Let be a list of distinct attributes of and a list of distinct attributes of , of the same length . The inclusion dependency holds in a database if
with the columns matched in order: for each there is with for . The number is the width of the IND, and the IND is unary if . It is trivial if and .
As a first-order sentence. With one variable per attribute, is the tuple-generating dependency
where has the variable of at the place of , and a new variable of at each other place. It has one atom on each side, and the variables of are existential when has attributes outside .
Key-based INDs and foreign keys. If is a key of (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.
- Reflexivity. .
- Projection and permutation. From infer for any list of distinct indices.
- Transitivity. From and infer .
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 , 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 and , the IND says that each order belongs to a known customer. It is key-based, since is a key.
- One relation. In , the IND says that each manager is an employee.
- Order of the columns. and are different INDs. For and the first holds and the second fails.
- Non-example: a wide IND from narrow ones. implies and , by rule 2. The converse fails: and satisfy both unary INDs, but is not in .
- Finite and unrestricted implication differ with FDs. Let have attributes and , and let . On a finite relation, the FD makes the image of a function on , so , and the IND gives . So the two sets are equal, and implies on finite databases. The infinite relation satisfies , but is in and not in . So does not imply on all databases.
- A chase that does not stop. Repair for with the chase: add with a new value , then , 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.
Related definitions
- 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
- 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
- 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
- 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
- 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
- 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.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag DCKXBX Edit this page History Report an error Markdown