Re: enums

From: "Merlin Moncure" <merlin(dot)moncure(at)rcsonline(dot)com>
To: "Andrew Dunstan" <andrew(at)dunslane(dot)net>
Cc: "PostgreSQL-development" <pgsql-hackers(at)postgresql(dot)org>, "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
Subject: Re: enums
Date: 2005-10-28 12:41:36
Message-ID: 6EE64EF3AB31D5448D0007DD34EEB3417DD6F3@Herge.rcsinc.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrew wrote:
> > Jim C. Nasby wrote:
> >Personally, I don't see why enum can't just be syntactic sugar on top
of
> >a side-table of values and a foreign key. And I guess a view to hide
the
> >internals from normal viewing. That would certainly allow the most
> >flexibility, although it probably wouldn't perform as well as what
you
> >wrote.
> The other issue is ease of use.
>
> We used lookup tables in bugzilla when it was converted to work with
> Postgres. But many users will find having to do that annoying, to say
> the least. I think there's a very good case for providing true enums.
> There is a technical part of the puzzle I can't quite see yet, though
:-)

Hm, I agree with Jim here. IMO, enum=FK syntax sugar...enum should be a
lookup table with two fields, one being enum value which is the PK, and
two being the sequencing value.

I think many people are opposed to this approach because they assume
this relationship is via ID-ID link (IIRC this is what mysql does under
the hood). In fact, the enum table's only purpose is for constraint
checking, not to lookup the value (there is no 'id').

I like the way sequences work. They are first class SQL objects
although they are normally accessed via helper functions. Enums could
be the same. Dependancy could be preserved to the creating table or not
(I prefer not).

Merlin

Browse pgsql-hackers by date

  From Date Subject
Next Message Kenneth Marshall 2005-10-28 13:31:46 Re: [ANNOUNCE] PostgreSQL 8.1 Beta 4
Previous Message Andrew Dunstan 2005-10-28 12:39:59 Re: enums