in Databases retagged by
703 views
12 votes
12 votes

Let $\mathrm{R}(\mathrm{a}, \mathrm{b})$ be a schema and $\mathrm{Q} 1$ and $\mathrm{Q} 2$ are queries on $\mathrm{R}$.

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

Which of the following statements is true?

  1. $\text{Q1}$ and $\text{Q2}$ produce the same answer.
  2. The answer to $\text{Q1}$ is always contained in the answer to $\text{Q2}.$
  3. The answer to $\text{Q2}$ is always contained in the answer to $\text{Q1}.$
  4. $\text{Q1}$ and $\text{Q2}$ produce different answers.
in Databases retagged by
703 views

5 Comments

I;ve made the mistake by just forgetting the basic concept of set operation which makes removal of duplicate rows.i.e. intersection is a set operation .so duplicate rows are removed .And that’s the reason why Q1 covers all the rows of Q2.
1
1
when can we expect aimt 3 video solutions?
0
0

@Srken Does R(a,b) itself indicates that it is in 1NF right? So there will not be duplicates tuples in R(a,b)??

0
0
yeah but SQL tables can have duplicate tuples and they can be printed
0
0

$ \large{\colorbox{yellow}{Detailed video solution of this question with direct time stamp}}$
All India Mock Test 3 - Solutions Part 2

0
0

1 Answer

15 votes
15 votes
The intersection is a set operation and set doesnt contain duplicate values. $\text{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 $\text{Q2}$ duplicate rows are printed only once i.e there will be no repetition. $\text{Q2} \leq \text{Q1}$ and hence result of $\text{Q2}$ will always be contained in $\text{Q1}$.

If it would have been INTERSECT ALL then the answer would have been (A).
edited by
Answer:

Related questions