Empty Strings Aren’t Better Than NULLs

Scene


Prove me wrong.



23 thoughts on “Empty Strings Aren’t Better Than NULLs

  1. Empty strings are storage vendors friends. It’s all about perspective.

    What did I win?

  2. What about ‘NULL’ as a string? That seems like a nice compromise. That way everybody knows what’s going on.

  3. I teach this during t-sql fundamentals, when I compare INTERSECT vs INNER JOIN (two-value logic vs three-value logic).
    You cannot INNER JOIN a NULL-able column that contains, well, NULLs, whereas INTERSECT couldn’t care less about your NULLs (two value logic). Let me rephrase that, you can INNER JOIN, it’s just a terrible idea, that’s all.
    So, by using an empty string instead of NULL you can go old school with JOINs. Like 99,9% of the general population – you know, the ones telling you how cool NoSQL is.

  4. Consider the case of the non-null column where stupid humans, errr,,, ummm… “people” use NULL and Empty strings to mean the same thing.

    Then when they want to find things that don’t have a value, they end up with criteria that looks like one of the following:
    WHERE (SomeColumn IS NULL or SomeColumn = ”)
    WHERE ISNULL(SomeColumn,”) = ”

    In this case, empty strings in a non-null column are much better than having NULLs in the column.

    Do I get to say that I proved you wrong (which would be an extreme rarity by anyone and then only because someone has to do something wrong for you to be wrong)? 😀

  5. p.s. And I agree with Calin… his post is another place where empty strings are better than NULLs but for the same reason.

    Heh… Empty Strings Rock!

      1. I mean, I agree with you.
        I use NULL in my projects (SQL Server and PostgreSQL) and we work well together. NULL has saved my skin many times when some (user or developer) going bullshits.
        It’s probably a matter of habit.
        🙂

Comments are closed.