ON DELETE CASCADE in employee hierarchy

December 4, 2026 · Team EasyExamNotes · 1 min read (est.) · 0 comments

Share on WhatsApp

← RGPV CS-502 DBMS November 2022 solved question paper

RGPV CS-502 (GS) | November 2022 | Q2(a) | 7 marks

Question (restated): For Emp_Manager with Employee_ID as primary key and Manager_ID as a self-referencing cascading foreign key, determine the effect of deleting employee 2.

Answer

ON DELETE CASCADE in employee hierarchy
ON DELETE CASCADE in employee hierarchy

Given relation

Employee_ID Manager_ID
2 3
4 5
6 7
8 2
10 4
12 6
14 8
16 2

ON DELETE CASCADE propagates deletion of a referenced parent row to every dependent row. Since the foreign key refers to the same table, propagation can continue through multiple levels.

DELETE FROM Emp_Manager WHERE Employee_ID = 2;

Step-by-step solution

First remove (2,3). Employees 8 and 16 reference employee 2, so their rows (8,2) and (16,2) are removed. Employee 14 references employee 8, so (14,8) is also removed. No other listed row references any of these deleted employees.

Deleted employee Reason
2 Explicit deletion
8 Manager 2
16 Manager 2
14 Manager 8

Remaining tuples

Employee_ID Manager_ID
4 5
6 7
10 4
12 6

Answer: Four tuples are deleted. The question has a consistency caveat: managers 3, 5 and 7 are absent from the supplied rows. A fully enforced self-referencing foreign key would reject these rows unless the referenced employees exist elsewhere in the complete relation or constraints are not enforced. The calculation assumes the displayed rows are the relevant subset and no additional descendants exist.

Further reading: Silberschatz, Korth and Sudarshan, Database System Concepts.

← RGPV CS-502 DBMS November 2022 solved question paper

Discussion

Ask a question, share your thoughts or report an error.

Sign in to participate in the discussion.

Join the discussion