• retagged by
2,867 views
4 4 votes
Let R(a,b) be a schema and Q1 and Q2 are queries on R.

Q1: SELECT * FROM R;

Q2: (SELECT * FROM R) INTERSECT (SELECT * FROM R);

Which of the following statements is true?

(A) Q1 and Q2 produce the same answer.

(B) The answer to Q1 is always contained in the answer to Q2.

(C) The answer to Q2 is always contained in the answer to Q1.

(D) Q1 and Q2 produce different answers.

ans = C given

please explain the logic behind

3 Answers

3 3 votes
Intersection is a set operation and set doesnt contain duplicate values. Q1 will print all the rows including those which are duplicates i.e there may be some rows in its output that might be repeated. In Q2 duplicate rows are printed only once i.e there will be no repeatition. |Q2|<=|Q1| and hence result of Q2 will always be contained in Q1.

If instead of 'Intersect' we have used 'Intersect All' then duplicacy will be allowed and Q1 and Q2 will produce same result.
1 1 vote
when your are using the intersection operator duplicates are removed so...

simply the first query gives u all the rows including duplicates

second query gives u all the rows from R without duplicates hence c is the answer
Position:
Show:

Related questions

6 6 votes
1 1 answer
1.6k
1.6k views
indrajeet asked Sep 22, 2016
1,632 views
Consider the following table MysteryMysteryAB1Null2435Null6select count() from Mysterywhere A not in( select B from Mystery)(A) 1(B) 0(C) 4(D) 3ans is B givenplease expla...
0 0 votes
0 0 answers
1.0k
1.0k views
Beyonder asked Nov 30, 2016
1,044 views
Can Anyone Explain how Query 28 works with example.
0 0 votes
1 1 answer
1.8k
1.8k views
aditya kuppa 1 asked Dec 5, 2017
1,820 views
How many minimum tables are required for this er diagram consisting of a many - many relation and total participation of one of the entities.? Can't i merge relation R an...
2 2 votes
2 2 answers
4.5k
4.5k views
indrajeet asked Sep 23, 2016
4,539 views
Consider the following entity relation diagramIf A has 50 entities,B has 20 entities and C has 200 entities. what is the maximum number of triples of entities that could ...