Question

Consider two relations R1(A,B)R_1(A, B) with the tuples (1,5),(3,7)(1, 5), (3, 7) and R2(A,C)R_2(A, C) with (1,7),(4,9)(1, 7), (4, 9). Assume that R(A,B,C)R(A, B, C) is the full natural outer join of R1R_1 and R2R_2. Consider the following tuples of the form (A,B,C)(A, B, C):

a=(1,5,null),b=(1,null,7),c=(3,null,9),a = (1, 5, \text{null}),\quad b = (1, \text{null}, 7),\quad c = (3, \text{null}, 9),
d=(4,7,null),e=(1,5,7),f=(3,7,null),g=(4,null,9).d = (4, 7, \text{null}),\quad e = (1, 5, 7),\quad f = (3, 7, \text{null}),\quad g = (4, \text{null}, 9).

Which one of the following statements is correct?

Choose one option
Official answer and solution
Official answer
C
From
Official GATE 2015 answer key

Solution

Construct the full natural outer join of R1(A,B)R_1(A, B) and R2(A,C)R_2(A, C) on common attribute AA.

Relations given:

  • R1(A,B)={(1,5),(3,7)}R_1(A, B) = \{(1, 5), (3, 7)\}
  • R2(A,C)={(1,7),(4,9)}R_2(A, C) = \{(1, 7), (4, 9)\}

The full natural outer join R(A,B,C)=R1  FULL OUTER JOIN  R2R(A, B, C) = R_1 \;\text{FULL OUTER JOIN}\; R_2 includes:

  1. Natural inner join tuples on matching AA values:
    • A=1A = 1: tuple (1,5,7)(1, 5, 7) (this is tuple ee).
  2. Tuples from R1R_1 with no matching AA in R2R_2, padded with null for attribute CC:
    • A=3A = 3: tuple (3,7,null)(3, 7, \text{null}) (this is tuple ff).
  3. Tuples from R2R_2 with no matching AA in R1R_1, padded with null for attribute BB:
    • A=4A = 4: tuple (4,null,9)(4, \text{null}, 9) (this is tuple gg).

The full outer join relation RR consists of exactly {e,f,g}\{e, f, g\}. It does not contain tuples a=(1,5,null)a = (1, 5, \text{null}) or b=(1,null,7)b = (1, \text{null}, 7) because A=1A = 1 matched and formed the combined tuple ee.

Hence, 'R contains e,f,ge, f, g but not a,ba, b' (option C).

Final answer

C

Common trap

Assuming full outer join retains the null-padded versions of successfully matched tuples aa and bb.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2015 Computer Science and Information Technology (CS) Session 2
Question
42 of 65, printed as CS Q.32
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.