Re: Simple db table design question

From: --CELKO-- <71062.1056_at_compuserve.com>
Date: 19 Mar 2003 11:25:19 -0800
Message-ID: <c0d87ec0.0303191125.7898d7fb_at_posting.google.com>


>> Actually in this case I can't guarantee that both home and work
emails are NOT NULL, ... <<

CREATE TABLE Foobar
(name ....

 home_email VARCHAR(64),
 work_email VARCHAR(64),
 best_email CHAR(1) DEFAULT 'h' NOT NULL
         CHECK (best_email IN ('h', 'w', 'n')),
 ...);

SELECT ...,

     CASE WHEN best_email = 'h'
          THEN home_email 
          WHEN best_email = 'w
          ELSE '{{NONE}}' END AS email,

  FROM Foobar
 WHERE ...; Received on Wed Mar 19 2003 - 20:25:19 CET

Original text of this message