in Databases edited by
16,296 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
in Databases edited by
16.3k views

4 Comments

@Deepak Poonia Sir how can we consider duplicates because we cannot have duplicates in relation . I know that in SQL we can have duplicates but for table r and s it only menionted in the question that they are tables so how can we consider them to be SQL relations ??

0
0
edited by
The given query is SQL query. So, Why would you treat it as RDBMS Model?
1
1
in given question result always different tuple  show in relation r has no duplicate this is the key point of the question
0
0

4 Answers

87 votes
87 votes
Best answer

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

4 Comments

yes
0
0
Hello to all

What if in place of option a) statement, this is written "R is empty"

Then also correct option is a)

Am I correct?
0
0
Doesn’t the Definition of Candidate Key itself disallow 2 Tuples to Be Same?

I mean if a Relation Has No Proper Subset of Attributes as  Candidate Key, it will have All attributes combined as Candidate Key and so , 2 tuples can’t be same i guess.
0
0
15 votes
15 votes
(a)

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

4 Comments

@Arjun Suresh: Agree with you. r has no duplicates doesn't make sense here.
0
0
@Arjun, This questions is about SQL. In SQL we allow relations to have duplicates. Check my answer here !
9
9
edited by

yes In SQL, relation can have duplicate tuples

Relation

           A           B
          1           2
          4           9
          1           2

the above relation, it is valid in SQL but not in Relational Algebra.

12
12
1 vote
1 vote

 

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