Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E9108476540 for ; Mon, 30 Sep 2002 13:48:11 -0400 (EDT) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 576C84764C3 for ; Mon, 30 Sep 2002 13:48:11 -0400 (EDT) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 3.5.9) with ESMTP id 1734753; Mon, 30 Sep 2002 10:48:34 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Thrasher Subject: Re: Unique constraint over null values Date: Mon, 30 Sep 2002 10:50:05 -0700 X-Mailer: KMail [version 1.4] References: <3D98884F.9070704@fibers.upc.es> <200209301033.22795.josh@agliodbs.com> <3D988CE6.5070505@fibers.upc.es> In-Reply-To: <3D988CE6.5070505@fibers.upc.es> Cc: pgsql-sql@postgresql.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200209301050.05473.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/433 X-Sequence-Number: 9710 Thrasher, > I think I'll follow your advice, as this is the method that I had in my= =20 > pocket to use if I had no response. I tried with TRIM and other=20 > functions in the CHECK constraint, but I guess that I cannot use=20 > functions over a check field. >=20 > It surprised me, but anyway, I'll do that. >=20 > Thanks a lot for your prompt reply No problem. You should also add a second constraint:=20 CHECK ((type =3D 'x' AND data2 <> 'blank value') OR (type =3D 'y' AND data2= =3D=20 'blank value')) To enforce your other criterion.=20=20 Keeop in mind that depending on the rest of your data structure, there are= =20 probably 8 different ways to approach this problem. I'd reccomend, in fact= ,=20 a quick reading of Pascal's "Practical Issues in Database Management" on=20 normalization to see the different table structures that might work for you. --=20 -Josh Berkus Aglio Database Solutions San Francisco