Redirected
recategorized by
1,243 views
1 votes
1 votes

Given two relations $R_1(A,B)$ and $R_2(C,D)$, the result of following query

Select distinct A, B  
From R1, R2

Is guaranteed to be same as R1 provided one of the following condition is satisfied.

  1. $R_1$ has no duplicates and $R_2$ is empty.
  2. $R_1$ has no duplicates and $R_2$ is non-empty.
  3. Both $R_1$ and $R_2$ have no duplicates.
  4. $R_2$ has no duplicates and $R_1$ is non – empty.
recategorized by

2 Answers

2 votes
2 votes
  1. R1 has no duplicates and R2 is empty. ( If R2 is empty and we select distinct A,B from R1,R2 ,then cartesian product would result in zero tuples)
  2. R2 has no duplicates and R1 is empty (If R1 is empty, then by no means the query will getch any content from R1)
  3. Both R1 and R2 have no duplicates. (This will fetch distinct columns from R2 containing null values)
  4. R2 has no duplicates and R1 is non empty. ( Correct Answer : The query selects all attributes of R1 Since we have distinct in query, result can be equal to R1 only if R1 doesn’t have duplicates.)
0 votes
0 votes

Select A,B
From R1, R2 :
In this query first we will take cartesian product of R1, R2 (R2 must be non empty)for this 0- R2 then select distinct A,B from Cartesian product of R1, R2 (for A,B being distinct there should not any duplicate A,B).
And
Select A,B
From R2
For this query A,B → No duplicate A,B.
By combining condition for both query we will get the right condition.
So, option (B) is correct. 

Answer:

Related questions