edited by
16,204 views
57 votes
57 votes

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, provided.

  1. r has no duplicates and s is non-empty
  2. r and s have no duplicates
  3. s has no duplicates and r is non-empty
  4. r and s have the same number of tuples
edited by

4 Answers

Best answer
87 votes
87 votes

This question is about SQL, in SQL Relations are MULTISET, not SET. So, $R$ or $S$ can have duplicated.

Answer: A.

A. If $R$ has duplicates, in that case, due to distinct keyword those duplicates will be eliminated in final result. So, $R$ can not have duplicates. If $S$ is empty $RXS$ becomes empty, so $S$ must be non empty. This is true.

B. Here, assume that S is empty. (No duplicates.) Then R X S will be empty. SO this is false.

C. Same argument as B.

D. Assume that $R$ has duplicates. Then Distinct keyword will remove duplicates. So, result of query $!= R$, so This is false.

edited by
15 votes
15 votes
(a)

if s is empty r x s will give empty set, so s cant be empty
1 votes
1 votes

 

Option A would have been correct if the only condition was on S that S should be non empty

Even if R has duplicates, it will exexute correctly

 

 

  1. S is empty
  2. S is non empty
0 votes
0 votes
r has no duplicate and s is not empty then rXs will  will be non empty and using select distinct w,x  we will gwt r as r has no dublicate

so here we have to think about 2 important things

first is s should not be empty as then rXs will be empty

second is r should not contain duplicate as in ans we are using distinct keyword!!

so option a is correct.
Answer:

Related questions

30 votes
30 votes
5 answers
3
Kathleen asked Sep 14, 2014
14,524 views
Given the following relation instance.$$\begin{array}{|l|l|}\hline \text{X} & \text{Y} & \text{Z} \\\hline \text{1} & \text{4} & \text{2} \\ \text{1} & \text{5} & \te...
41 votes
41 votes
7 answers
4
Kathleen asked Sep 14, 2014
36,386 views
The number of tokens in the following C statement isprintf("i=%d, &i=%x", i, &i);$3$$26$$10$$21$