GATE / CS ARCHIVE

GATE CSE 2005 / QUESTION 76

Transitive cascading deletion

Database Management Systems · Database Models, Architecture & ER Diagrams · Full GATE CSE 2005 paper

GATE 2005, Q76 2 marks · MCQ
Report issue

Database Models, Architecture & ER Diagrams

Question 76, GATE 2005: Table(A, C), primary key A, C references A ON DELETE CASCADE, contains (2, 4),(3, 4),(4, 3),(5, 2),(7, 2),(9, 5),(6, 4). Besides(2, 4), which rows must be deleted when it is removed? A(3, 4),(6, 4); B(5, 2),(7, 2); C(5, 2),(7, 2),(9, 5); D(3, 4),(4, 3),(6, 4).
Question 76, GATE 2005: Table(A, C), primary key A, C references A ON DELETE CASCADE, contains (2, 4),(3, 4),(4, 3),(5, 2),(7, 2),(9, 5),(6, 4). Besides(2, 4), which rows must be deleted when it is removed? A(3, 4),(6, 4); B(5, 2),(7, 2); C(5, 2),(7, 2),(9, 5); D(3, 4),(4, 3),(6, 4).
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Deleting key A=2 directly deletes the referencing rows (5, 2) and (7, 2). Deleting A=5 in turn deletes (9, 5). Nothing points to 7 or 9 in the displayed instance. Rows (3, 4),(4, 3),(6, 4) do not depend on key 2 and remain. The additional deletion set is {(5, 2),(7, 2),(9, 5)}, option C.

Follow references toward deleted primary-key values, not outward along the deleted row’s own foreign key. Removing key 2 first removes rows with C=2, namely 5 and 7. Removing key 5 then removes row 9. No remaining row points to 7 or 9. The cycle 3↔4 and row 6→4 are unrelated to deletion of 2, so they survive. Cascades must be followed transitively, which is why choice B is incomplete.

Original paper, page 10