DEV Community 👩‍💻👨‍💻

Discussion on: What Can't I do, as a Rule?

Collapse
 
jgomo3 profile image
Jesús Gómez

Beautiful!: "And since both possibilities result in Aoe(IOKASTE) being true, then this tells us that the condition is met."

Aside: I understand that NULL in SQL has to be treated as: I Don't know, which seems to me as an Open World Assumption. Am I right?

Collapse
 
quoll profile image
Paula Gearon Author

If you're treating it as "I don't know" then it's an open world assumption (OWA), but my experience is that it's typically treated as, "I do know, and the data does not exist"

Collapse
 
jgomo3 profile image
Jesús Gómez

Isn't that the same thing?

Not having the data, in a database system, marked with NULL[1], is the same as "not knowing", if we could say the database "knows" something. I think.

You ask something to the database and get NULL, you have no knowledge except for the fact that the database doesn't have enough information to concrete an answer.

Ex, What's the average income? NULL. I think is valid to read it as "I Don't know" as much as "I Don't have enough data to give you a concrete answer".

At least operations are coherent with this reasoning. What is greater NULL or 1: NULL (NULL > 1 = NULL), or... IDK what is greater.

[1] I made this note "marked with NULL" because it is different to not having a "row" in a table, which could be conclusive: "There are 10 things, no more no less", instead of saying "There are at least 10 things in the world". In which case I suppose there is nothing but the application context to determine which of the 2 interpretations to use.

Ok, I'm raving now. I think I've never thought about this OWA/CWA stuff before. Tell me if I'm wrong on what I said that with traditional databases, it is the application which make the assumptions, i.e. one codes with a preconceived meaning of what NULL is and what non-existing rows mean.

Thread Thread
 
quoll profile image
Paula Gearon Author

Strictly speaking, a relational database works with the CWA, so missing data means that as far as the computer is concerned then it does not exist, as opposed to "unknown".

For instance, if you're joining between tables on a nullable column, those rows with null in that column will not match. If they were truly "don't know" then they'd be included, since maybe they actually would match if those rows contained appropriate data in that column.

An app can absolutely treat it as meaning something else, but that is a choice of the developer of how to treat this data. It's not the default behavior of the database.