CS FundamentalsHardGATE CS (PYQ pattern)

O(oid, c): (1,100), (2,100), (3,200), (4,NULL). I(oid, p, q): (1,5,2), (1,6,1), (2,5,3), (3,7,1), (3,7,1), (9,1,1). C(c, n): (100,u), (100,v), (200,w), (300,z). How many rows does SELECT * FROM O JOIN I ON O.oid = I.oid JOIN C ON O.c = C.c return?

  1. A. 5
  2. B. 9
  3. C. 10
  4. D. 8

Correct answer: D. 8

O ⋈ I gives 5 rows (oid 1 twice, 2 once, 3 twice; oid 4 and 9 do not match). Joining C on c: customer 100 has two names, so rows for oid 1 and 2 double (3 rows become 6), and oid 3 matches one name (2 rows): 8.

More DBMS and SQL questions

Exams that ask this topic