11,206 views

In SQL, relations can contain null values, and comparisons with null values are treated as unknown. Suppose all comparisons with a null value are treated as false. Which of the following pairs is not equivalent?

1. $x = 5 \quad not (not (x = 5))$
2. $x = 5 \quad x > 4$ and $x < 6,$ where $x$ is an integer
3. $x ≠ 5 \quad not (x = 5)$
4. none of the above

put x=NULL & check which one is equivalent
NOTE :-  $x=5$ and $x\neq 5$ both will return false.
finally I have understood this question !!!

### Subscribe to GO Classes for GATE CSE 2022

Answer is option C.
$${\begin{array}{|c|cc|cc|cc|}\hline\\ \textbf{Value at hand}& \textbf{Option A}& & \textbf{Option B}& &\textbf{Option C} \\\hline 6 & \times & \times & \times & \times & \checkmark & \checkmark \\ \hline 5 & \checkmark & \checkmark & \checkmark & \checkmark &\times & \times \\ \hline \text{NULL}& \times & \times & \times & \times &\color{blue} \times & \color{blue}\checkmark \\ \hline \end{array}}$$

@amarVashishth can oyu please explain me the options given, Like i am not able relate between null and x=5. Where does comparision with null comes in picture?

@Aayushi, I am trying to explain option c.

Suppose all comparisons with a null value are treated as false.

now see, LHS = x !=5,  lets take x=null, => (null) !=5                  => false.

RHS = not( x = 5) ,  => not ( null = 5)    =>> not (false) =>> true.

Now check above solution for other options..

Can u explain about all options and their correctness, means how are they correct
Suppose x=NULL

a) NULL=5 is false ; Not(Not(NULL=5)  => Not(Not(False))  => Not(true)   =>  false...so they are equivalent.

b) NULL=6 is false ; NULL> 4 and NULL<6 is also false so they  are also equivalent.
Just to add a point:

Comparison with NULL value are in general unknown.
But here we are treating it to be false.

Does anyone observe this statement comparisons with null values are treated as unknown.

And how you are concluding NULL != 5 as False.

As (null) != 5 gives false.
But, not((null) = 5) gives not(false) gives true.
by

option (b)
NULL=5   False
x>4 and x<6 where x is an integer
Please explain how this evaluates to false
in all the options, will be evaluating the pair of equations with same value of x(whether it is null or an integer) in option 'b' x is always an integer, so whatever value of x u put both x=5 and x>4 and x<6 will always give the same answer
Yes. THANKS
a.null = 5   => false ,

not(not(null=5))  = not(not(false)) = not(true) = false

b. null = 5 => false ,

null>4 and null <6 = False and false = false

c.null ≠ 5 => false

not(null= 5)= not (false) = true

∴ option C is not eqivivalent

According to given question, comparison with NULL value always False, so “x ≠ 5” will be false. “x = 5” will also false and not (x = 5) = not(false) = true.
Hence, these are not equivalent pair.

ans-C