Referential Integrity constraints
Referential Integrity constraints
The table from which the values are derived is known as Master or Referenced Table and the Table in
which values are inserted accordingly is known as Child or Referencing Table. In other words, we can
say that the table containing the foreign key is called the child table, and the table containing
the Primary key/candidate key is called the referenced or parent table.
• Referential Integrity constraint is enforced when a foreign key references the primary key of a
relation.
• It specifies that all the values taken by the foreign key must either be available in the relation
of the primary key or be null.
Referential Integrity Constraint Violation-
There are following three possible causes of violation of referential integrity constraint-
Cause-01: Insertion in a referencing relation
Cause-02: Deletion from a referenced relation
Cause-03: Updation in a referenced relation
1 Rahul 22 CS
2 Anjali 21 CS
3 Teena 20 IT
Branch
Branch_Code Branch_Name
CS Computer Science
EE Electronics Engineering
IT Information Technology
CE Civil Engineering
Here,
• In relation “Student”, we cannot insert any student having branch code ME (Mechanical
Engineering).
• This is because branch code ME is not present in the relation “Branch”.
Method-02:
• This method involves aborting or deleting the request for a deletion from the referenced relation
if the value is used by the referencing relation.
Method-03:
• This method involves setting the value being deleted from the referenced relation to NULL or
some other value in the referencing relation if the referencing attribute uses that value.
Method-02:
• This method involves aborting or deleting the request for an updation of the referenced relation
if the value is used by the referencing relation.
Method-03:
• This method involves setting the value being updated in the referenced relation to NULL or
some other value in the referencing relation if the referencing attribute uses that value.