GATE / CS ARCHIVE

GATE CSE 2001 / QUESTION 2.25

Recursive deletion through a self-referencing foreign key

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

GATE 2001, Q2.25 2 marks · MCQ
Report issue

Database Models, Architecture & ER Diagrams

Question 2.25, GATE 2001: Table geq has nonnull integer lb,ub, primary key lb, and self-referencing foreign key ub with ON DELETE CASCADE. Every row(x,y) obeys y≥x. On deleting(x,y), can a cascaded row(z,w) have z>y, z>x, or w<x, or must deletion be prohibited?
Question 2.25, GATE 2001: Table geq has nonnull integer lb,ub, primary key lb, and self-referencing foreign key ub with ON DELETE CASCADE. Every row(x,y) obeys y≥x. On deleting(x,y), can a cascaded row(z,w) have z>y, z>x, or w<x, or must deletion be prohibited?
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step 1: Deleting parent key x directly cascades to rows(z,w) with w=x. Since every row obeys w≥z, these direct children have z≤x. Cascades continue to their children, so keys along a deletion chain cannot increase. Options requiring z>x or z>y≥x are therefore impossible.

Step 2: A deeper descendant can have w<x. For example the legal rows(3,3),(2,3),(1,2) satisfy the ordering and foreign key. Deleting(3,3) cascades to(2,3) and then(1,2), whose upper value 2 is less than the original x=3.

Thus C is possible. ON DELETE CASCADE means the mere presence of dependent rows does not prohibit the deletion; self-reference is handled by the database’s cascade semantics.

Original paper, page 7