Re: The BOOLEAN data type

From: Bob Badour <bbadour_at_golden.net>
Date: Mon, 31 Mar 2003 22:50:28 -0500
Message-ID: <6z8ia.241$v35.69_at_mantis.golden.net>


"Paul" <paul_at_not.a.chance.ie> wrote in message news:MPG.18f2f9fb9888aaa29896af_at_news1.eircom.net...
>
> > Aside from the destruction of the foundations of SQL, Booleans are
> > usually, but not always, a sign of bad programming.
>
> I'm confused here! Why is it bad?
>
> I'm working on a project where we store people's gender - what's wrong
> with using a boolean for that?

Because gender is neither true nor false. It is male, female, neuter, partially transgendered, gender reassigned male to female, gender reassigned female to male, unknown etc.

I suggest you choose an appropriate domain that represents the values of interest and define the appropriate operations for the domain. The boolean domain has two distinct values neither of which are male or female, and it has operations such as conjunction and implication that have no meaning for gender.

> > Someone is
> > storing the state of the database at one point in time as a flag. It
> > is a computed column and we all know better than to store redundant
> > data like that.
>
> How does one "compute" gender?

Personally, I have no objection to storing redundant or derived data. Indexes do it. Snapshots do it. ... I guess I don't know who "we" is. Since you cut the attribution, I don't even know who "he" is.

You might want to ask him what type of value a comparison operation should return. For instance, what is the type of the following expression and what type do the operands to the 'and' operation have? ((gender <> 'M') and (gender <> 'F'))

Of course, normalization reduces redundancy in the logical design and thereby avoids a number of update anomalies and simplifies integrity enforcement. But then again, base relations are not the full logical design. Views and snapshots will introduce redundancy into the logical design as well--automated and managed but redundant nonetheless.

To answer your question: One might derive gender a number of ways depending on the data modelled--by counting Y chromosomes, for instance. In Ontario, one can derive gender from a driver's license number. Received on Tue Apr 01 2003 - 05:50:28 CEST

Original text of this message