UGC-NET Dec 2015 · SQL Queries

MCQ · 2 marks · Problem DBMS-SQL-0013

Suppose ORACLE relation \(R(A,B)\) currently has tuples \(\{(1,2), (1,3), (3,4)\}\) and relation \(S(B,C)\) 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

Solve it on GATE DA practice →More Relational Model & SQL problems

Show the worked solution\[\boxed{|\text{full join}| = |\text{inner join}| + \text{unmatched } R + \text{unmatched } S}\]Inner join on \(R.B=S.B\): \((1,2,2,5)\) and \((3,4,4,6)\), so SQ2 gives 2 tuples.Unmatched: \((1,3)\) of \(R\) (padded with NULLs) and \((7,8)\) of \(S\). SQ1 gives \(2+1+1=4\) tuples.So 4 and 2. The official UGC NET key was (B), which treats the full join as a Cartesian product.Answer: D

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com