CS FundamentalsVery hardGATE CS (PYQ pattern)
Table DU(a, b): (1,NULL), (1,NULL), (2,3), (2,3), (NULL,5), (NULL,5), (1,2). Let x = rows returned by SELECT DISTINCT a, b FROM DU, y = COUNT(DISTINCT a), and z = rows returned by SELECT a FROM DU GROUP BY a. What is the triple (x, y, z)?
- A. (4, 3, 3)
- B. (4, 2, 3)
- C. (5, 2, 3)
- D. (4, 2, 2)
Correct answer: B. (4, 2, 3)
DISTINCT and GROUP BY treat NULLs as equal, so x = 4 distinct pairs ((1,NULL), (2,3), (NULL,5), (1,2)) and z = 3 groups (1, 2, NULL); COUNT(DISTINCT a) ignores NULL, so y = 2.
More DBMS and SQL questions
- R(A, B) and S(B) are relations. Which relational-algebra expression computes the division R ÷ S (the A-values that are paired in R with…
- 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…
- 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…