Let R(a, b, c) and S(d, e, f) be two relations in which d is the foreign key…
1997
Let R(a, b, c) and S(d, e, f) be two relations in which d is the foreign key of S that refers to the primary key of R. Consider the following operations on R and S:
1. Insert into R
2. Insert into S
3. Delete from R
4. Delete from S
Which of the following can cause violation of the referential integrity constraint?
- A.
None of (1), (2), (3) or (4) can cause its violation
- B.
All of (1), (2), (3) and (4) can cause its violation
- C.
Both (1) and (4) can cause its violation
- D.
Both (2) and (3) can cause its violation
Attempted by 67 students.
Show answer & explanation
Correct answer: D
Referential integrity requires every foreign-key value in S(d, e, f) to match an existing referenced primary-key value in R(a, b, c).
Operation 2, insert into S, can violate the constraint if the inserted tuple has a d value that is not present as a primary-key value in R.
Operation 3, delete from R, can violate the constraint if the deleted primary-key value is still referenced by one or more tuples in S.
Operation 1, insert into R, only adds a referenced parent value. Operation 4, delete from S, removes a referencing child tuple. These two operations do not create dangling references.
Therefore, both (2) and (3) can cause violation of referential integrity.