• edited by
26,004 views
83 83 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

5 Answers

Best answer
110 110 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
16 16 votes
(a)

if s is empty r x s will give empty set, so s cant be empty
3 3 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
1 1 vote
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:
Position:
Show:

Related questions

51 51 votes
8 answers 8 answers
18.0k
18.0k views
Kathleen asked Sep 14, 2014
17,997 views
A multiset is an unordered collection of elements where elements may repeat any number of times. The size of a multiset is the number of elements in it, counting repetiti...
89 89 votes
9 answers 9 answers
28.9k
28.9k views
Kathleen asked Sep 14, 2014
28,938 views
In SQL, relations can contain null values, and comparisons with null values are treated as unknown. Suppose all comparisons with a null value are treated as false. Which ...
14 14 votes
2 2 answers
4.4k
4.4k views
Kathleen asked Sep 14, 2014
4,446 views
Consider a bank database with only one relation transaction (transno, acctno, date, amount)The amount attribute value is positive for deposits and negative for withdrawa...
59 59 votes
9 answers 9 answers
49.0k
49.0k views
Kathleen asked Sep 14, 2014
49,034 views
The number of tokens in the following C statement isprintf("i=%d, &i=%x", i, &i);$3$$26$$10$$21$