From: | Philip Warner <pjw(at)rhyme(dot)com(dot)au> |
---|---|
To: | "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>, "Hackers" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Foreign Key Columns And Indices |
Date: | 2001-02-05 03:31:33 |
Message-ID: | 3.0.5.32.20010205143133.021ed6d0@mail.rhyme.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
At 11:01 5/02/01 +0800, Christopher Kings-Lynne wrote:
>Just a quick question, when a column of a table is defined to be a foreign
>key, is it implicitly indexed, or does one still need to explicitly CREATE
>INDEX?
The referenced columns must be either a PK or the set of columns in a
Unique constraint. As a result, then will have indexes. Not sure about the
referencing table - are there any NOTICES when you create an FK?
<Aside>
PGSQL implements PK/FK & Unique constraints by using indexes (and rules) at
the moment. There is no guarantee that this will always be the case - in
fact, one path to rationalizing the constraints system is to implement most
features as SQL CHECK constraints:
PK: Check( (Select Count(*) from Table Where PKCOLS=PKCOLS) = 1)
FK: Check( (Select Count(*) from PK_Table Where PKCOLS=FKCOLS) = 1)
etc.
This is something I would like to see discussed for 7.2.
</Aside>
----------------------------------------------------------------
Philip Warner | __---_____
Albatross Consulting Pty. Ltd. |----/ - \
(A.B.N. 75 008 659 498) | /(@) ______---_
Tel: (+61) 0500 83 82 81 | _________ \
Fax: (+61) 0500 83 82 82 | ___________ |
Http://www.rhyme.com.au | / \|
| --________--
PGP key available upon request, | /
and from pgp5.ai.mit.edu:11371 |/
From | Date | Subject | |
---|---|---|---|
Next Message | m w | 2001-02-05 03:37:25 | contrib |
Previous Message | Roderick A. Anderson | 2001-02-05 03:22:37 | Re: Foreign Key Columns And Indices |