Subject RE: [IBO] Boolean with NULL
Author Helen Borrie
At 08:38 PM 12-08-01 +0200, you wrote:
>Helen,
>
> I am reading column rdb$null_flag from rdb$relation_fields table, and I
>can't change anything there . So if it is not logical (I agree with you it
>is not), why is it implemented like that in system tables ?

The current SQL doesn't have a Boolean type. It has been introduced into SQL3 at the intermediate and full levels as a nullable enumerated type which has only two possible values, True and False.

The "fudge" that we do in the absence of an implemented Boolean type is to create a Boolean domain with the same restrictions. Jason's implementation recognises it by supporting the two-state Boolean in certain controls - checkbox-style representation of columns designated BOOLEAN in grids, standardized behaviour in checkboxes. The value you assign for True (e.g. smallint 1 or char(1) 'T') causes the control to display a checkmark; the designated False value (e.g. 0 or 'F') displays a blank. If you allow your column to be nullable, the NULL state is indicated by a greyed checkmark. This is sufficiently confusing for users to make it useful to define your Boolean domain as not null and default it. That's not a rule, though.

The entire system database is defined without NOT NULL constraints on any columns and without formal PRIMARY or FOREIGN constraints. At the time the engine was created InterBase didn't support referential integrity or domains. RI triggers in the system database are done with custom triggers. There are no Booleans and no domains. Flag columns are open-ended, not constrained as two-state Booleans at all but capable of containing any SMALLINT value, or NULL.

As to **why** the system database wasn't brought up to date with the capabilities of the engine, one would have to guess. If the rationale behind the design of the system database really interests you, you could inquire in the ib-support list when Ann Harrison returns from vacation at the end of the month...although she had no part in design or feature changes made after the database was sold to Borland.

Regards,
Helen

All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________