Some while ago, I\'ve been reading through the book SQL and Relational Theory by C. J. Date. The author is well-known for criticising SQL\'s three-valued logic (3VL).
One option is to use explicit option types, analogous to Haskell's Maybe
functor.
Unfortunately a lot of existing SQL implementations have poor support for user-defined algebraic data types and even poorer support for user-defined type constructors that you really need to do this cleanly.
This recovers a sort of "null" for only those attributes where you explicitly ask for it, but without null
's silly three-valued logic. Nothing == Nothing
is True
, not unknown
or null
.
Support for user-defined algebraic types also helps when there are a few reasons for missing information, for example a database equivalent of the following Haskell type would be a good solution for the obvious application:
data EmploymentStatus = Employed EmployerID | Unemployed | Unknown
(Of course, a database supporting this would also need to support the more-complicated-than-usual foreign key constraint that comes with it.)
Short of this, I agree with APC's and onedaywhen's answers about 6NF.