Re: Constraint Problem - Mailing list pgsql-general

From Alvaro Herrera
Subject Re: Constraint Problem
Date
Msg-id 20031104190317.GA11253@dcc.uchile.cl
Whole thread Raw
In response to Re: Constraint Problem  (Ron St-Pierre <rstpierre@syscor.com>)
List pgsql-general
On Tue, Nov 04, 2003 at 10:25:03AM -0800, Ron St-Pierre wrote:
> Stephan Szabo wrote:

>        CREATE TABLE compass (
>          compassnID SERIAL PRIMARY KEY,
>          company int4 NOT NULL REFERENCES tblcompanies (cntcompanyid),
>          association int4 NOT NULL REFERENCES tblassociations
> (cntasncode),
>          ysnDefault bool
>        );
>
>        CREATE UNIQUE INDEX compassoc_default_ind ON compass
> (company,association) WHERE ysnDefault;
>
> And as you can see company 23590 has three default associations. Any
> ideas on how I can get around this?

Well, shouldn't the index be

CREATE UNIQUE INDEX compassoc_default_ind ON compass (company) WHERE ysnDefault;

?

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
Essentially, you're proposing Kevlar shoes as a solution for the problem
that you want to walk around carrying a loaded gun aimed at your foot.
(Tom Lane)

pgsql-general by date:

Previous
From: Martin Marques
Date:
Subject: Re: PostgreSQL v7.4 Release Candidate 1
Next
From: Greg Stark
Date:
Subject: Re: Constraint Problem