PostgreSQL doesn't allow the creation of a foreign key to a combination
of fields that has got no dedicated unique key but is unique nonetheless
because a subset of the combination of fields has a unique constraint.
CREATE TABLE p (
name TEXT PRIMARY KEY,
CREATE TABLE f (
FOREIGN KEY(name, "type") REFERENCES p(name, "type")
ERROR: there is no unique constraint matching given keys for referenced table "p"
Is this on purpose? I think the foreign key should be allowed. Creating
an extra unique key only has a negative impact on performance, right?
Markus Bertheau <twanger(at)bluetwanger(dot)de>
pgsql-sql by date
|Next:||From: Oliver Elphick||Date: 2004-08-17 09:39:36|
|Subject: Re: multi column foreign key for implicitly unique columns|
|Previous:||From: Theo Galanakis||Date: 2004-08-17 02:47:12|
|Subject: Re: CROSS-TAB query help? I have read it cant be done in on|