Enforcing Referential Integrity
Consider Students and Enrolled; sid in Enrolled is a foreign key that references Students.
What should be done if an Enrolled tuple with a non-existent student id is inserted? (Reject it!)
What should be done if a Students tuple is deleted?
- Also delete all Enrolled tuples that refer to it.
- Disallow deletion of a Students tuple that is referred to.
- Set sid in Enrolled tuples that refer to it to a default sid.
- (In SQL, also: Set sid in Enrolled tuples that refer to it to a special placeholder null, meaning `unknown’ or `inapplicable’)
Similar if primary key of Students tuple is updated.