CS FundamentalsVery hardGATE CS (PYQ pattern)
Relations R(A, B, C) with key A and S(C, D) with key C, where R.C is a foreign key to S. A row of S that is referenced by some R rows is deleted. Which referential action leaves the database consistent while keeping the R rows (and not deleting them)?
- A. ON DELETE CASCADE
- B. NO ACTION (the delete succeeds immediately)
- C. Do nothing; foreign keys are not checked on deletes
- D. ON DELETE SET NULL (if R.C allows NULL) or SET DEFAULT with a valid default
Correct answer: D. ON DELETE SET NULL (if R.C allows NULL) or SET DEFAULT with a valid default
CASCADE would delete the R rows; NO ACTION/RESTRICT would reject the delete. SET NULL (or SET DEFAULT to an existing key) keeps the R rows while removing the dangling reference.
More DBMS and SQL questions
- PA(id, k): (1,1), (2,2), (3,2), (4,3), (5,NULL), (6,4). PB(k, z): (1,9), (2,9), (2,8), (NULL,7). Let p = rows of SELECT FROM PA LEFT JOIN…
- GB(id, v): (1,5), (2,12), (3,18), (4,25), (5,31), (6,39), (7,NULL). The query SELECT v / 10, COUNT() FROM GB GROUP BY v / 10 uses integer…
- Three transactions each execute R(A) followed by W(A) on the same item A. Among all interleavings of the six operations (each…
- T1: R(A), W(A), R(B) and T2: R(B), W(B), R(A), each in that order. Of the C(6,3) = 20 interleavings, how many are conflict-serializable?
- T1: W(A) W(B) and T2: W(B) W(A) run under strict 2PL (exclusive locks held until the transaction ends; a schedule counts only if no…
- Table T(x) holds the values 1, 2, 3, NULL and table U(y) holds 2, NULL. Let Q1 = SELECT COUNT() FROM T WHERE x NOT IN (SELECT y FROM U)…