Comment

Comment by int_19h

The problem is that semantics of NULL in SQL are not that of "unknown". Well, they are in most cases, but there are also many when it's not true - e.g. SUM().

Even if they were, it's just a horrible name for the concept. You could argue that back when the keyword was introduced into SQL, it didn't yet have a well-established meaning that was different... but I'm not even sure that is true - some form of NIL or NULL has been around since the early Algol extensions, and it never meant "unknown".

The way to fix it would be to have MISSING and UNKNOWN as two different concepts. Then:

   UNKNOWN + 1 -> UNKNOWN
   MISSING + 1 -> *error*

   TRUE AND UNKNOWN -> UNKNOWN
   TRUE AND MISSING -> *error*

   UNKNOWN = UNKNOWN -> UNKNOWN
   MISSING = MISSING -> TRUE
Well, and fix the aggregates - e.g. SUM() of no values should just be 0.
parent int_19h 6 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton