From: | Martín Marqués <martin(at)bugs(dot)unl(dot)edu(dot)ar> |
---|---|
To: | PFC <lists(at)boutiquenumerique(dot)com> |
Cc: | "Mike Rylander" <mrylander(at)gmail(dot)com>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: ENUM like data type |
Date: | 2005-06-28 18:22:25 |
Message-ID: | 200506281522.25124.martin@bugs.unl.edu.ar |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-sql |
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.
--
select 'mmarques' || '@' || 'unl.edu.ar' AS email;
---------------------------------------------------------
Martín Marqués | Programador, DBA
Centro de Telemática | Administrador
Universidad Nacional
del Litoral
---------------------------------------------------------
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2005-06-28 18:28:11 | Re: Problem with dblink regression test |
Previous Message | Josh Berkus | 2005-06-28 18:11:43 | Re: commit_delay, siblings |
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Marlowe | 2005-06-28 18:46:18 | Re: ENUM like data type |
Previous Message | Scott Marlowe | 2005-06-28 17:47:22 | Re: Unique primary index? |