Inclusion Dependencies
Inclusion dependencies were initially described by a number of people (Codd, 1979; Smith and Smith, 1977; Zaniolo, 1979), but were first formalized as inclusion dependencies by Fagin (1981). Inclusion dependencies are a generalization of referential constraints. As such, they provide the foundation upon which referential integrity is based. In common with functional dependencies (see “Functional, Transitive, and Multivalued Dependencies” on page 82), inclusion dependencies represent one‑to‑many relationships (see “One-to-Many Relationships” on page 71); however, inclusion dependencies typically represent relationships between relations (see “Database-Level Constraints” on page 585), while functional dependencies always represent relationships between the primary key of a relation variable and its attributes.
Suppose you have the following table definitions:
Using the notation R.A, where R is the name of a relation variable and A is the name of one of its attributes, you can write the following inclusion dependency:
supplier_parts.part_num → parts.part_num
|
|
|
|
|
|
supplier_parts |
|
|
parts |
|
|
|
|
|
PK |
|
|
PK |
|
|
|
|
|
FK |
FK |
|
part_num |
part_name |
color |
weight |
city |
|
supp_num |
part_num |
quantity |
|
|
|
|
|
|
|
|
|
This inclusion dependency states that the set of values appearing in the attribute part_num of relation variable supplier_parts must be a subset of the values appearing in the attribute part_num of relation variable parts. Notice that this defines a simple foreign key-primary key relationship, though it is only necessary, in order to write a proper referential integrity relationship, that the right hand side (RHS) indicates any candidate key of the specified relation variable, not necessarily its primary key (see “Foreign Key Constraints” on page 594 for more information about this).
The left hand side (LHS) and RHS of a dependency relationship are not required to be a foreign key and a candidate key, respectively. This is merely required to write a correct inclusion dependency expression of a referential integrity relationship.