Let's say you have an application that has a boolean field in its User
table called Inactive
.
Is there anything inherently wrong with just storing false as null? If so can you please explain what the down side should be? I have discussed this with someone a few months ago and we both agreed it shouldn't matter as long as you do it consistently throughout the app/database. Recently, someone I know was emphatic that "true" true
or false
should be used, but they didn't really give an explanation as to why.
Best Answer
Yes.
NULL is not the same as False.
By definition, comparisons (and logic) that involve NULL should return values of NULL (not False). However, SQL implementations can vary.
True and NULL
is NULL (not False).True and NULL or False
is NULL (not False).http://en.wikipedia.org/wiki/Null_(SQL)#Three-valued_logic_.283VL.29
http://technet.microsoft.com/en-us/library/cc966426.aspx