Re: The BOOLEAN data type

From: Alan <alan_at_erols.com>
Date: Wed, 9 Apr 2003 12:57:03 -0400
Message-ID: <b71jcp$9qhgq$1_at_ID-114862.news.dfncis.de>


"Bob Badour" <bbadour_at_golden.net> wrote in message news:eDYka.181$QN1.18012226_at_mantis.golden.net...
> "Alan" <alan_at_erols.com> wrote in message
> news:b717p3$a176q$1_at_ID-114862.news.dfncis.de...
> > "--CELKO--" <71062.1056_at_compuserve.com> wrote in message
> > news:c0d87ec0.0304081511.36fdbd40_at_posting.google.com...
> > > >> Let's say you have a table of product orders and you need to know
> > > which one's have been shipped and which one's haven't. That's a
> > > boolean value that can't be computed from other data. <<
> > >
> > > Wrong:
> > >
> > > CREATE TABLE Orders
> > > (order_nbr INTEGER NOT NULL PRIMARY KEY,
> > > ..
> > > ship_date DATE, -- null means not yet shipped
> > > ..);
> > >
> > > And please don't tell that you would not record the shipping date,
> > > shipping charges, shipping method, etc. in the database.
> >
> > So, you are saying NULL may have a valid semantic meaning? Doesn't NULL
> (in
> > this example) mean, "have not a clue, maybe it was shipped, maybe it
> wasn't,
> > maybe it will be shipped one day..."? Shouldn't it work like this:
> >
> > IF Shipping_Date <= Today, then it's been shipped
> > Else If Shipping_Date > Today, it has not yet been shipped, but
apparently
> > will be on the given date
> > Else If Shipping_Date IS NULL, then we just don't know...

>

> What happens if something goes wrong and the item doesn't ship on the
> anticipated date? Hmmmm.... I guess you might need a boolean, after all,
to
> indicate whether the item actually shipped.
>
>

Not really. It depends on the semantics of the attribute (shippED_date (infers past dates only) vs. shippING_date (infers any date), E.g. ), and how one wants to handle the situation. It boils down to business rules, which is what the database is there to serve. So, for example, the business decides that the shipping_date will remain null (see oops, below) until the item is shipped (no future dates allowed), or, if there is a problem (as with getting Dell PCs shipped by the ship date), just update the shipping_date to some other future date. Or just call it shipped_date and only allow past dates. However one wants to do it... But in no case is a Boolean needed. It is always possible to calculate if shipping _has_ occurred.

Oops: But now this "null" business now puts me at odds with what I wrote to Joe Celko earlier. Looks like "null" has a business meaning in this case. But Booleans would still be superfluous. Received on Wed Apr 09 2003 - 18:57:03 CEST

Original text of this message