0 to 1

NULL vs Empty String: Why "No Data" Isn't Always the Same Thing

If you've worked with databases for more than a week, you've probably hit this moment: a text field has no data, and you have to decide: do I leave it NULL, or do I set it to an empty string ''? It looks like a trivial choice. It isn't. Pick wrong (or pick inconsistently) and you'll spend years explaining weird bugs in your reports.

Let's break down what each one actually means, why most well-designed systems lean toward NULL, and where empty strings sneak in anyway.

First, What Are We Even Comparing?

NULL means "unknown" or "not applicable." It's the database's way of saying we don't have this information, not "we checked and there's nothing there."

Empty string ('') means "this value is known, and it happens to be zero characters long." That's a real, defined value; it's just an empty one.

These sound similar in casual conversation but they are semantically different claims about the world. NULL is an absence of a fact. '' is a fact that happens to be blank.

Example: think about a MiddleName column.

Most systems can't actually tell these two situations apart, which is exactly the problem.

Why NULL Is Usually the Better Default

1. It's honest about missing data

If a field is NULL, anyone querying it knows immediately: this information isn't here. An empty string implies someone already resolved the question and the answer was "nothing," which is rarely true in practice. Most of the time an empty string in a LastName field doesn't mean the person has no last name; it means a form was submitted without one, or a script defaulted to '' instead of leaving the field untouched.

2. Aggregate functions behave the way you'd expect

SELECT COUNT(LastName) FROM users;

COUNT() ignores NULL values automatically. So this query tells you how many users have a recorded last name. If those missing values were empty strings instead, they'd get counted too, and your "how many records have this field filled in" number would just be wrong.

3. Filtering is cleaner

With NULL, you write:

WHERE LastName IS NULL

Clean, explicit, and every SQL engine agrees on what this means.

With empty strings, people often forget to handle both cases and end up needing:

WHERE LastName IS NULL OR LastName = ''

or worse, they only check LastName = '' and silently miss all the actual NULL rows. This is a very common, very quiet bug: it doesn't throw an error, it just returns incomplete results.

4. Storage and indexing

Most database engines store NULL more efficiently than an empty string. A NULL is typically just a flag bit, with no string overhead at all. Indexes also tend to handle NULL more predictably than a bunch of empty strings that all "look the same" but technically aren't nothing.

5. Tools expect NULL, not blank strings

Reporting tools, BI dashboards (Power BI, Tableau, Looker), and most ORMs have built-in handling for missing data, and that handling is built around NULL. Feed those tools an empty string instead, and you'll often get a mystery category like a blank slice in a pie chart, or a "missing" group that doesn't get filtered out the way you'd expect.

So Why Do Empty Strings Show Up Everywhere Anyway?

If NULL is clearly the better default, why do so many production systems end up full of empty strings? A few very common reasons:

The Practical Takeaway

At the end of the day, this isn't really a database trivia question; it's a data modeling question. NULL and '' are answering two different questions ("do we know?" vs. "do we know, and it's nothing"), and most of the time, the question you're actually trying to answer is the first one.