From: | Markus Schaber <schabi(at)logix-tt(dot)com> |
---|---|
To: | Andreas Joseph Krogh <andreak(at)officenet(dot)no> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Constraint question |
Date: | 2006-05-18 16:38:25 |
Message-ID: | 446CA301.20305@logix-tt.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi, Andreas,
Andreas Joseph Krogh wrote:
> create table onp_crm_businessfield_company(
> businessfield_id integer not null references onp_crm_businessfield(id),
> company_id integer not null references onp_crm_relation(id),
> is_preferred boolean,
> UNIQUE(businessfield_id, company_id)
> );
> I want a constraint on "is_preffered" so that it's only allowed to be set once
> pr. businessfield_id pr. company so that only one businessfield can be
> preferred for a company. Does anyone have an idea how to enforce this?
CREATE UNIQUE INDEX foo ON onp_crm_businessfield_company(company_id)
WHERE is_prefferred;
HTH,
Markus
--
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf. | Software Development GIS
Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org
From | Date | Subject | |
---|---|---|---|
Next Message | Guillaume Lelarge | 2006-05-18 16:54:46 | Re: Add column and specify the column position in a table |
Previous Message | Andrew Sullivan | 2006-05-18 15:58:29 | Re: Add column and specify the column position in a table |