Constraint Problem - Mailing list pgsql-general

From Ron St-Pierre
Subject Constraint Problem
Date
Msg-id 3DC40D2D.3070409@syscor.com
Whole thread Raw
Responses Re: Constraint Problem  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
I want to create a constraint that's a little different, but don't know
how to implement it. I have an intermediate table with a compound PK and
a boolean 'ysnDefault' column:

   comanyID     INTEGER REFERENCES companies,
   assocationID INTEGER REFERENCES associations,
   ysnDefault     BOOLEAN

I just want to constrain the ysnDefault field to only allow one TRUE
value for any companyID/associationID pair, with no restrictions on the
number of FALSES.

At first glance I thought it would be easy, but I can't see how to do
it. Any suggestions?

Thanks
Ron



pgsql-general by date:

Previous
From: Will Trillich
Date:
Subject: Re: Perl and Postgres
Next
From: Tom Lane
Date:
Subject: Re: Constraint Problem