CS FundamentalsModerateGATE CS (PYQ pattern)
SP(id, s): (1,10), (2,10), (3,10), (4,20), (5,20), (6,30), (7,NULL), (8,NULL). How many rows does SELECT * FROM SP a JOIN SP b ON a.s = b.s return?
- A. 4
- B. 14
- C. 16
- D. 13
Correct answer: B. 14
Each row pairs with every row of equal s, including itself: 3 x 3 + 2 x 2 + 1 x 1 = 14; the NULL rows match nothing (NULL = NULL is unknown). Only distinct unordered pairs would be 4.
More DBMS and SQL questions
- Table T(x) has 4 rows. How many rows does each of these return? (a) SELECT COUNT() FROM T HAVING COUNT() > 5; (b) SELECT COUNT() FROM T…
- Which of the following statements about standard SQL are correct? I. A column alias defined in the SELECT list can be used in ORDER BY…
- X1(a): 1, 1, 2, 2, 3, 4 and Y1(a): 2, 4, 5. Let p = rows from SELECT a FROM X1 WHERE a NOT IN (SELECT a FROM Y1) and q = rows from SELECT…
- Tables: P(id); C(id, p) with p referencing P(id) ON DELETE CASCADE; G(id, c) with c referencing C(id) ON DELETE SET NULL. Rows: P = {1…
- Optimistic concurrency control with backward validation. Transactions (start, validation, finish times; read set; write set): T1 (0, 4, 5…
- A two-phase commit has 1 coordinator and 5 participants and uses the read-only optimisation. All 5 receive PREPARE. Three vote YES, one…