Suppose ORACLE relation 𝑅(𝐴,𝐵) currently has tuples {(1,2),(1,3),(3,4)} and…

2015

Suppose ORACLE relation 𝑅(𝐴,𝐵) currently has tuples {(1,2),(1,3),(3,4)} and relation 𝑆(𝐵,𝐶) currently has {(2,5),(4,6),(7,8)}.Consider the following two SQL queries SQ1 and SQ2:

SQ1:   Select *

From R Full Join S

On R.B=S.B;

SQ2:   Select *

From R Inner Join S

On R.B=S.B;

The numbers of tuples in the result of the SQL query SQ1 and the SQL query SQ2 are given by:

  1. A.

    2 and 6 respectively

  2. B.

    6 and 2 respectively

  3. C.

    2 and 4 respectively

  4. D.

    4 and 2 respectively

Attempted by 445 students.

Show answer & explanation

Correct answer: D

Given: R has tuples (1,2), (1,3), (3,4).

S has tuples (2,5), (4,6), (7,8).

Matches on column B:

  • B = 2 gives the joined row (1,2,5).

  • B = 4 gives the joined row (3,4,6).

Unmatched rows that appear only in one relation:

  • From R: (1,3) has no matching B in S, so it appears as (1,3,NULL) in the full join.

  • From S: (7,8) has no matching B in R, so it appears as (NULL,7,8) in the full join.

Counts:

Full join result has 4 tuples (2 matched + 1 unmatched from R + 1 unmatched from S).

Inner join result has 2 tuples (the two matched rows).

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

Explore the full course: Mppsc Assistant Professor