GATE CS 2005 · SQL Queries

MCQ · 1 mark · Problem DBMS-SQL-0135

The following table has two attributes A and C where A is the primary key and C is the foreign key referencing A with on-delete cascade.\[\begin{array}{|c|c|} \hline A & C \\ \hline 2 & 4 \\ 3 & 4 \\ 4 & 3 \\ 5 & 2 \\ 7 & 2 \\ 9 & 5 \\ 6 & 4 \\ \hline \end{array}\]The set of all tuples that must be additionally deleted to preserve referential integrity when the tuple (2, 4) is deleted is:
  1. A
    (3,4) and (6,4)
  2. B
    (5,2) and (7,2)
  3. C
    (5,2), (7,2) and (9,5)
  4. D
    (3,4), (4,3) and (6,4)

Solve it on GATE DA practice →More Relational Model & SQL problems

Show the worked solution\[\boxed{\text{on-delete cascade: delete every tuple whose } C \text{ is a deleted } A}\]Deleting \((2, 4)\) removes \(A = 2\), so the tuples with \(C = 2\) go: \((5, 2)\) and \((7, 2)\).That removes \(A = 5\) and \(A = 7\): the tuple with \(C = 5\), \((9, 5)\), goes; none has \(C = 7\).Removing \(A = 9\) affects nothing. Additionally deleted: \((5, 2), (7, 2), (9, 5)\).Answer: C

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com