Search Postgresql Archives

Re: are foreign keys realized as indexes?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx
---------------------------------------------------------------


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux