| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Simple db table design question
>> 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
CREATE TABLE Foobar
(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
![]() |
![]() |