There exists a construct which returns a value 'true' if the argument subquery…

2009

There exists a construct which returns a value 'true' if the argument subquery is:

  1. A.

    empty

  2. B.

    non-empty

  3. C.

    in error

  4. D.

    none of the other three options

Show answer & explanation

Correct answer: B

The SQL EXISTS construct is a Boolean test applied to a subquery. Its truth value depends strictly on the row-count membership of the subquery's result set -- whether the result set contains any rows at all -- and never on the content of any specific row. By the standard SQL definition: EXISTS(subquery) evaluates to true precisely when the subquery's result set is non-empty (contains one or more rows); it evaluates to false when the result set is empty (contains zero rows).

Applying this definition to the question: it asks for the condition on the argument subquery under which the construct returns the value 'true'. Per the definition above, that condition is that the subquery's result be non-empty -- the subquery must return at least one row for EXISTS to evaluate to true.

An independent check follows from the construct's logical negation, NOT EXISTS. NOT EXISTS(subquery) is true precisely when the subquery's result is empty. Since EXISTS and NOT EXISTS between them must cover the two possible row-count states of a subquery exactly once, and NOT EXISTS covers the 'empty' state, EXISTS itself must cover the remaining 'non-empty' state -- confirming the same conclusion from the opposite direction.

  • 'Empty' names the row-count state under which EXISTS evaluates to false (the complement of the condition asked about), not the state under which it returns true.

  • 'Non-empty' is exactly the row-count state under which EXISTS evaluates to true, as derived above -- the subquery must return one or more rows.

  • 'In error' names a subquery whose execution failed outright; the EXISTS definition applies only to the row count of a subquery that executed successfully, so an execution-failure state falls outside that definition entirely.

  • 'None of the other three options' would hold only if the true condition matched none of the three listed states -- but 'non-empty' is exactly the condition given in the standard SQL definition of EXISTS, so this option does not apply.

Hence, the EXISTS construct returns the value 'true' exactly when the argument subquery is non-empty.

Explore the full course: Nta Ugc Net Paper 2

Loading lesson…