CS FundamentalsVery hardGATE CS (PYQ pattern)
R(A, B): (1,x), (2,y), (3,z), (4,NULL). S(B, C): (x,10), (x,11), (y,20), (w,30), (NULL,40). How many rows does SELECT * FROM R FULL OUTER JOIN S ON R.B = S.B AND S.C > 10 return, and how many if the condition S.C > 10 is moved from ON into a WHERE clause?
- A. 7 and 7
- B. 6 and 4
- C. 8 and 4
- D. 7 and 4
Correct answer: D. 7 and 4
With the condition in ON: matches are (1,x)-(x,11) and (2,y)-(y,20). Unmatched R rows: 3 and 4; unmatched S rows: (x,10), (w,30), (NULL,40). Total 2 + 2 + 3 = 7. In WHERE, the full join (matches (1,x) twice and (2,y) = 3, plus unmatched R 3 and 4, plus S (w,30) and (NULL,40)) is filtered on S.C > 10: rows with C = 11, 20, 30, 40 survive = 4; rows with NULL C are dropped.
More DBMS and SQL questions
- R(A, B) = {(1,2), (1,3), (2,3), (3,4), (4,1)} is a graph's edge set. How many tuples are in the relation π{A,D}(ρ(R) ⋈{R.B = R2.A} ρ(R2))…
- Multiple-granularity locking (modes IS, IX, S, SIX, X with the standard compatibility matrix). T1 holds IX on table TB and S on row r1 of…
- Snapshot isolation with first-committer-wins: a transaction aborts at commit time if some other transaction that committed after it…
- In a wait-for graph over transactions T1..T7 the edges (Ti waits for Tj) are T1→T2, T2→T3, T3→T1, T3→T4, T4→T5, T5→T4, T6→T3, T2→T7…
- Under strict two-phase locking (shared locks for reads, exclusive for writes, all locks held until commit; a transaction whose lock…
- A B+ tree has leaf nodes holding at most 3 keys. Keys are inserted in the order 50, 20, 80, 10, 30, 60, 90, 70, 40, 25, 35, 5, 65, 75, 95…