Consider the following ORACLE relations: One (x, y) = {<2, 5>, <1, 6>, <1, 6>, <1, 6>, <4, 8>, <4, 8>}
Consider the following ORACLE relations:
One (x, y) = {<2, 5>, <1, 6>, <1, 6>, <1, 6>, <4, 8>, <4, 8>}
Two (x, y) = {<2, 55>, <1, 1>, <4, 4>, <1, 6>, <4, 8>, <4, 8>}
Consider the following two SQL queries SQ1 and SQ2:
SQ1: (SELECT * FROM One)
EXCEPT
(SELECT * FROM Two);
SQ2: (SELECT * FROM One)
EXCEPT ALL
(SELECT * FROM Two);
For each of the SQL queries, what is the cardinality (number of rows) of the result obtained when applied to the instances above?
Show answerHide answer
Correct answer: (B) 1 and 2 respectively
Explanation
EXCEPT returns the records present in the first relation and absent in the second, eliminating duplicates: SQ1 gives the single tuple <2, 5>. EXCEPT ALL keeps duplicates, removing one occurrence per matching tuple: SQ2 gives <2, 5> and <1, 6> (2 tuples). So the cardinalities are 1 and 2.