I think the correct solution for null
(which has its own problems in SQL – see Errors considered harmful - #102 by peter.ludemann) is to do something like Haskell’s Maybe = Just a | Nothing
… that is, a non-defaulty representation. (In Prolog, this would be just(X)
and nothing
, for example, which can always be distinguished.)
Although, when designing a database, it’s often possible to avoid null
completely – with specifying not null
for a column when creating a table in SQL, and specifying a suitable default value for strings (typically a zero-length string).