Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
485 views
in Programming by (114k points)
closed by

Given two relations R1(A, B) and R2(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. R1 has no duplicates and R2 is empty.
2. R1 has no duplicates and R2 is non-empty.
3. Both R1 and R2 have no duplicates. 
4. R2 has no duplicates and R1 is non - empty

1 Answer

0 votes
by (113k points)
selected by
 
Best answer
Correct Answer - Option 1 : R1 has no duplicates and R2 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)

A

B

1

2

1

2

 

R2(A, B)

y

z

3

4

5

2

 

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:

w

x

1

2

 

This proves option 2, 3 and 4 an incorrect statement

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...