in Databases retagged by
699 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
699 views

4 Comments

@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