Consider the following tables T1 and T2 In table T1, P is the primary key and…

2017

Consider the following tables T1 and T2

In table T1, P is the primary key and Q is the foreign key referencing R in table T2 with on-delete cascade and on-update cascade. In table T2, is the primary key and S is the foreign key referencing  in table T1 with on-delete set NULL and on-update cascade. In order to delete record ⟨3,8⟩ from the table T1, the number of additional records that need to be deleted from table T1 is _______

Attempted by 189 students.

Show answer & explanation

Correct answer: 0

Answer: 0 additional records

Explanation:

  • Foreign keys and actions: T1.Q references T2.R with ON DELETE CASCADE (so deleting a T2 row would delete referencing T1 rows). T2.S references T1.P with ON DELETE SET NULL (so deleting a T1 row sets matching T2.S values to NULL, without deleting those T2 rows).

  • We delete the T1 row with P = 3 (the row ⟨3,8⟩). Any T2 rows with S = 3 will have S set to NULL; they are not deleted. In the given data, the T2 row (R = 8, S = 3) becomes (R = 8, S = NULL).

  • No T2 rows are deleted, so there is no ON DELETE CASCADE from T2 back to T1. Therefore no additional rows in T1 are deleted.

  • Conclusion: 0 additional records in T1 need to be deleted.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir