Given relations R(w,x) and S(y,z), the result of SELECT DISTINCT w, x FROM R,…
20182003
Given relations R(w,x) and S(y,z), the result of
SELECT DISTINCT w, x
FROM R, S
Is guaranteed to be same as R, if
- A.
R has no duplicates and S is non-empty
- B.
R and S have no duplicates
- C.
S has no duplicates and R is non-empty
- D.
R and S have the same number of tuples
Attempted by 1023 students.
Show answer & explanation
Correct answer: A
FROM R, Screates a Cartesian product of R and S.For each tuple of R, it gets repeated once for every tuple in S.
SELECT DISTINCT w, xremoves duplicates from the final result.
Now, the result will be exactly same as R only if:
R has no duplicates
→ OtherwiseDISTINCTmay remove tuples.S is non-empty
→ If S is empty, Cartesian product is empty → result ≠ R.
The number of tuples in S doesn’t matter as long as S is non-empty, because DISTINCT collapses repetitions back to R.
A video solution is available for this question — log in and enroll to watch it.