Skip to main content

GATE CSE 2017Databases › ER Modeling & Relational Model FundamentalsVerified

GATE CSE 2017 PYQ: Consider the following tables T 1 T1 T 1 and T 2. T2. T 2. P Q 2 2 3 8 7 3 5 8 6 9 8 5 9 8 T 1 R S 2 2 8 3 3…

Consider the following tables T1T1 and T2.T2.

PQ22 3873586 98598T1RS22 8332975 772T2\overset{T1}{\begin{array}{|c|c|c|} \hline \textbf {P} & \textbf {Q} \\\hline \text {2} & \text{2 }\\\hline \text{3} & \text{8} \\\hline \text{7} & \text{3} \\\hline \text{5} & \text{8} \\\hline \text{6 } &\text{9} \\\hline \text{8} & \text{5} \\\hline \text{9} & \text{8} \\\hline \end{array}} \qquad \overset{T2}{\begin{array}{|c|c|c|} \hline \textbf {R} & \textbf {S} \\\hline \text {2} & \text{2 }\\\hline \text{8} & \text{3} \\\hline \text{3} & \text{2} \\\hline \text{9} & \text{7} \\\hline \text{5 } &\text{7} \\\hline \text{7} & \text{2} \\\hline \end{array}}

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

    Answer

    0

    Approach

    Trace only the referential actions that can reach T1 when T1.P = 3 is deleted. The only foreign key referencing T1.P is T2.S, which has ON DELETE SET NULL, so it causes an update in T2, not a deletion. The T1.Q foreign key references T2.R with ON DELETE CASCADE, but no T2 row is deleted, so it cannot cascade back to T1. Thus no additional T1 record is deleted.

    The deletion of T1(3, 8) triggers only ON DELETE SET NULL on T2.S = 3, changing that T2 row to (8, NULL). No T2 deletion occurs, so the T2-to-T1 cascade path is never activated. Hence 0 additional records need to be deleted from T1.

    Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.