P^Q | T | F | NA
----------------
T | T | F | T
----------------
F | F | F | F
----------------
NA | T | F | NA
This is the plausibility argument: if a predicate does not apply, then it can be ignored. Thus, T^NA becomes simply T, since the second predicate can be ignored. Obviously, one could continue in this vein, and construct a truth table for this logic's disjunction:
PvQ | T | F | NA
----------------
T | T | T | T
----------------
F | T | F | F
----------------
NA | T | F | NA
But, if we do this, we find that the distributive law does not hold. In particular, if one considers:
P^(QvR) = (P^Q)v(P^R)
for the truth values P=True, Q=False, and R=NULL, One finds that the left and right side both evaluate to NULL in standard SQL, but the left side evaluates to False and the right to True in my hypothetical 3 valued logic. So, this is not going to become part of SQL anytime soon.
To sum up, what is the point of all this? Here is the short answer:
Values can be missing for at least two reasons: the proper value is currently unknown, and/or the value does not apply.
The SQL Null is tailored for the "unknown" reason.
Using a Null to mean "does not apply" will produce confusing results at best, and downright wrong results at worst.
No comments:
Post a Comment