Home » Database » Database miscellaneous » Question

Database miscellaneous

  1. Consider the following tables T1 and T2.

    In table Tl, P is the primary key and Q is the foreign key referencing R in table T2 with on-delete cascade and onupdate cascade, In table T2, R is the primary key and S is the foreign key referencing P in table Tl with on-delete set NULL and on-update cascade. In order to delete record {3,8} from table Tl. the number of additional records that need to be deleted from table Tl is________.
    1. 0
    2. 1
    3. 2
    4. 4
Correct Option: A

As given that, Q → R (Primary Key)
S → P (Primary Key)
Entry to be deleted – P(3) and Q (8) in T1 table Q can be deleted directly.
Now, S → P but the relationship given is on delete set Null, therefore when we delete 3 from T1, the entry in T2 having 3 will be NULL.
Consider the tables T1 and T2 :

No other record need to delete because of deletion of (3, 8) record from T1. Hence, 0 is correct answer.



Your comments will be displayed only after manual approval.