Re: inheritance is madness - Mailing list pgsql-novice

From Oliver Elphick
Subject Re: inheritance is madness
Date
Msg-id 1190364337.7954.178.camel@linda.lfix.co.uk
Whole thread Raw
In response to inheritance is madness  ("T W" <list@traviswellman.com>)
List pgsql-novice
On Thu, 2007-09-20 at 22:11 -0700, T W wrote:
> Hello Gurus
>
> I'm very surprised at the fact that primary keys are not inherited.
> When trying to make foreign keys from a third table to a parent table,
> the child table's data is not counted [I assume] due to this fact,
> even if the child table has the same primary key. This is really
> weird, considering a select from the parent table will return the
> child table's data. Does anyone know of a hack to get this behavior to
> change, and allow the third table to use a foreign key that references
> child table data?

This is a very long-standing deficiency in inheritance.  Primary keys
and foreign keys are valid only for a single table, not for an
inheritance tree.

One solution is to maintain an index table which is updated by triggers
fired after an update to any of the tables in the inheritance tree.  Do
your foreign key relationships to that index table.  The trigger could
reject any duplicated keys in the tree itself.

--
Oliver Elphick                                          olly@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA  92C8 39E7 280E 3631 3F0E  1EC0 5664 7A2F A543 10EA
                 ========================================
   Do you want to know God?   http://www.lfix.co.uk/knowing_god.html


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


pgsql-novice by date:

Previous
From: "T W"
Date:
Subject: inheritance is madness
Next
From: Derrick Betts
Date:
Subject: numericOnly trigger