3 ms·
> The relational null represents the absence of a value in a field of a record; whereas the programming language null represents one of the possible values of a
by ken 6y ago
> The relational null represents the absence of a value in a field of a record; whereas the programming language null represents one of the possible values of a variable.
This sounds like splitting hairs, especially as they never seem to explicitly define what "value" means. How is it not a value? It sure looks like a "value" to me.
It's not just the occasional textbook that uses this nomenclature. In SQL itself, you type "INSERT INTO mytable VALUES (NULL);" to insert a NULL. Did the designers of SQL not understand what "value" means?
They also claim that databases are special in that they use "three-valued logic" -- which would seem to imply that NULL is a third value. Does "value" have different meanings in different contexts? For the word whose precise definition is central to their thesis, it has some remarkable linguistic flexibility.
> Here is a partial list of the reasons why NULL can occur. 1. The field has a value but it isn't known... 2. The field has no value because it isn't applicable...
These are all reasons I've seen people use null in programming languages, too.
> The field is not allowed to have a value. For example, the root node of a tree has no parent node. The fact that the field is NULL in this case is not due to missing information.
Are they really trying to claim this is somehow unique to relational databases? Trees work exactly the same way in programming languages.
- nerdponx 6y agoI think I understand what they're trying to say. The value of a variable with type "non-nullable 32-bit integer" is an element of the space {-231, ..., 231 - 1}. The value of a variable with type "nullable 32-bit integer" is an element of the space {-231, ..., 2*31 - 1} U {NULL}. There's a "main space", and an extra singleton space tacked on, containing the "NULL" element. So NULL isn't a value in the "main space", and therefore in some sense "isn't a value". I think it's wrong for the same reasons you stated, but I think this is what they were trying to describe.