From: | Gregory Stark <stark(at)enterprisedb(dot)com> |
---|---|
To: | "Richard Broersma" <richard(dot)broersma(at)gmail(dot)com> |
Cc: | <rafal(at)zorro(dot)isa-geek(dot)com>, "pgsql general" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: foreign key restrictions |
Date: | 2008-08-10 14:36:58 |
Message-ID: | 87prohc4xh.fsf@oxford.xeocode.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
"Richard Broersma" <richard(dot)broersma(at)gmail(dot)com> writes:
> On Sun, Aug 10, 2008 at 1:15 AM, <rafal(at)zorro(dot)isa-geek(dot)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!
From | Date | Subject | |
---|---|---|---|
Next Message | Martijn van Oosterhout | 2008-08-10 14:39:36 | Re: foreign key restrictions |
Previous Message | Richard Broersma | 2008-08-10 14:10:10 | Re: foreign key restrictions |