Consider the following relations X(S, Si, C) and Y(S, P, D) . Which of the…

2023

 Consider the following relations X(S, Si, C) and Y(S, P, D) .

Which of the following join is used to get all the tuples of relation X and Y with Null values of corresponding missing values ?

Answer: D. Full outer joinAnswer: Full outer join Explanation: A full outer join returns all rows from both relations and fills NULL for attributes from the other relation when no…

  1. A.

    Left outer join

  2. B.

    Right outer join

  3. C.

    Natural join

  4. D.

    Full outer join

Attempted by 456 students.

Show answer & explanation

Correct answer: D

Answer: Full outer join

Explanation: A full outer join returns all rows from both relations and fills NULL for attributes from the other relation when no matching tuple exists.

  • Join key: the common attribute S is used to match tuples.

  • Tuples present only in relation X will appear with NULLs for the attributes from relation Y (P, D).

  • Tuples present only in relation Y will appear with NULLs for the attributes from relation X (Si, C).

  • Tuples present in both relations will include values from both sides.

Resulting rows (S, Si, C, P, D):

  1. S = J: Si = 1, C = M, P = S1, D = CA

  2. S = B: Si = 2, C = N, P = P1, D = AB

  3. S = R: Si = 3, C = H, P = D1, D = DC

  4. S = T: Si = 4, C = G, P = NULL, D = NULL

  5. S = A: Si = NULL, C = NULL, P = H1, D = MD

Why other joins do not satisfy the requirement: a join that returns only rows from the left relation misses tuples present only in the right; a join that returns only rows from the right misses tuples present only in the left; a natural/inner join returns only matching tuples and excludes non-matching ones.

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

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…