X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 89EE03A2C4F for ; Sat, 15 Jan 2005 14:40:33 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 15567-08 for ; Sat, 15 Jan 2005 14:40:15 +0000 (GMT) Received: from web14207.mail.yahoo.com (web14207.mail.yahoo.com [216.136.173.71]) by svr1.postgresql.org (Postfix) with SMTP id 7254C3A18B5 for ; Sat, 15 Jan 2005 14:40:17 +0000 (GMT) Received: (qmail 8934 invoked by uid 60001); 15 Jan 2005 14:40:18 -0000 Message-ID: <20050115144018.8932.qmail@web14207.mail.yahoo.com> Received: from [141.151.83.165] by web14207.mail.yahoo.com via HTTP; Sat, 15 Jan 2005 06:40:18 PST Date: Sat, 15 Jan 2005 06:40:18 -0800 (PST) From: "j.random.programmer" Subject: SQL design question: null vs. boolean values To: pgsql-sql@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.274 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE X-Spam-Level: X-Archive-Number: 200501/111 X-Sequence-Number: 19899 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