From: Josh Berkus <josh@agliodbs.com>
To: Thrasher <thrasher@fibers.upc.es>
Cc: pgsql-sql@postgresql.org
Subject: Re: Unique constraint over null values
Date: Mon, 30 Sep 2002 10:50:05 -0700
Message-ID: <200209301050.05473.josh@agliodbs.com> (raw)
In-Reply-To: <3D988CE6.5070505@fibers.upc.es>
References: <3D98884F.9070704@fibers.upc.es>
<200209301033.22795.josh@agliodbs.com>
<3D988CE6.5070505@fibers.upc.es>
Thrasher,
> I think I'll follow your advice, as this is the method that I had in my
> pocket to use if I had no response. I tried with TRIM and other
> functions in the CHECK constraint, but I guess that I cannot use
> functions over a check field.
>
> It surprised me, but anyway, I'll do that.
>
> Thanks a lot for your prompt reply
No problem. You should also add a second constraint:
CHECK ((type = 'x' AND data2 <> 'blank value') OR (type = 'y' AND data2 =
'blank value'))
To enforce your other criterion.
Keeop in mind that depending on the rest of your data structure, there are
probably 8 different ways to approach this problem. I'd reccomend, in fact,
a quick reading of Pascal's "Practical Issues in Database Management" on
normalization to see the different table structures that might work for you.
--
-Josh Berkus
Aglio Database Solutions
San Francisco
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: josh@agliodbs.com, thrasher@fibers.upc.es
Subject: Re: Unique constraint over null values
In-Reply-To: <200209301050.05473.josh@agliodbs.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox