Re: Simple db table design question

From: --CELKO-- <>
Date: 18 Mar 2003 12:32:31 -0800
Message-ID: <>

>> METHOD 2 HomeEmail and WorkEmail are VarChar fields [sic]
containing email addresses BestEmail is a Varchar field [sic] containing "Home" or "Work" <<

Don't use VARCHAR(n) when a simple code will do. If you truly have only two options and they are always NOT NULL, then

(name ....

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

SELECT ... CASE WHEN best_email = 'h'

                THEN home_email ELSE work_email END AS email,
  FROM Foobar
 WHERE ...; Received on Tue Mar 18 2003 - 21:32:31 CET

Original text of this message