Consider two relations R1(A,B) with the tuples (1,5), (3,7) and R2(A,C) =…

2015

Consider two relations R1(A,B) with the tuples (1,5), (3,7) and R2(A,C) = (1,7), (4,9). Assume that R(A,B,C) is the full natural outer join of R1 and R2. Consider the following tuples of the form (A,B,C): \(a\) = (1,5,\(null\)), \(b\) = (1,\(null\),7), \(c\) = (3, \(null\), 9), \(d\) = (4,7,\(null\)), \(e\) = (1,5,7), \(f\) = (3,7,\(null\)), \(g\) = (4,\(null\),9). Which one of the following statements is correct?

  1. A.

    R contains \(a, b, e, f, g\)  but not \(c, d\).

  2. B.

    R contains all of \(a, b, c, d, e, f, g\).

  3. C.

    R contains \(e, f, g\) but not \(a, b\).

  4. D.

    R contains \(e\) but not \(f, g\).

Attempted by 142 students.

Show answer & explanation

Correct answer: C

Key idea: match rows by A; for unmatched A include the row with NULLs for missing attributes.

  • R1 has A = 1 → (1,5) and A = 3 → (3,7).

  • R2 has A = 1 → (1,7) and A = 4 → (4,9).

  • For A = 1 the rows match, producing (1,5,7).

  • A = 3 appears only in R1, so include (3,7,NULL).

  • A = 4 appears only in R2, so include (4,NULL,9).

Therefore the full natural outer join R contains exactly (1,5,7), (3,7,NULL), and (4,NULL,9) — corresponding to e, f, and g. Tuples like (1,5,NULL) or (1,NULL,7) are not present because the A = 1 rows join into a single combined tuple; tuples that mix values from different A values (such as (3,NULL,9) or (4,7,NULL)) are incorrect.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir