Re: Constrain duplicate patterns

From: joseph speigle <joe(dot)speigle(at)jklh(dot)us>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Constrain duplicate patterns
Date: 2004-02-01 09:40:56
Message-ID: 20040201094056.GA7372@www.sirfsup.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I found a way to do it like this

create table parts (part_id int, description character varying(33) constraint part_id unique , primary key (part_id));
create table vendors (vendor_id int, description character varying(33) constraint vendor_id unique, primary key (vendor_id) );
CREATE TABLE parts_vendors ( part_id integer unique references parts (part_id), vendor_id integer unique references vendors (vendor_id));

On Sun, Feb 01, 2004 at 08:11:50PM +1100, Russell Shaw wrote:
> Russell Shaw wrote:
> >Hi,
> >
> >Is there a way to make postgresql report an error if when
> >inserting data, a multiple-column combination is duplicated?
> >
> >CREATE TABLE parts_vendors (
> > part_id integer references parts (part_id),
> > vendor_id integer references vendors (vendor_id),
> > ...
> >)
> >
> >part_id vendor_id
> >------------------
> >1 3
> >2 5 <--+
> >7 9 |
> >2 5 <--+-- duplicate pattern
> >...
> >
>
> Oops, i can just do a select on the various columns
> to detect this...
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)

--
joe speigle

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Russell Shaw 2004-02-01 09:46:46 Re: Constrain duplicate patterns
Previous Message Michael Glaesemann 2004-02-01 09:21:54 Re: Constrain duplicate patterns