Re: foreign key restrictions

Поиск
Список
Период
Сортировка
От Gregory Stark
Тема Re: foreign key restrictions
Дата
Msg-id 87prohc4xh.fsf@oxford.xeocode.com
обсуждение исходный текст
Ответ на Re: foreign key restrictions  ("Richard Broersma" <richard.broersma@gmail.com>)
Ответы Re: foreign key restrictions  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
"Richard Broersma" <richard.broersma@gmail.com> writes:

> On Sun, Aug 10, 2008 at 1:15 AM,  <rafal@zorro.isa-geek.com> wrote:
>
>> Since table TWO has a unique constraint on column ID, the (ID, OFONE) pair
>> will also be unique, obviously.
>
> This statement is not completely true.  The only part of the pair that
> is true is ID.  Also there is not unique constraint on the pare.  So
> there is no way to PG to build a foreing key on the pair.

Uhm, afaics he's right. if ID is unique not null then <ID, OFONE> also has to
be unique. That is, there could be duplicate values of OFONE but they'll all
have different values of ID anyways.

I'm not sure if there's a fundamental reason why there has to be an index that
exactly matches the foreign key or not -- offhand I can't think of one.

--
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com
  Get trained by Bruce Momjian - ask me about EnterpriseDB's PostgreSQL training!

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

Предыдущее
От: "Richard Broersma"
Дата:
Сообщение: Re: foreign key restrictions
Следующее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: foreign key restrictions