Re: The BOOLEAN data type

From: Costin Cozianu <c_cozianu_at_hotmail.com>
Date: Wed, 02 Apr 2003 19:45:09 -0800
Message-ID: <b6gadl$50c7q$1_at_ID-152540.news.dfncis.de>


Here's a data modeling exercise for you.

Let all threads in comp.database.theory get a identifying key (let's say the one used by groups.google.com web application for lack of easier references ).

Let there be a a panel of judges who will "judge" if Joe Celko's contributions to the above threads are "good" as opposed to "bad" (unreasonable, misleading, containing bad advice). So we want to trak basic facts like this:

        Costin Cozianu thinks that Joe Celko's contribution to the <BOOLEAN Data type thread> is not good.

The final purpose would probably be to run some statistics :)

Here's a minimal and natural solution with the boolean data types. I leave the constraints as an exercise for the reader, because you made SQL way too verbose for me to bother :)

CREATE TABLE THREADS (
thread_id varchar,
thread_subject varchar)

CREATE TABLE JUDGES (
judge varchar
)

CREATE TABLE JUDGEMENTS (
thread_id varchar,
judge varchar,
is_good boolean
)

and then I'd insert for this particular thread:

INSERT INTO JUDGEMENTS
        VALUES ( 'W1Hia.19%243l2.962647%40mantis.golden.net', 'Costin Cozianu', false )

If I want to say that your contribution is good I'd put a "true". If I am in doubts or have mixed feelings, I don't want to pronounce, I won't insert anything.

Voila: a natural usage of boolean datatype, *and* there are no NULLs in the table, and no NULLs are ever needed in this case. Plus the schema is   very easy to use in programs, queries, reports, OLAP thingies :) Received on Thu Apr 03 2003 - 05:45:09 CEST

Original text of this message