Re: ENUM like data type - Mailing list pgsql-sql

From Scott Marlowe
Subject Re: ENUM like data type
Date
Msg-id 1119984378.8208.114.camel@state.g2switchworks.com
Whole thread Raw
In response to Re: ENUM like data type  (Martín Marqués <martin@bugs.unl.edu.ar>)
List pgsql-sql
On Tue, 2005-06-28 at 13:22, Martín Marqués wrote:
> El Mar 28 Jun 2005 13:58, PFC escribió:
> >
> > >> Here is where I get uncertain as to if this is possible. My idea is to
> > >> create a pseudo type that triggers the creation of it's lookup tables
> > >> the same way the SERIAL type triggers creation of a sequence and returns
> > >> an int with the right default value.
> >
> >     Personnally I use one table which has columns (domain, name) and which
> > stores all enum values for all different enums.
> >     I have then CHECK( is_in_domain( column, 'domain_name' )) which is a
> > simple function which checks existence of the value in this domain (SELECT
> > 1 FROM domains WHERE domain=$2 AND name=$1 LIMIT 1) for instance.
> >     You can also use integers.
>
> I personally think that the ENUM data type is for databases that are not well
> designed. So, if you see the need for ENUM, that means you need to re-think
> your data design.

I would generally agree, however, a pseudo type like serial that created
the properly fk'd table with all the options in it would be quite nice
to have.



pgsql-sql by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: Unique primary index?
Next
From: Nick Johnson
Date:
Subject: Re: ENUM like data type