Wikipedia says NULL is for representing “missing information and inapplicable information”.
I have always underestood NULL to be appropriate to represent “Unknown” information, as in the field is applicable to the record, it is just an unknown value.
Given the problems that NULL introduces to queries (3-point logic and tons of exceptions that have to be accounted for) should NULL still be used in records for fields that are not applicable to a record? Or should it just be used for applicable fields whose values are unknown for a given record?
I too accept
nullto mean “unknown”, but “inapplicable” fits for example when saving the CEO’s employee record, we setemployee_manager_id = nullbecause the CEO has no manager.One technique to avoid the hassle of nulls is to use a special value instead, for example saving
-1for an person.age, but then you have a bit more complexity checking this value. When using a special value for a foreign key (as in the manager id example), you actually have to create a dummy record with id = 0 for example, and this may introduce problems when processing “all employees” – you must skip the dummy record.Personally, I think things stay cleaner just using null and suffering the hassle of more complex SQL – at least everyone knows what’s going on.