Hi,
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.
Example:
CREATE TABLE p ( name TEXT PRIMARY KEY, "type" TEXT
);
CREATE TABLE f ( name TEXT, "type" TEXT, 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?
Thanks
--
Markus Bertheau <twanger@bluetwanger.de>