GATE / CS ARCHIVE

GATE CSE 2017 SET 2 / QUESTION 19

GATE CSE 2017 Set 2 Q19

Database Management Systems · Database Models, Architecture & ER Diagrams · Full GATE CSE 2017 Set 2 paper

GATE 2017 Set 2, Q19 1 mark · NAT
Report issue

Database Models, Architecture & ER Diagrams

Question 19, GATE 2017: T1(P,Q) contains (2,2),(3,8),(7,3),(5,8),(6,9),(8,5),(9,8). T2(R,S) contains (2,2),(8,3),(3,2),(9,7),(5,7),(7,2). P and R are their primary keys. T1.Q references T2.R with ON DELETE CASCADE and ON UPDATE CASCADE. T2.S references T1.P with ON DELETE SET NULL and ON UPDATE CASCADE. Delete (3,8) from T1. How many additional T1 records must be deleted?
Tap to enlarge
Answer & solution

Official answer: 0.0

Our answer: 0

1. Follow the incoming foreign-key references to the deleted key P=3. In T2, only row (R=8,S=3) references this value through S. Its specified action is ON DELETE SET NULL, so it becomes (8,NULL).

2. Crucially, this action neither deletes the T2 row nor changes its primary key R=8. The references from T1.Q to T2.R remain valid, including Q=8 values in other T1 rows.

3. T1's ON DELETE CASCADE would apply if a referenced T2 row were deleted; that has not happened. Nor has a referenced primary key been updated. Thus no cascade returns to T1 and the number of additional deletions is 0. A change to a foreign-key field is not automatically a change to the key referenced by the opposite table.

Original paper, page 8 · Answer key