Question 63Asked in UGC NET Computer Science, August 2016 (Paper II & III, Selected Questions)

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?
  1. A2 and 1 respectively
  2. B1 and 2 respectively
  3. C2 and 2 respectively
  4. D1 and 1 respectively
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.

From UGC NET Computer Science PYQ, August 2016 (Paper II & III, Selected Questions)

This is question 63 of UGC NET Computer Science PYQ, August 2016 (Paper II & III, Selected Questions). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.