Lecture 4 - Integrity Constraints
Lecture 4 - Integrity Constraints
Integrity
Constraints
Integrity Constraints
Referential Integrity Constraint
Referenced Relation
Referencing
Relation
Referential Integrity Constraint (Cont.)
🞆 Tuples in the referencing relation R1 have attributes FK (called
foreign key attributes) that reference the primary key attributes PK of
the referenced relation R2.
Referencing Deletion
Relation No Violation
( EMP )
Updation Restricted
Referential Integrity Constraint - INSERTION
Insertion in
Referenced Relation is
allowed
Insertion in
Referencing
Relation is
restricted
Deletion/Updation in Referenced Relation
ON DELETE, CASCADE
ON UPDATE, CASCADE
Deletion/Updation in Referenced Relation
ON DELETE, NO ACTION
ON UPDATE, NO ACTION
Deletion in Referencing Relation
Updation in Referencing Relation
Primary key vs Foreign Key
Primary Key Foreign Key
• Helps you to uniquely • It is a field in the table that is
identify a record in the the primary key of another
table. table.