retagged by
856 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.
retagged by

1 Answer

16 votes
16 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

608
views
3 answers
4 votes
GO Classes asked Jan 21
608 views
An attribute $A$ is called prime if $A$ is in any of the candidate keys. Assume in the following statements, $\mathrm{A}$ is an attribute $\&\;\mathcal{X}$ is a set of attributes ... , D - BCNF}$\text{A - BCNF, B - 3NF, C - 2NF, D - 1NF}$
823
views
0 answers
3 votes
GO Classes asked Jan 21
823 views
Assume that a data file has an index consisting of $\text{N}$ items, where $\text{N}$ is large. If a binary search of the index is used to find an item, then, of the ... $\text{N} \log _2 \text{N}$
938
views
2 answers
8 votes
GO Classes asked Jan 21
938 views
Consider the following partial schedule for several data items for transactions $T_i$ with timestamp $i:$ How many transactions are Aborted by the timestamp scheduler?
1.1k
views
1 answers
11 votes
GO Classes asked Jan 21
1,062 views
Consider the two statements regarding the Huffman's algorithm -$\text{S1:}$ The character with the highest probability (all probabilities are unique) is ... $\mathrm{S} 2$ is correctBoth are correct statementsBoth are incorrect statements