EXPLAIN EXTENDED

How to create fast database queries

NULL in SQL: explaining its behavior

with one comment

On my blog feedback page I get lots of questions which essentially boil down to one thing: "Those NULL things in databases work in a way I don't freaking get!"

Let's have them explained a little.

The Wikipedia page defines NULL this way:

Introduced by the creator of the relational database model, E. F. Codd, SQL Null serves to fulfill the requirement that all true relational database management systems (RDBMS) support a representation of "missing information and inapplicable information".

For people new to the subject, a good way to remember what null means is to remember that in terms of information, "lack of a value" is not the same thing as "a value of zero"; similarly, "lack of an answer" is not the same thing as "yes" or "no".

Rather than trying to come up with intuitive rules for how NULL behaves, it's easier to expand on the definition above to demonstrate the motivation behind introducing the NULL at all, and why it ended up so complex.

NULL is like an "unknown variable" in algebraic equation

Let's step away from relations and tables for a moment, and remember some old school math. What is this?

Read the rest of this entry on tech.pro »

Written by Quassnoi

September 27th, 2013 at 11:00 pm

Posted in Miscellaneous

One Response to 'NULL in SQL: explaining its behavior'

Subscribe to comments with RSS

  1. Null is like a void in the universe. So beautiful =D

    Heavyrick

    7 Jan 14 at 15:38

Leave a Reply