Re: Foreign Key Columns And Indices - Mailing list pgsql-hackers

From Philip Warner
Subject Re: Foreign Key Columns And Indices
Date
Msg-id 3.0.5.32.20010205143133.021ed6d0@mail.rhyme.com.au
Whole thread Raw
In response to Foreign Key Columns And Indices  ("Christopher Kings-Lynne" <chriskl@familyhealth.com.au>)
Responses Re: Foreign Key Columns And Indices  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List 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   |/


pgsql-hackers by date:

Previous
From: "Christopher Kings-Lynne"
Date:
Subject: Comparison operators for bytea
Next
From: "Roderick A. Anderson"
Date:
Subject: Re: Foreign Key Columns And Indices