Re: The BOOLEAN data type

From: Bob Badour <bbadour_at_golden.net>
Date: Wed, 9 Apr 2003 13:17:25 -0400
Message-ID: <8aZka.183$9P1.18045049_at_mantis.golden.net>


"Alan" <alan_at_erols.com> wrote in message news: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.

You just changed your requirements to suit the design. That puts the cart before the horse. You must develop your design to suit your requirements.

> Oops: But now this "null" business now puts me at odds with what I wrote
to
> Joe Celko earlier.

Yes, it does put you at odds with what you wrote earlier. You proposed business requirements suggesting NULL means unknown and that future ship dates mean anticipated ship dates. According to those requirements, one would need the boolean or some other indicator to indicate that an item has not been shipped even though the anticipated ship date has passed.

Some requirements will suggest the use of a boolean and some will not. What's your point?

Now, if you were to suggest that 'shipped' is probably one of more than two states in a state machine, I would tend to agree. Off the top of my head, I might guess it has states like: ordered/created, confirmed/paid, prepared, inspected, packaged, shipped, return authorized, return received, return confirmed etc. Received on Wed Apr 09 2003 - 19:17:25 CEST

Original text of this message