Monday, March 16
Small Wonder
Programmers have a lot of trouble with the concept of null, as found in relational databases.
There's a good reason for that. In regular boolean logic, there are 16 binary operators - the usual suspects like AND, OR, XOR, and implication and its converse; their negations; and the six degenerate forms that aren't truly binary at all - P, Q, their negations, and T and F (tautology and contradiction).
Okay?
There are 256 ternary boolean operators, as any hardcore Amiga programmer would know. (The Amiga's blitter allowed you to process three image sources into a destination, and you could program it to perform any one of the 256 possible operators.)
If you throw in null, so that you have three-valued, or ternary, logic, you now have 19,683 binary operators. (That is, binary ternary operators. And 7,625,597,484,987 ternary ternary operators, which is why no-one made a three-valued Amiga.)
In 1990, Codd suggested that four-valued rather than three-valued logic was better for the relational model, dividing the concept of null into Missing but Applicable (A-values) and Missing but Inapplicable (I-values). I call them don't know and don't care, or none and any. (Because if you don't know and it matters, no value will give you the right answer, while if you don't care, any value will do.)
This does give you a more precise way of handling missing data. It also gives you 4,294,967,296 binary operators. That's probably why it hasn't really caught on yet.
Comments are disabled.
Post is locked.
Programmers have a lot of trouble with the concept of null, as found in relational databases.
There's a good reason for that. In regular boolean logic, there are 16 binary operators - the usual suspects like AND, OR, XOR, and implication and its converse; their negations; and the six degenerate forms that aren't truly binary at all - P, Q, their negations, and T and F (tautology and contradiction).
Okay?
There are 256 ternary boolean operators, as any hardcore Amiga programmer would know. (The Amiga's blitter allowed you to process three image sources into a destination, and you could program it to perform any one of the 256 possible operators.)
If you throw in null, so that you have three-valued, or ternary, logic, you now have 19,683 binary operators. (That is, binary ternary operators. And 7,625,597,484,987 ternary ternary operators, which is why no-one made a three-valued Amiga.)
In 1990, Codd suggested that four-valued rather than three-valued logic was better for the relational model, dividing the concept of null into Missing but Applicable (A-values) and Missing but Inapplicable (I-values). I call them don't know and don't care, or none and any. (Because if you don't know and it matters, no value will give you the right answer, while if you don't care, any value will do.)
This does give you a more precise way of handling missing data. It also gives you 4,294,967,296 binary operators. That's probably why it hasn't really caught on yet.
Posted by: Pixy Misa at
12:30 AM
| Comments (3)
| Add Comment
| Trackbacks (Suck)
Post contains 245 words, total size 2 kb.
Posted by: Wonderduck at Monday, March 16 2009 09:44 AM (eXdIs)
Posted by: Andrew at Monday, March 16 2009 02:23 PM (/uGTr)
3
I once worked with a point-of-sale program (written in xbase) which used numbers in a character field to accommodate this:
Positive number: Net sale of n pieces in the time period
Negative number: Net return of n pieces (more returned than sold)
Zero: Returns = Sales (both some nonzero value)
Blank: No returns or sales (e.g., no transactions for that item at all)
Made for interesting consequences when exporting the data, especially before FoxPro introduced the empty() function!
Positive number: Net sale of n pieces in the time period
Negative number: Net return of n pieces (more returned than sold)
Zero: Returns = Sales (both some nonzero value)
Blank: No returns or sales (e.g., no transactions for that item at all)
Made for interesting consequences when exporting the data, especially before FoxPro introduced the empty() function!
Posted by: Old Grouch at Tuesday, March 17 2009 06:39 AM (dguEG)
48kb generated in CPU 0.0259, elapsed 0.1453 seconds.
56 queries taking 0.1368 seconds, 352 records returned.
Powered by Minx 1.1.6c-pink.
56 queries taking 0.1368 seconds, 352 records returned.
Powered by Minx 1.1.6c-pink.