Re: table inheritance and foreign keys - Mailing list pgsql-general

From Reece Hart
Subject Re: table inheritance and foreign keys
Date
Msg-id 1053102193.5829.1022.camel@tallac
Whole thread Raw
In response to Re: table inheritance and foreign keys  (James Gregory <james@anchor.net.au>)
Responses Re: table inheritance and foreign keys
List pgsql-general
James-

Thanks for your advice.  I think I'll opt for the following approach
instead, but I'm interested to hear of any pitfalls you foresee.

Subtables (for which I wanted to use inherit) will instead contain only
the subtable-specific columns, and in addition contain a foreign key
into the parent table.  A view with insert, update, and delete rules can
emulate the appearance of a full subtable (ie, inherited and
subtable-specific columns).

The upside I see over triggers is that the referential integrity is
still on postgresql's back.  The downside is that I end up with more
tables and views to maintain and an extra join in many cases.

Again, thanks for your advice.  Do you see any reason that the above
sketch wouldn't work to emulate foreign keys into inherited tables?

-Reece

--
Reece Hart, Ph.D.                       rkh@gene.com, http://www.gene.com/
Genentech, Inc.                         650/225-6133 (voice), -5389 (fax)
Bioinformatics and Protein Engineering
1 DNA Way, MS-93                        http://www.in-machina.com/~reece/
South San Francisco, CA  94080-4990     reece@in-machina.com, GPG: 0x25EC91A0


pgsql-general by date:

Previous
From: Dennis Gearon
Date:
Subject: stupid patent
Next
From: Kathy Zhu
Date:
Subject: Re: create db with -E