Re: Using a serial primary key as a foreign key in a second table

Поиск
Список
Период
Сортировка
От Richard Broersma Jr
Тема Re: Using a serial primary key as a foreign key in a second table
Дата
Msg-id 610820.38154.qm@web31813.mail.mud.yahoo.com
обсуждение исходный текст
Ответ на Re: Using a serial primary key as a foreign key in a second table  (Sean Davis <sdavis2@mail.nih.gov>)
Список pgsql-novice
> Actually, your explanation of the problem is very succinct.  Postgresql offers
> a direct solution to situations like these.  See here:
>
> http://www.postgresql.org/docs/8.2/interactive/ddl-inherit.html
>
> Isn't postgresql an AWESOME product!

Not arguments here, but there is one point of caution with postgresql's table inheritance that
should be considered in during schema design.  You cannot use the parent's tables primary key as a
foreign key in other parts of the schema, since the parent table does not >actually< have records
inserted into the child tables.

I have worked out an inheritance solution that does allow this just by using regular tables linked
with foreign keys.  To handle simultaneous insertion and updates across an entire branch of the
hierarchy I used a view made updatable using the rule system.  For deletes I just create the child
tables using cascade deletes.

The advantage using postgresql's tables inheritance is that it is quite easy to set up and it
works very well.  The solution I am using requires alot more planning and setup. :o(

If any are interested I can provide more details on how this is accomplished.

Regards,

Richard Broersma Jr.

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

Предыдущее
От: Sean Davis
Дата:
Сообщение: Re: Using a serial primary key as a foreign key in a second table
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: Using a serial primary key as a foreign key in a second table