CS FundamentalsModerateProduct placement · SQL round
Table Product(pid, cat, price) rows: (1, 'X', 10), (2, 'X', 20), (3, 'Y', 20), (4, NULL, 30), (5, 'Y', NULL), (6, 'Z', 5). What does this query return?
Table Product(pid, cat, price) rows: (1, 'X', 10), (2, 'X', 20), (3, 'Y', 20), (4, NULL, 30), (5, 'Y', NULL), (6, 'Z', 5).
What does this query return?
SELECT cat, MAX(price) FROM Product WHERE cat IS NOT NULL GROUP BY cat HAVING MIN(price) >= 10 ORDER BY cat;
- A. (X, 20), (Y, 20)
- B. (X, 20)
- C. (Y, 20)
- D. (X, 20), (Y, 20), (Z, 5)
Correct answer: A. (X, 20), (Y, 20)
X: min 10 passes. Y: prices 20 and NULL, MIN ignores NULL so min = 20, passes. Z: min 5 fails.
More DBMS and SQL questions
- R(A, B) = {(1, 1), (1, 2), (1, 4), (2, 2), (4, 2), (4, 4)} and S(B, C) = {(1, 5), (3, 5), (3, 6), (4, 7)}. What is πA(R) − πA(R ⋈ S)?
- R(A, B) = {(1, 4), (2, 1), (2, 4), (3, 2), (3, 3), (4, 4)} and S(B, C) = {(1, 6), (1, 7), (2, 5), (2, 6)}. What is πA(R) − πA(R ⋈ S)?
- Which view is generally updatable in standard SQL (an UPDATE through it maps to exactly one base row)?
- A B+ tree has at most 7 children per internal node and at most 6 keys per leaf. A non-root internal node must have at least ⌈7/2⌉…
- Consider the schedule W2(A), W2(B), R3(A), R3(B), W1(A), R1(B). Which statement is correct?
- R(A, B, C, D) has functional dependencies AC → D, A → D, CD → A, C → A, AB → CD. What is the highest normal form R satisfies?