Re: ENUM type

From: "Jim C(dot) Nasby" <decibel(at)decibel(dot)org>
To: Merlin Moncure <merlin(dot)moncure(at)rcsonline(dot)com>
Cc: PostgreSQL advocacy <pgsql-advocacy(at)postgresql(dot)org>
Subject: Re: ENUM type
Date: 2005-07-27 17:37:32
Message-ID: 20050727173732.GT26758@decibel.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-advocacy

On Wed, Jul 27, 2005 at 08:45:53AM -0400, Merlin Moncure wrote:
> > > 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).
> >
> > Please go back through the original thread. The original comment was
> > regarding adding an enum type that actually made sense; ie: it stored
> an
> > int in the base table that referenced a parent table. The original
> > poster was arguing that enum didn't really buy anything over doing
> that
> > the manual method (create seperate table; fill that table with values;
> > create base table with RI, and finally, make sure that everything that
> > touches the base table can do mapping, or add a bunch of other stuff
> to
> > do the mapping automatically). My argument is that simply specifying
>
> You're right, I did jump on this (mostly off-topic) thread. Also, I was
> not aware that the enum did an id-id relationship internally.
> Regardless, on the surface enum is essentially a check constraint.
> Check constraints offer the same functionality and while marginally more
> verbose they are much more powerful and more standard to boot.
>
> Putting my advocacy hat on I'd rather highlight PostgreSQL's very well
> implemented constraint system. However, if enum was implemented as
> syntax sugar for a constraint in a similar way that serial is syntax
> sugar for the default value then I suppose it would not be a bad idea.

Keep in mind that my original point was to go after items that were the
biggest headache for migration from mysql to postgresql. Enum was just
an example I picked out of thin air.
--
Jim C. Nasby, Database Consultant decibel(at)decibel(dot)org
Give your computer some brain candy! www.distributed.net Team #1828

Windows: "Where do you want to go today?"
Linux: "Where do you want to go tomorrow?"
FreeBSD: "Are you guys coming, or what?"

In response to

Browse pgsql-advocacy by date

  From Date Subject
Next Message Jim C. Nasby 2005-07-27 17:40:34 Re: ENUM type
Previous Message Jim C. Nasby 2005-07-27 17:36:23 Re: [HACKERS] Enticing interns to PostgreSQL