|
In a relationship model, in contradiction to an entity relationship model ERM, there is no way to model relationships between tuples explicitly. Therefore relationships are modeled implicitly using a primary- and foreign-key concept.
A relationship between two schemes is established by using the
domain of the primary key in one scheme as the domain of a foreign key in a
second scheme (with the according attributes).
Referential integrity constraints ensure that any
foreign key value is always pointing on an primary key of an existing tuple.
References to non-existing primary keys are not allowed. In such a case the
foreign key value must be set to NULL.
The relational scheme containing the
foreign key is called the referencing scheme, the
scheme with the primary key is called the referenced
scheme.A foreign key can also point to its own
scheme.
In the early days of computer databases, only workstations
were able to check for referential integrity. Today most PC-based database
systems are able to check for referential integrity.
In the above table Division we have Div_No as a primary key. In the second table Employee this key is used as a foreign key to associate each member to one department. For each department number in the table Employee there exists a department in the table Division. These tables are integer. If we would insert a tuple "4, Weber, A5" into table Employee then a database system should refuse this operation because in table Division there exists no value A5 and therefore there is no integrity.