[Fwd: Re: [SQL] multi column foreign key for implicitly unique columns]

Поиск
Список
Период
Сортировка
От Markus Bertheau
Тема [Fwd: Re: [SQL] multi column foreign key for implicitly unique columns]
Дата
Msg-id 1092737313.2627.14.camel@dicaprio.akademie1.de
обсуждение исходный текст
Список pgsql-hackers
Hi hackers,

can this be made a TODO?

Thanks

--
Markus Bertheau <twanger@bluetwanger.de>
Markus Bertheau wrote:
> 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.
[snip example]
> 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?

As you say, the uniqueness is guaranteed so there's no good reason why
it couldn't be made to work. It's probably more of an implementation
issue. Unique constraints are implemented with an index, so I'm guessing
the FK code assumes there is an index there to check against.

--
   Richard Huxton
   Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

               http://archives.postgresql.org

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Richard van den Berg
Дата:
Сообщение: Added schema selection to pg_restore
Следующее
От: Erwin Moller
Дата:
Сообщение: Re: listing triggers