GATE / CS ARCHIVE

GATE CSE 2000 / QUESTION 2.26

Replacing SQL unknown comparisons with false

Database Management Systems · SQL & Queries · Full GATE CSE 2000 paper

GATE 2000, Q2.26 2 marks · MCQ
Report issue

SQL & Queries

Question 2.26, GATE 2000: Suppose every comparison involving NULL returns FALSE rather than UNKNOWN. Which pair ceases to be equivalent: x=5 versus NOT NOT(x=5); x=5 versus x>4 AND x<6 for integer x; x≠5 versus NOT(x=5); or none?
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step 1: For an ordinary nonnull x, inequality x≠5 agrees with negated equality. But at x=NULL, the stipulated direct comparison x≠5 is FALSE, while x=5 is FALSE and its negation is TRUE. Thus C differs.

Step 2: Double negation still restores the original Boolean value, so A remains equivalent. In B, both comparisons on NULL are FALSE, making the conjunction FALSE just like equality; for nonnull integers the open interval(4,6) contains only 5.

Therefore only C among these pairs exposes the inconsistency. Standard SQL uses UNKNOWN precisely to avoid treating a negated unknown comparison as true.

Original paper, page 6