Re: are foreign keys realized as indexes?

From: Felix Kater <fkater(at)googlemail(dot)com>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: are foreign keys realized as indexes?
Date: 2007-05-09 09:40:38
Message-ID: 20070509114038.22c2ad8d.fkater@googlemail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 8 May 2007 15:54:08 +0200
Martijn van Oosterhout <kleptog(at)svana(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message anhtin 2007-05-09 09:48:43 Re: backup and restore
Previous Message Felix Kater 2007-05-09 09:34:01 Re: pg_contraint: 'action code' ?