Re: Implementation of boolean types.

From: David Cressey <david.cressey_at_earthlink.net>
Date: Fri, 15 Jul 2005 10:14:59 GMT
Message-ID: <D0MBe.3716$oZ.175_at_newsread2.news.atl.earthlink.net>


"Jonathan Leffler" <jleffler_at_earthlink.net> wrote in message news:T3IBe.8231$8f7.4833_at_newsread1.news.pas.earthlink.net...
> -CELKO- wrote:
> > NULL is not a logical value and UNKNOWN is. Look up the truth tables
> > in any SQL book.
> >
> > Q: Now what is the first and most important rule of NULLs?
> > A: NULLs propagate in computations!
> >
> > That means we should have these rules for Boolean types:
> >
> > NULL AND TRUE = NULL
> > NULL AND FALSE = NULL
> > NULL AND NULL = NULL
> >
> > NULL OR TRUE = NULL
> > NULL OR FALSE = NULL
> > NULL OR NULL = NULL
> >
> > NOT NULL= NULL -- valid but really weird looking, unh?
>
> Hmmm...the 3VL truth tables I was taught looked like this (with ?
> meaning null - I hope you're looking at fixed width fonts):
>
> AND T ? F
> T T ? F
> ? ? ? F
> F F F F
>
>
> OR T ? F
> T T T T
> ? T ? ?
> F T ? F
>
> x NOT x
> T F
> ? ?
> F T
>
> This would make your rules for NULL AND FALSE and for NULL OR TRUE
> incorrect:
> NULL AND FALSE = FALSE
> (because regardless of whether TRUE or FALSE is substituted
> for null, the result will then be false)
> NULL OR TRUE = TRUE
> (because, regardless of whether TRUE or FALSE is substituted
> for null, the overall result will then be TRUE)
>
> > However, in 3VL we have these rules
> >
> > UNKNOWN AND TRUE = UNKNOWN
> > UNKNOWN AND FALSE = FALSE <== opps! not the same as NULL
> > UNKNOWN AND UNKNOWN = UNKNOWN
>
> If your initial statement was accurate, then yes; my understanding is
> that looks the same as the corrected table.
>
> > UNKNOWN OR TRUE = TRUE <== opps! not the same as NULL
> > UNKNOWN OR FALSE = UNKNOWN
> > UNKNOWN OR UNKNOWN = UNKNOWN
>
> Ditto.
>
> > NOT UNKNOWN = UNKNOWN
> >
> > So, which of the three values does a NULL map to?
>
> Apparently, NULL == UNKNOWN, under the premises I was taught.
>
> > The results of
> > logical expressions now depend on the order of execution and
> > substitution of UNNOWN and NULL
>
> Where did I make a mistake in my analysis?
>
> --
> Jonathan Leffler #include <disclaimer.h>
> Email: jleffler_at_earthlink.net, jleffler_at_us.ibm.com
> Guardian of DBD::Informix v2005.01 -- http://dbi.perl.org/

And if your font is variable width, but your reader decodes embedded html, this might help:

<code>
AND T ? F
  T T ? F
  ? ? ? F
  F F F F

OR T ? F
  T T T T
  ? T ? ?
  F T ? F

  x NOT x
  T F
  ? ?
  F T
</code> Received on Fri Jul 15 2005 - 12:14:59 CEST

Original text of this message