Re: are foreign keys realized as indexes?

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: are foreign keys realized as indexes?
Дата
Msg-id 20070508135408.GB17033@svana.org
обсуждение исходный текст
Ответ на Re: are foreign keys realized as indexes?  (Felix Kater <fkater@googlemail.com>)
Ответы Re: are foreign keys realized as indexes?  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: are foreign keys realized as indexes?  (Felix Kater <fkater@googlemail.com>)
Список pgsql-general
On Tue, May 08, 2007 at 02:14:54PM +0200, Felix Kater wrote:
> If I get you right:
>
> 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)?

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.

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?

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Вложения

В списке pgsql-general по дате отправления:

Предыдущее
От: Felix Kater
Дата:
Сообщение: pg_contraint: 'action code' ?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: pg_contraint: 'action code' ?