Re: Foreign keys and inheritance

From: brian <brian(at)zijn-digital(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Foreign keys and inheritance
Date: 2007-11-19 20:14:21
Message-ID: 4741EE9D.3060902@zijn-digital.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Kynn Jones wrote:
> I have two classes of objects, A and B, where B is just a special case
> of A. (I.e., to describe a B-type object I need to specify the same
> fields as for an A-type object, plus a whole bunch additional fields
> specific to B alone.) Furthermore, there's a third class T that is in
> a many-to-one relation with A (and hence also B) objects.
>
> The question is, what's the "best practice" for implementing this
> situation in PostgreSQL. My first idea was to define B as inheriting
> from A, which is OK, except that I have not figured out how to
> implement the reference from T. Is inheritance indeed the right tool
> for this problem, or should I use a different approach?
>

It seems that inheritance is precisely what you want.

WRT yout table T you should be able to join to B in the same way you
would join to A. But perhaps you should give an example of both B & T
(and maybe A).

brian

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2007-11-19 20:19:41 Re: Foreign keys and inheritance
Previous Message Jeff Davis 2007-11-19 19:56:42 Re: Foreign keys and inheritance