X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C059D529F0 for ; Tue, 28 Jun 2005 15:17:57 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 12285-09 for ; Tue, 28 Jun 2005 18:17:49 +0000 (GMT) Received: from n7.gigared.com (smtp1.gigared.com [200.68.216.7]) by svr1.postgresql.org (Postfix) with ESMTP id E85C5528B7 for ; Tue, 28 Jun 2005 15:17:48 -0300 (ADT) Received: from [10.41.138.237] (unknown [10.41.138.237]) by n7.gigared.com (Postfix) with ESMTP id DE3C186E7D; Tue, 28 Jun 2005 15:17:39 -0300 (GMT) From: =?iso-8859-15?q?Mart=EDn_Marqu=E9s?= To: PFC Subject: Re: ENUM like data type Date: Tue, 28 Jun 2005 15:22:25 -0300 User-Agent: KMail/1.7.1 Cc: "Mike Rylander" , pgsql-sql@postgresql.org References: <11bgc1oblfasq3d@corp.supernews.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200506281522.25124.martin@bugs.unl.edu.ar> X-Gigared-MailScanner-Information: MailScanner: Found to be clean X-MailScanner-From: martin@bugs.unl.edu.ar X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.636 tagged_above=0 required=5 tests=INVALID_TZ_GMT X-Spam-Level: X-Archive-Number: 200506/341 X-Sequence-Number: 21942 El Mar 28 Jun 2005 13:58, PFC escribi=F3: >=20 > >> 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 retur= ns > >> an int with the right default value. >=20 > Personnally I use one table which has columns (domain, name) and which = =20 > stores all enum values for all different enums. > I have then CHECK( is_in_domain( column, 'domain_name' )) which is a =20 > simple function which checks existence of the value in this domain (SELEC= T =20 > 1 FROM domains WHERE domain=3D$2 AND name=3D$1 LIMIT 1) for instance. > You can also use integers. I personally think that the ENUM data type is for databases that are not we= ll=20 designed. So, if you see the need for ENUM, that means you need to re-think= =20 your data design. =2D-=20 select 'mmarques' || '@' || 'unl.edu.ar' AS email; =2D-------------------------------------------------------- Mart=EDn Marqu=E9s | Programador, DBA Centro de Telem=E1tica | Administrador Universidad Nacional del Litoral =2D--------------------------------------------------------