Re: are foreign keys realized as indexes? - Mailing list pgsql-general

From Raymond O'Donnell
Subject Re: are foreign keys realized as indexes?
Date
Msg-id 46406C64.8050401@iol.ie
Whole thread Raw
In response to Re: are foreign keys realized as indexes?  (Felix Kater <fkater@googlemail.com>)
List pgsql-general
On 08/05/2007 13:14, Felix Kater wrote:

> There is *no complete* substitute for foreign keys by using *indexes*
> since I'd loose the referencial integrity (whereas for unique contraints
> there *is* a full replacement using indexes)?

Here's my understanding....an index is just that (an index) and no more
- it tells PostgreSQL where to look in a table to find a particular row
or set of rows. A foreign key, on the other hand, ensures that
referential integrity is enforced: it enforces the relationship between
rows in a table which refer to rows in another table, depending on how
the foreign key was specified in the first place (cf. the "ON UPDATE...
ON DELETE... etc. clauses).

When you have a foreign key, you can put an index on the foreign key
column in the "child" table for performance reasons, but this *isn't*
the same as the foreign key.

I don't know about the equivalence of unique constraints and indices -
others on the list can answer that.

Ray.

---------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@iol.ie
---------------------------------------------------------------

pgsql-general by date:

Previous
From: "Anoo Pillai"
Date:
Subject: Time of previous REINDEX execution..
Next
From: Felix Kater
Date:
Subject: Re: are foreign keys realized as indexes?