From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Rod Taylor <rbt(at)rbt(dot)ca> |
Cc: | Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, Antti Haapala <antti(dot)haapala(at)iki(dot)fi>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Multicolumn foreign keys need useless unique indices? |
Date: | 2002-09-13 14:00:44 |
Message-ID: | 18437.1031925644@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Rod Taylor <rbt(at)rbt(dot)ca> writes:
> On Fri, 2002-09-13 at 04:27, Christopher Kings-Lynne wrote:
>> Hmmm - thinking about it, I don't see why postgres would need the entire
>> thing to be unique...can't think of a reason at the moment. Stephen?
> If it's not all unique, you cannot be guaranteed there is a single row
> with those values in the referenced table.
Right. The single-column unique constraint guarantees at most one
match, but it isn't helpful for checking if there's at least one match.
The spec obviously intends that the index supporting the unique
constraint be useful for verifying the existence of a match.
I read this in SQL92:
a) If the <referenced table and columns> specifies a <reference
column list>, then the set of column names of that <refer-
ence column list> shall be equal to the set of column names
in the unique columns of a unique constraint of the refer-
enced table.
It says "equal to", not "superset of". So we are behaving per spec.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Stephan Szabo | 2002-09-13 14:50:19 | Re: Multicolumn foreign keys need useless unique indices? |
Previous Message | Jim Buttafuoco | 2002-09-13 13:47:28 | Re: Query having issues... |