UGC-NET Nov 2017 · SQL Queries

MCQ · 2 marks · Problem DBMS-SQL-0020

Given two relations $R_1(A,B)$ and $R_2(C,D)$, the result of following querySelect distinct A, B From R1, R2 Is guaranteed to be same as R1 provided one of the following condition is satisfied.
  1. A
    $R_1$ has no duplicates and $R_2$ is empty.
  2. B
    $R_1$ has no duplicates and $R_2$ is non-empty.
  3. C
    Both $R_1$ and $R_2$ have no duplicates.
  4. D
    $R_2$ has no duplicates and $R_1$ is non – empty.

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

Show the worked solutionFROM R1, R2 forms \(R_1\times R_2\). Each \(R_1\) row appears \(|R_2|\) times, and DISTINCT A, B collapses those copies. If \(R_2\) is empty, the product is empty and the result is empty, not \(R_1\). So \(R_2\) must be non-empty. DISTINCT also removes any duplicates within \(R_1\), so \(R_1\) must have none for the result to equal it.(A) With \(R_2\) empty the result is empty — incorrect.(C) and (D) do not guarantee that \(R_2\) is non-empty or that \(R_1\) has no duplicates — incorrect.Answer: B

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