Following table has two attributes Employee_id and Manager_id, where…
2019
Following table has two attributes Employee_id and Manager_id, where Employee_id is a primary key and manager_id is a foreign key referencing Employee_id with on-delete cascade:
Employee – Manager Table
Employee_id | Manager_id |
|---|---|
20 | 40 |
25 | 40 |
30 | 35 |
35 | 20 |
40 | 45 |
45 | 25 |
On deleting the table (20,40), the set of other tuples that must be deleted to maintain the referential integrity of table is
- A.
(30,35) only
- B.
(30,35) and (35,20) only
- C.
(35,20) only
- D.
(40,45) and (25,40) only
Attempted by 780 students.
Show answer & explanation
Correct answer: B
Deleting the tuple with Employee_id = 20 triggers cascading deletes for any rows whose Manager_id equals 20.
Step-by-step cascade:
Delete (20,40).
Rows with Manager_id = 20 must be deleted: (35,20).
Deleting (35,20) forces deletion of rows with Manager_id = 35: (30,35).
Final set of additional tuples deleted: (35,20) and (30,35).
A video solution is available for this question — log in and enroll to watch it.