CS FundamentalsHardGATE CS (PYQ pattern)

R(A, B) has 100 tuples; R.B is a foreign key to S(B), which is S's primary key, but R.B allows NULL and 10 tuples of R have B = NULL. S has 50 tuples, of which exactly 30 are referenced by some R tuple. How many tuples are in R join S (on B) and in R full outer join S?

  1. A. 100 and 120
  2. B. 90 and 120
  3. C. 90 and 110
  4. D. 100 and 150

Correct answer: B. 90 and 120

Every non-NULL R.B matches exactly one S tuple: 90 joined tuples. The full outer join adds the 10 R tuples with NULL B (they match nothing) and the 20 unreferenced S tuples: 90 + 10 + 20 = 120. Treating the FK as guaranteeing a match for all 100 rows gives 100.

More DBMS and SQL questions

Exams that ask this topic