Module 52: Database Structure

Lesson 5 of 5 · 15–25 minutes

NULL and missing information

🏠The everyday picture

A form with a box left blank. Does blank mean "no", "not asked yet", "unknown" or "not applicable"? A blank box can mean many things, so good forms are clear about which.

📘What it really is

🖱️Try it

Add a nullable email to customers (not everyone gives one) and a NOT NULL phone. Insert customers with and without email. Run SELECT COUNT(*), COUNT(email) FROM customers; and SELECT * FROM customers WHERE email = NULL; (returns nothing) versus WHERE email IS NULL.

✅Quick check

Why does WHERE email = NULL find nothing?

Show the answer

NULL isn't equal to anything, even NULL; use IS NULL.

Why not store "no email" as the text 'N/A'?

Show the answer

It looks like a real value, gets counted and may even be emailed; NULL clearly means missing.

← PreviousConstraints
ProLearners Assist