![]() |
A Relational Database Management System (RDMS) enforces integrity rules to ensure the accuracy and accessibility of the data. |
![]() |
Such rules govern which operations can be performed on the data in addition to putting constraints on the structure of the database. |
![]() |
There are three integrity rules that a relational database follow which are: the Key Integrity rule, the Entity Integrity rule and the Referential Integrity rule which are described next. |
![]() |
The Key Integrity rule specifies that rows in a table must be unique with no row duplication. |
![]() |
This is useful to remove any data ambiguity. |
![]() |
Thus, tables are defined as a unique set of rows with no two rows having the same combination of values for their attributes. |
![]() |
Key constraints enforce this rule as follows (which we discussed earlier): |
![]() |
Candidate Key: that is an attribute or a minimal combination of attributes that uniquely identify any row in a table. |
![]() |
Minimal means that removing an attribute from the candidate key causes the inability of the candidate key to identify any row uniquely, thus not being a candidate key anymore. | ||
![]() |
There could be more than one candidate key in a table. |
![]() |
Primary Key: is the candidate key chosen in the definition of the table schema to uniquely identify each row in the table. |
![]() |
The Entity Integrity rule states that no attribute that is part of a primary key is allowed to have value NULL. |
![]() |
If NULL values are allowed for primary key attributes, then two rows can have NULL as primary key values and thus the two rows can’t be uniquely identified. |
![]() |
This causes the Key Integrity rule to be violated. |
![]() |
An illustration on how the Entity Integrity rule is shown in Figure 5.3 with the student member table having two rows with NULL values for the primary key attribute. |

![]() |
The Referential Integrity rule is concerned with the linking between tables using foreign keys. |
![]() |
It states that an attribute in a table schema T1 is a foreign key if: |
![]() |
Thus, the Referential Integrity rule ensures that any foreign key value is always pointing to a primary key row in the other table. |
![]() |
References to non-existing primary keys are not allowed. If a primary key referred by a foreign key does not exist, the foreign key value must be NULL. |