A database does not return null
. A method from any library you are using can return null
and you can store this value in a variable. Not all languages allow this, but I understand you’re talking about one that allows it. Not all libraries use this way of indicating that nothing was possible to return from the database. This is a error code.
The question starts from a false premise that a value and a state are distinct things. In fact the value is the state of the variable at that time. So null
is both.
null
is a value that is said to be of his own kind, a type whose value can only be null
. There are languages that conceptualize a little different, but it’s never very different from this, some even use another name like nil
or none
. Anyway it’s usually the absence of value valid. Note that it is not exactly absence of value as it is said informally.
In some languages the value null
can only be used in reference types since the reference is null and therefore prevents accessing a valid object. In types by value there is no way to represent nullity directly (you can create a composite type).
In static typing languages we can say that this is a breach of typing since a variable can have two different types of data, one is the valid value, the object of its type, and the other is a null
which is basically a value of another kind.
Then a variable (or property) has a valid or invalid value (null
), and is in valid or invalid status (specified by null
). It’s just a semantic discussion at best.