Question 16 MCQ · 4.0 marks
(2,2,5) and (3,1,5)
(5,2,4), (1,1,5), (2,2,5) and (3,1,5)
(6,1,1),(7,4,1) and (8,4,7)
All the remaining rows will be deleted
**PDSA**
**Section Id :** 64065359209
**Section Number :** 2
**Section type :** Online
**Mandatory or Optional :** Mandatory
**Number of Questions :** 16
**Number of Questions to be attempted :** 16
**Section Marks :** 50
**Display Number Panel :** Yes
**Section Negative Marks :** 0
**Group All Questions :** No
**Enable Mark as Answered Mark for Review and**
No
**Clear Response :**
**Section Maximum Duration :** 0
**Section Minimum Duration :** 0
**Section Time In :** Minutes
**Maximum Instruction Time :** 0
Published solution
**Answer: D**
**Topic:** Relational Databases — *Cascading Deletes with Self-Referencing Foreign Key*
### Step-by-Step Solution
**Step 1:** In the given table with primary key `X` and foreign key `Z REFERENCES X ON DELETE CASCADE`, deleting a row with `X = v` automatically deletes every row whose `Z = v`, recursively.
**Step 2:** Trace the chain reaction starting from the deletion of `(4, 2, 4)` (`X = 4`):
1. Deleting `X = 4` triggers the deletion of `(5, 2, 4)` because its `Z = 4`.
2. Deleting `X = 5` triggers the deletion of `(1, 1, 5)`, `(2, 2, 5)`, and `(3, 1, 5)` because their `Z = 5`.
3. Deleting `X = 1` triggers the deletion of `(6, 1, 1)` and `(7, 4, 1)` because their `Z = 1`.
4. Deleting `X = 7` triggers the deletion of `(8, 4, 7)` because its `Z = 7`.
**Step 3:** Thus, **all the remaining rows will be deleted**, making **D** correct.
**Key Takeaway / Tip:** Follow the foreign-key dependency chain $4 \leftarrow 5 \leftarrow \{1, 2, 3\} \leftarrow \{6, 7\} \leftarrow 8$ step by step until no matching `Z` values remain.
A: **Incorrect:** Option A ((2,2,5) and (3,1,5)) does not satisfy the conditions derived in the step-by-step analysis for Cascading Deletes with Self-Referencing Foreign Key (correct choice: D).
B: **Incorrect:** Option B ((5,2,4), (1,1,5), (2,2,5) and (3,1,5)) does not satisfy the conditions derived in the step-by-step analysis for Cascading Deletes with Self-Referencing Foreign Key (correct choice: D).
C: **Incorrect:** Option C ((6,1,1),(7,4,1) and (8,4,7)) does not satisfy the conditions derived in the step-by-step analysis for Cascading Deletes with Self-Referencing Foreign Key (correct choice: D).
D: **Correct:** Option D (All the remaining rows will be deleted **PDSA** **Section Id :** 64065359209 **Section Number :** 2 **Section type :** Online **Mandatory or Optional :** Mandatory **Numbe...) matches our derived result under Cascading Deletes with Self-Referencing Foreign Key. Follow the foreign-key dependency chain $4 \leftarrow 5 \leftarrow \{1, 2, 3\} \leftarrow \{6, 7\} \leftarrow 8$ step by step until no matching `Z` values remain.