Thread: foreign key support for inheritance

foreign key support for inheritance

From
Floyd Shackelford
Date:
i would like to suggest the following modification to the foreign key
syntax (and underlying implementation) to support table inheritance:

  alter table [only] foo add foreign key (a_field) references [only] bar
(another_field) on delete restrict;

the only changes from the current syntax are the "[only]" modifiers
(pardon the pun) to the source and target tables. this modifier would
behave the same was as the "[only]" modifier in the "from [only]
foo_table" clause.

i really, really need foreign keys to support table inheritance. right
now, i have a script i run that generates 1000's of alter table commands
because i have to take into account not only the target table's
inheritance but the source table's inheritance too and all the
combinations of inheriting tables between them.

postgresql developers: please treat this as an enhancement request. i
think this would be a very popular enhancement.

--

Soli Deo gloria,

Floyd Shackelford


Re: foreign key support for inheritance

From
Richard Huxton
Date:
Floyd Shackelford wrote:
>
> i would like to suggest the following modification to the foreign key
> syntax (and underlying implementation) to support table inheritance:

The place to look for all these things is:
  http://www.postgresql.org/docs/faqs.TODO.html

--
   Richard Huxton
   Archonet Ltd