The Logic, Mathematics, and Utility of NULLs

  • Since I've made that distinction, one aspect of logic and unknowns has become clear to me, although I'm thinking out-loud some here...

    Logic divides arguments into subjects and predicates. A column is usually the subject in a table, and the value for each row the predicate. So, you have a Car table, one of the columns is MPG. For a row, a number 27 in the MPG column would describe the gas mileage of that particular make and model of car for example. The value in the rows become the predicates.

    In logic, if one of the values is missing, we simply do not make the claim: "This car gets x MPG" is not very useful, is it?

    So in logic, the whole sentence is avoided, which actually makes more sense. In programming on the other hand, it is as if we assume that a value must be there. :ermm:

    The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge. - Stephen Hawking

  • mtillman-921105 (9/8/2010)


    In the first post, it says that NULLs are, in effect, in logic and in algebra. But notice that we should be more careful about that since logic can only use BOOLEAN types.

    No-one who has seriously studied logic in the 20th or 21st century believes that - and the idea of 3-valued logic started a couple of thousand years ago with Aristotle (who asserted that there were exceptions to the principle of bi-valence despite numerous mumbo-jumbo artists claiming that he was responsible for promoting that principle).

    If you have NULLs in a relational system you had better not have a 2-valued logic as the logic component of your relational calculus, because the combination just doesn't work.

    A large number of mathematicians prefer to work using "constructive logic" which doesn't just have one or a couple more truth values than "true" and "false", but which has no models in which the cardinality of the set of truth values is as small as the cardinality of the set of all integers. "Fuzzy logic" is another logic with an infinite set of truth values. These things are used for good reasons - so don't assume that a 2-valued logic is enough.

    Tom

  • Tom.Thomson (9/10/2010)


    mtillman-921105 (9/8/2010)


    In the first post, it says that NULLs are, in effect, in logic and in algebra. But notice that we should be more careful about that since logic can only use BOOLEAN types.

    No-one who has seriously studied logic in the 20th or 21st century believes that - and the idea of 3-valued logic started a couple of thousand years ago with Aristotle (who asserted that there were exceptions to the principle of bi-valence despite numerous mumbo-jumbo artists claiming that he was responsible for promoting that principle).

    If you have NULLs in a relational system you had better not have a 2-valued logic as the logic component of your relational calculus, because the combination just doesn't work.

    A large number of mathematicians prefer to work using "constructive logic" which doesn't just have one or a couple more truth values than "true" and "false", but which has no models in which the cardinality of the set of truth values is as small as the cardinality of the set of all integers. "Fuzzy logic" is another logic with an infinite set of truth values. These things are used for good reasons - so don't assume that a 2-valued logic is enough.

    All right Tom, I like your take on this, but I'm actually not convinced. I'm kind-of playing the devil's advocate now, but here it goes:

    People usually reason with the law of the excluded middle intact. That is, if p is true, then NOT P is false. To give a simple example for those who are not used to talking logic, either apples are a fruit or apples are not a fruit. So a or ~a, period. Both or neither is not a possibility. Allowing NULLs creates a whole new plain - an apple is neither a fruit nor not a fruit? (This may be somewhat oversimplified, but this is the gist of it.)

    When NULLs are introduced, SQL logic becomes counterintuitive and creates a big, confusing mess.

    By the way, I read that a sort of 3VL also came up when the "Cancel" option was added in Windows - so the options were "Yes", "No", or "Cancel." :w00t: So apparently DBMS are not alone in this.

    The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge. - Stephen Hawking

  • mtillman-921105 (9/8/2010)


    Logic divides arguments into subjects and predicates. A column is usually the subject in a table, and the value for each row the predicate. So, you have a Car table, one of the columns is MPG. For a row, a number 27 in the MPG column would describe the gas mileage of that particular make and model of car for example. The value in the rows become the predicates.

    In logic, if one of the values is missing, we simply do not make the claim: "This car gets x MPG" is not very useful, is it?

    So in logic, the whole sentence is avoided, which actually makes more sense. In programming on the other hand, it is as if we assume that a value must be there. :ermm:

    I'm not sure about that use of "predicate" but that's just terminology so who cares.

    Not making the claim - I agree with that. What we see in SQL is something like "where mpg > 26" - and if the database has NULL for the mpg column for a particular row it is not making any claim (other that "I don't have any value for the mpg for this row") about mpg for that row. It's not a question we can avoid though - someone is going to make that query - so all the database can say is " I don't have a value so I can't tell you whether it's greater than 26 or not": in other words, the database's answer for "is it greater than 26" isn't "Yes" and it isn't "No", it's "I haven't a clue". So it has to work in (at least) a three-valued logic, with the three values "True", "False", and "I Don't know".

    "It is as if we can assume the value must be there" is a place where lots of people go wrong: we can't make that assumption, it's just nonsense. (I think I'm agreeing with you here.)

    The rest of this comment is a [n ex-] mathematical logician's take on Codd's work on having two sorts of NULL. Don't read it if you want to stick in the real world instead of in speculative mathematical theory.

    In databases with more than one type of NULL this can get quite messy: if we look at Codd's NULL-i and NULL-a, we find one version where NULL-i means "known to be inapplicable" and NULL-a means "don't have a value and don't know why"; then there's another version where NULL-a means "we don't have a value but we know it's applicable" and NULL-i means "we don't have a value because it's inapplicable" (so there's no way of covering the case "we don't know whether it's applicable or not"; Codd fans - including me, I have to admit, - tend to forget about this gap in that version, which is the version in RM version 2, and prefer either his other version of his 2-NULL system or his 1-NULL system, which is what SQL attempted to implememt and failed). The reason for the RM-2 version was that Codd wanted to be able to reason about some of the cases where it was known that a value was applicable: for example a proposition like "NULL-a < 0 or NULL >= 0" is guaranteed to be True when NULL-a is a marker for a missing value from the integer domain provided NULL_a is guaranteed to signal an applicable value (and, in Codd's RM-2 system, if I'm remembering correctly, "NULL-i < 0 or NULL-i >= 0" was guaranteed to be "False", while "NULL-i < NULL-i or NULL-i >= NULL-i" was none of "True", "False" or "Unknown" but had a fourth truth value "Inapplicable"). All the stuff about the relational calculus engine needing to detect tautologies could be discarded if there were no version of NULL which offered a guarantee of applicability, as could the fourth truth value in the logic component of the relational calculus; and the RM-2 gap in absent-value coverage would disappear; of course the basic problem in the RM-2 NULLs can also be fixed by introducing a 3-rd NULL (to cover the "we don't even know whether it's applicable" case) and keeping RM-2's 4 truth values, but doing that would leave the question of tautology detection still a valid one. But of course there's no imaginable way that Date's nonsense about needing an unbounded set of NULLs as soon as one goes to two can be justified.

    Tom

  • Tom.Thomson (9/10/2010)


    ...

    The rest of this comment is a [n ex-] mathematical logician's take on Codd's work on having two sorts of NULL. Don't read it if you want to stick in the ...

    In databases with more than one type of NULL this can get quite messy: if we look at Codd's NULL-i and NULL-a, we find one version ...

    Heh, he. You said Null-A, ha.(*) 😛

    (* - obscure A. E. Van Vogt reference...)

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • RBarryYoung (9/15/2010)


    Tom.Thomson (9/10/2010)


    ...

    The rest of this comment is a [n ex-] mathematical logician's take on Codd's work on having two sorts of NULL. Don't read it if you want to stick in the ...

    In databases with more than one type of NULL this can get quite messy: if we look at Codd's NULL-i and NULL-a, we find one version ...

    Heh, he. You said Null-A, ha.(*) 😛

    (* - obscure A. E. Van Vogt reference...)

    Actually, did you know that NULL is an elegant computer language too? http://baetzler.de/humor/null.html :laugh:

    The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge. - Stephen Hawking

  • RBarryYoung (9/15/2010)


    Heh, he. You said Null-A, ha.(*) 😛

    (* - obscure A. E. Van Vogt reference...)

    What's obscure about it? The Pawns of Null-A was his second best book (by my counting The Weapon Shops of Isher was the best). 😛

    There's a problem with the term NULL-A in that book: non-Aristotelian is a pretty ambiguous (actually not ambiguous, because there are 3 possible meanings, not 2 :Whistling:) term which has been used to mean (a) disagreeing with Aristotle and accepting the principle of bivalence, (b) disagreeing with Aristotle and rejecting the principle of bivalence, and (c) agreeing with Aristotle but disagreeing with the idiots who use it to mean either (a) or (b) because they think that the principle of bivalence is the only thing that matters in logic. I guess Van Vogt's use of the term was with meaning (c), because he was a fan of Korzybski who was clearly a proponent of (c).

    But of course the use of "NULL-a" (or, in some papers, just "a") in relational calculi has no real connection with its use by Van Vogt.

    Tom

  • mtillman-921105 (9/15/2010)


    Actually, did you know that NULL is an elegant computer language too? http://baetzler.de/humor/null.html :laugh:

    The trouble with Andrews' presentation of the language is that he doesn't mention its principle advantage: that no programme in NULL can contain a bug. :hehe:

    Tom

Viewing 8 posts - 61 through 67 (of 67 total)

You must be logged in to reply to this topic. Login to reply