Correct Answer - Option 1 : R
1 has no duplicates and R
2 is empty.
CONCEPT:
- SQL Relations are MULTISET, not SET. So, R1 or R2 can have duplicated.
- If S is empty, then R1 × R2 = empty and hence it will not equal R
- If R1 has duplicates, in that case, due to distinct keywords those duplicates will be eliminated in the final result and SQL query will not be equal to R1. So, R1 cannot have duplicates.
EXPLANATION:
Option 1: R1 has no duplicates and R2 is non-empty
This is true:
Option 2: R and S has same number of tuples
Since R1 can be duplicate it is false
Option 3: R1 and R2 have no duplicates
Since S can be empty ∴ R × S = 0 it is false
Option 4: R2 has no duplicates and R1 is non-empty
Since R can be duplicate it is false
Example:
R1(x, y)
R2(A, B)
R1 × R2:
A
|
B
|
C
|
D
|
1
|
2
|
3
|
4
|
1
|
2
|
5
|
2
|
1
|
2
|
3
|
4
|
1
|
2
|
5
|
2
|
SELECT DISTINCT w, x from R, S
Output:
This proves option 2, 3 and 4 an incorrect statement