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 B4CC1529D0 for ; Wed, 29 Jun 2005 10:31:51 -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 57803-10 for ; Wed, 29 Jun 2005 13:31:46 +0000 (GMT) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id 08E4952992 for ; Wed, 29 Jun 2005 10:31:44 -0300 (ADT) Received: from 216-154-13-177.dsl.look.ca (216-154-13-177.dsl.look.ca [216.154.13.177]) by tht.net (Postfix) with ESMTP id 8184B76B83; Wed, 29 Jun 2005 09:31:50 -0400 (EDT) Subject: Re: ENUM like data type From: Rod Taylor To: =?ISO-8859-1?Q?Mart=EDn_Marqu=E9s?= Cc: pgsql-sql@postgresql.org In-Reply-To: <200506291021.10986.martin@bugs.unl.edu.ar> References: <200506291021.10986.martin@bugs.unl.edu.ar> Content-Type: text/plain; charset=ISO-8859-1 Date: Wed, 29 Jun 2005 09:28:49 -0400 Message-Id: <1120051729.39304.113.camel@home> Mime-Version: 1.0 X-Mailer: Evolution 2.2.3 FreeBSD GNOME Team Port Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.012 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/357 X-Sequence-Number: 21958 On Wed, 2005-06-29 at 10:21 -0300, Martín Marqués wrote: > El Mié 29 Jun 2005 09:40, KÖPFERL Robert escribió: > > > > | > > |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 disagree. In several relations (views of the world) one needs to have a > > hand full of well defined values while > > integers or bools are not appropriate and strings are too free form. > > For example male female or true and false. Whilst the second has a well > > known type, other things like a telephone number type don't have such type. > > So a new one should be created instead of (varchar/ xy between 4 and 8). One > > might argue that new 1:n relations with integrity shall be established but > > this is in my eyes overkill for a constant number of values. > > Also think of schema export without data. These values are part of the > > schema data but not the schema itself which in this sense is wrong > > Please, most of this can be done with CHECK(...). Indeed. A CHECK constraint on a DOMAIN is an ENUM plus some. --