multi column foreign key for implicitly unique columns
От | Markus Bertheau |
---|---|
Тема | multi column foreign key for implicitly unique columns |
Дата | |
Msg-id | 1092734724.2627.4.camel@dicaprio.akademie1.de обсуждение исходный текст |
Ответы |
Re: multi column foreign key for implicitly unique columns
Re: multi column foreign key for implicitly unique columns |
Список | pgsql-sql |
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>
В списке pgsql-sql по дате отправления: