6.4 Enforcing the Integrity Rules


Integrity rules must be checked whenever an operation is executed that updates the database.
Three types of operations can violate the integrity rules which are: inserting a row, deleting a row and updating a row.

6.4 Enforcing the Integrity Rules



6.4 Enforcing the Integrity Rules


Examples of how Integrity rules can be violated:

Consider the library database shown in Figure 6.4 with the two tables student member and department:

Adding the row below to the student member table would violate the Key Integrity rule and would not be allowed by the database. This is because there is already a row in the table with primary key value 101022778
Similarly, the row below would violate the Key Integrity rule as its primary key value is NULL.
Deleting the 3rd row in the department table would violate the Referential Integrity rule as primary key value ’121’ will be deleted. This will cause the foreign key in the 1st row of the student member table to be invalid.
Similarly, updating the 3rd row in the department table would be invalid as the foreign key in the 1st row of the student member table will be pointing to a primary key with a different value.