Re: The BOOLEAN data type

From: Costin Cozianu <c_cozianu_at_hotmail.com>
Date: Thu, 17 Apr 2003 16:19:10 -0700
Message-ID: <b7ncgr$2odsj$1_at_ID-152540.news.dfncis.de>


--CELKO-- wrote:
>>>Well.... SQL has many faults, one of them being the value of having
>
> a
> NULL datatype. <<
>
> It is not a datatype! It is not a data value! It is a marker for a
> missing value. These differences are important.
>
>
>>>While I tend to agree that nulls in basetables are of little or no
>
> value, I do see the NULL value as a reasonable way to support outer
> joins. <<
>
> While I want to have DEFAULT or NOT NULL whenever possible, NULLs can
> be useful in tables. My favorite is as an "eternity symbol" in
> durations:
>
> CREATE TABLE Foobar
> (...
> start_date DATE DEFAULT CURRENT_TIMESTAMP NOT NULL,
> end_date DATE, -- null means on-going event
> CHECK(start_date <= end_date),
> ...);
>

Actually here you are representing a sum type.

type extendeDate = PastEternity | JustDate of date | FutureEternity

of course this is in ML (you can do the same in Haskell, Clean and a few other modern languages).

but you "translated" it in a contorted and unsafe way in SQL.

>
>>>This terrible of treating null-values with propagation is just
>
> incoherent, however. Who ever invented that? <<
>
> Dr. Codd. He later had two nulls -- missing value, and missing
> attribute
>
>
>>>While meaningful for e.g. arithmetic values (null + x is clearly
>
> null, and it seems reasonable to treat null*x = null even though this
> is incoherent if x = 0), <<
>
> Try (null/0); a lot of SQL products got it wrong. You are assuming
> that a NULL is a value of a numeric datatype, so that the laws of
> arithemetic apply. It is not a numeric; it has no datatype at all.
>
>
>>>Why does SQL not use three-valued logic? <<
>
>
> Dr. Codd and the NULLs required it.

Dr. Codd required that a relation is a set of tuples.

What happened to that requirement ?

Besides, three valued logic is totally unnecessary. You know the saying instead of feeding the hungry give him a fishing pole and teach him how to fish.

If you support sum types (see the parallel thread), I don't need three valued logic, classic logic is enough.

Using a decent type system , I can define a three valued logic boolean, in 5 lines of code and reuse it all over the place where I need. If I really need to I can dfine a fuzzy boolean data type in a hadnful of code and reuse it all over the place.

Mandating that users abide by an ugly three valued logic for all their needs is really a bad solution and should be deprecated. Received on Fri Apr 18 2003 - 01:19:10 CEST

Original text of this message