Re: ENUM type - Mailing list pgsql-advocacy

From Merlin Moncure
Subject Re: ENUM type
Date
Msg-id 6EE64EF3AB31D5448D0007DD34EEB3415C2EB2@Herge.rcsinc.local
Whole thread Raw
In response to ENUM type  ("Jim C. Nasby" <decibel@decibel.org>)
Responses Re: ENUM type
MySQL to PostgreSQL, was ENUM type
List pgsql-advocacy
Jim C Nasby:
> OK, but compare the amount of work you just described to the
simplicity
> of using an enum. Enum is much easier and simpler for a developer. Of
> course in most cases the MySQL way of doing it is (as has been
> mentioned) stupid, but done in the normal, normalized way it would
> remove a fair amount of additional work on the part of a developer:
>
> - no need to manually define seperate table
create table color (color text);
insert into color values ('red'); -- etc

> - no need to define RI
references color

> - no need to manually map between ID and real values (though of course
if you use color as p-key this is unnecessary

>   we should make it easy to get the ID too)
again, in this case the color should be the id and using a surrogate key
is poor design.  If that's too much typing you have the option of a
check constraint which is superior to enum in just about every way,
particularly if encapsulated into a domain (although inferior to RI
solution, IMO).

Merlin

pgsql-advocacy by date:

Previous
From: Josh Berkus
Date:
Subject: Re: SQL/PSM for 8.2 will offer ANSI/ISO, MySQL, and DB2 Compatibility
Next
From: "Jim C. Nasby"
Date:
Subject: Re: [HACKERS] Enticing interns to PostgreSQL