CS FundamentalsVery hardGATE CS (PYQ pattern)
IA(x): 1, 2, 3, NULL, 5 and IB(y): 2, 2, 5, 7. Let p = rows of IA satisfying x IN (SELECT y FROM IB), q = rows of IA satisfying x NOT IN (SELECT y FROM IB), and r = rows of IA JOIN IB ON IA.x = IB.y. What is (p, q, r)?
- A. (2, 2, 2)
- B. (2, 3, 3)
- C. (2, 2, 3)
- D. (3, 2, 2)
Correct answer: C. (2, 2, 3)
IN does not multiply rows: 2 and 5 qualify, p = 2. NOT IN: 1 and 3 qualify, NULL gives unknown, so q = 2. The join pairs row 2 with both 2s and 5 with one 5: r = 3.
More DBMS and SQL questions
- T1 executes W1(A), C1 and T2 executes R2(A), W2(B), C2, each in the stated order. Among all interleavings of the five operations, how many…
- Strict two-phase locking with shared locks for reads and exclusive for writes (a transaction already holding S can upgrade to X only if no…
- Transactions T1..T5 have timestamps equal to their numbers (T1 is oldest). Seven independent lock conflicts occur, written (requester…
- Log (LSN: record): 1: T1 update P1; 2: T2 update P2; 3: T1 update P3; 4: begincheckpoint, whose endcheckpoint records ATT = {T1, T2} and…
- Log (LSN: record): 1: T1 update P1; 2: T2 update P2; 3: T1 update P3; 4: begincheckpoint, whose endcheckpoint records ATT = {T1, T2} and…
- A system uses UNDO-only logging; log records <T,item,old value> hold the value BEFORE the update. Log: <T1 start>, <T1,A,10>, <T2 start>…