Re: inheritance is madness
От | Oliver Elphick |
---|---|
Тема | Re: inheritance is madness |
Дата | |
Msg-id | 1190364337.7954.178.camel@linda.lfix.co.uk обсуждение исходный текст |
Ответ на | inheritance is madness ("T W" <list@traviswellman.com>) |
Список | 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 по дате отправления: