CS FundamentalsVery hardGATE CS
P(g, v) = (a, 5), (a, 7), (a, 7), (b, 3), (b, NULL), (b, 9), (c, 4), (c, 4), (d, NULL), (NULL, 1), (NULL, 2). How many rows does SELECT * FROM P x JOIN P y ON x.g = y.g AND x.v < y.v return?
- A. 14
- B. 5
- C. 2
- D. 3
Correct answer: D. 3
Rows join only within equal non-NULL g, and the comparison v < v is UNKNOWN whenever either v is NULL, so NULLs never match. Counting pairs in each group gives 3; with <= the identical rows would also pair, giving 14.
More DBMS and SQL questions
- T(g, v) = (g1, 5), (g1, 15), (g2, 8), (g2, 9), (g2, NULL), (g3, 50), (g4, NULL), (g4, NULL), (g5, 12), (g5, 3). How many groups does…
- Tk(s, c) = (s1, c1), (s1, c2), (s1, c3), (s2, c1), (s2, c2), (s3, c1), (s3, c2), (s3, c3), (s3, c4), (s4, c3), (s5, c2), (s5, c3), (s5…
- M(s) holds the scores 90, 85, 85, 80, 80, 80, 70, 70, 60. What is the sum over all nine rows of (RANK() OVER (ORDER BY s DESC)…
- A(x) = (3, 5, NULL, 8, 9, 12) and B(x) = (4, NULL, 6). How many rows does SELECT x FROM A WHERE x > ALL (SELECT x FROM B) return? (ALL is…
- R(A, B) has 5000 tuples with V(R, B) = 100 distinct B values. S(B, C) has 3000 tuples with V(S, B) = 300 and V(S, C) = 60. Using the…
- R(A, B, C, D, E, F, G) has the functional dependencies AB -> C, C -> D, D -> E, E -> C, F -> G, BG -> A and AE -> F. How many candidate…