SQL design question: null vs. boolean values

Поиск
Список
Период
Сортировка
От j.random.programmer
Тема SQL design question: null vs. boolean values
Дата
Msg-id 20050115144018.8932.qmail@web14207.mail.yahoo.com
обсуждение исходный текст
Ответы Re: SQL design question: null vs. boolean values  (Andrew Sullivan <ajs@crankycanuck.ca>)
Re: SQL design question: null vs. boolean values  (Richard Huxton <dev@archonet.com>)
Список pgsql-sql
Hi all:

I was wondering if anyone had recommendations for the
following scenarios:

(A) 
I have three radio boxes in the user form

field_foo
[]yes  
[]no   
[]unknown

These are mutually exclusive and user input is always
required.

So in the database, should I have something like:

field_foo  char(1)  not null check (field_foo in 'y',
'n', 'u')    ....OR....
field_foo char(1) check (field_foo in 'y', 'n')

The second choice always implies that NULL means
unknown,
whereas for the first choice, unknown is coded as 'u'.

(B)
In the user form, I have a field like:

field_bar
[]  select_me

with ONE choice, which is optional.

Should I code this as:

field_bar  char(1)  not null check (field_foo in 'y',
'n')    ....OR....
field_foo char(1) check (field_foo in 'y')

The second choice always implies that NULL means not
selected whereas whereas for the first choice,
selected is coded 
as 'y' and not selected coded as 'n'

Any advice, dear SQL experts ? 

Best regards,

--j





    
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - 250MB free storage. Do more. Manage less. 
http://info.mail.yahoo.com/mail_250


В списке pgsql-sql по дате отправления:

Предыдущее
От: Markus Schaber
Дата:
Сообщение: Split pg_dump script
Следующее
От: Andrew Sullivan
Дата:
Сообщение: Re: SQL design question: null vs. boolean values