Re: The BOOLEAN data type - What is really Boolean and what is not?

From: Bruce Rennie <bruce.rennie_at_shell.com.au>
Date: 21 Apr 2003 03:30:30 -0700
Message-ID: <8d821729.0304210230.59072938_at_posting.google.com>


pkl_at_mailme.dk (Peter Koch Larsen) wrote in message news:<61c84197.0304180715.23ded92b_at_posting.google.com>...
> Costin Cozianu <c_cozianu_at_hotmail.com> wrote in message news:<b7ncgr$2odsj$1_at_ID-152540.news.dfncis.de>...
> > --CELKO-- wrote:
>
> [large snip]
>

[Snipped]
> >
> > 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.
>
> Yes - not that difficult.

In fact - IMPOSSIBLE. Boolean algebras require either 2 or an integer power of 2 number of values in the domain. Check any good combinatorics text for how this works. So at a minimum you will have

True or False ( 2 distinct values )

or you could have

True A B False ( 4 distinct values ) or 8, 16, etc

where both A and B are part way between True and False.

This leads to the correct logic tables.

Since three valued logic is not Boolean ( there are a number of different ways the logic operations can be written ( for 3VL-AND and 3VL-OR and 3VL-NOT )), you have to decide on the particular operations that you will allow and how the results will be calculated. Therefore, the normal Boolean operations of AND and OR and NOT cannot and do not work with three value domains.

Allowing another value in the Boolean (2VL) domain forces it to no longer be Boolean. Problems arise. For further research, look at the Russian TERNARY computer from the 1950's. This was not a Boolean logic based machine.

> >
>
> The to me fundamental problem is how to cope with missing values. I
> agree that You have no need for them in base tables, but what happens
> in the situation where you have an outer join? If outer joins are to
> be provided by the DBMS - and I believe they are to useful to be let
> out - there must be some means of denoting that a field has no value.
> There are three ways to go:

If the value is missing, then provide a way in the design of the database that allows you NOT to store information without resorting to the use of NULLS. An appropriate redesign/rethink of the questions being asked of the DBMS on the database will give rise to sensible answers. Too many times I've been required to provide answers to the wrong questions - so - teach the questioners to ask the right questions - not always easy, but doable. It allows correct information  to be given instead of wrong/partially correct that is generally given now (statement is stated this way deliberately - think carefully the implications).

>
> 1) Use a NULLABLE type. This could be an extension like the sum-type
> mentioned (i have not read that thread yet so i can not comment). I
> see no problems with that approach.
> 2) Use a DEFAULT value. This could be feasible in some situations, but
> in many situations it would not. The most obvious example would be if
> the field in question is boolean. Which default could you possible
> use?
> 3) Use a marker that existed independently of the field. This approach
> has so many flaws that I believe it to be infeasible. For one thing,
> what value should we store in that field? If we have ADT's we must be
> careful as the ADT might have some constraints, that if not set will
> invalidate the type - a CIRCLE could as an example be required a
> non-negative radius. Even non-ADT types might have some integrity
> constraints: think about a floating point number stored in the IEEE
> format.
>
> My personal conclusion is that we are stuck with NULLS - if not in the
> SQL sense then at least in the sense that we are to have some kind of
> sum type. And if we are stuck with such a type, then the only sensible
> thing is to have it standardised by the DBMS - how else are we going
> to let the DBMS perform the outer join by itself?
> This is getting very off topic, however, so I have started a new
> thread on this subject.
>
> Kind regards
> Peter

regards

-- 
Bruce Rennie ( from God's Own Country Downunder )
Disciple of Jesus Christ in Training

The Cross of Jesus Christ - Salvation for all men.

Song of Solomon ( Song of Songs ) - The greatest Love Story Ever
and a story for our times.

Be a GOD Chaser.
Received on Mon Apr 21 2003 - 12:30:30 CEST

Original text of this message