Re: Creating a table: UNIQUE constraint matching given keys for referenced table "xy" not found

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Jason Hihn <jhihn(at)paytimepayroll(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Creating a table: UNIQUE constraint matching given keys for referenced table "xy" not found
Date: 2003-08-07 14:27:24
Message-ID: 20030807142724.GA5549@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Thu, Aug 07, 2003 at 10:11:54 -0400,
Jason Hihn <jhihn(at)paytimepayroll(dot)com> wrote:
>
> Appendix:
> 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));
> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'xyz_pkey'
> for table 'xyz'
> NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY
> check(s)
> ERROR: UNIQUE constraint matching given keys for referenced table "xy" not
> found

You either need to create a unique index for x and for y for table xy
or you need to use the foreign key clause to use (x,y) as a reference
to table xy.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2003-08-07 14:41:39 Re: Creating a table: UNIQUE constraint matching given keys for referenced table "xy" not found
Previous Message Jason Hihn 2003-08-07 14:11:54 Creating a table: UNIQUE constraint matching given keys for referenced table "xy" not found