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

From Felix Kater
Subject Re: are foreign keys realized as indexes?
Date
Msg-id 20070509114038.22c2ad8d.fkater@googlemail.com
Whole thread Raw
In response to Re: are foreign keys realized as indexes?  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: are foreign keys realized as indexes?
List pgsql-general
On Tue, 8 May 2007 15:54:08 +0200
Martijn van Oosterhout <kleptog@svana.org> wrote:

> A unique index is not a "substitute" for a unique constraint, they're
> exactly the same thing. If you drop your constraint and create a
> unique index, you're back where you started. You neither added nor
> removed anything.

Yes. For this reason I didn't have to implement *both* 'unique
constraints' *and* 'unique indices' in my pg interface.


> On a certain level foreign keys are just triggers, specially coded to
> do the work. Yes, you could write your own triggers to do exactly the
> same thing, but why bother, when someone has written them for you and
> made nice syntax to use them?

My question simply was if I could save coding time... like with 'unique
constaints' and 'indeces', see above. However, for what I have learned
now, 'foreign keys' can *not* be substituted by indeces, so I have to
implement them.

Thanks again.

Felix

pgsql-general by date:

Previous
From: Felix Kater
Date:
Subject: Re: pg_contraint: 'action code' ?
Next
From: anhtin
Date:
Subject: Re: backup and restore