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 |/