Re: Creating a table: UNIQUE constraint matching given keys - Mailing list pgsql-novice

From Jason Hihn
Subject Re: Creating a table: UNIQUE constraint matching given keys
Date
Msg-id NGBBLHANMLKMHPDGJGAPMEEECMAA.jhihn@paytimepayroll.com
Whole thread Raw
In response to Re: Creating a table: UNIQUE constraint matching given keys for referenced table "xy" not found  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-novice
*smacks palm against forehead in a I-feel-like-a-dolt manner*
Thank you Bruno and Tom!

> -----Original Message-----
> From: pgsql-novice-owner@postgresql.org
> [mailto:pgsql-novice-owner@postgresql.org]On Behalf Of Tom Lane
> Sent: Thursday, August 07, 2003 10:42 AM
> To: Jason Hihn
> Cc: pgsql-novice@postgresql.org
> Subject: Re: [NOVICE] Creating a table: UNIQUE constraint matching given
> keys for referenced table "xy" not found
>
>
> Jason Hihn <jhihn@paytimepayroll.com> writes:
> > create table xy( x integer not null, y integer not null,
> primary key (x,y));
> > create table xyz( x integer not null references xy(x), y
> integer not null
> > references xy(y), z integer not null, primary key (x,y,z));
> > ERROR:  UNIQUE constraint matching given keys for referenced
> table "xy" not
> > found
>
> I think what you want is a two-column foreign key reference:
>
> create table xyz( x integer not null, y integer not null, z
> integer not null,
> primary key (x,y,z),
> foreign key (x,y) references xy(x,y));
>
>             regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>

pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: Creating a table: UNIQUE constraint matching given keys for referenced table "xy" not found
Next
From: Josh Berkus
Date:
Subject: Re: database design