Re: inheritance - Mailing list pgsql-novice

From Jake Stride
Subject Re: inheritance
Date
Msg-id 1057770645.1056.33.camel@tintagel.senokian
Whole thread Raw
In response to Re: inheritance  (Ben Clewett <B.Clewett@roadrunner.uk.com>)
Responses Re: inheritance
Re: inheritance
List pgsql-novice
On Wed, 2003-07-09 at 17:56, Ben Clewett wrote:
> PostgreSQL,
>
> I've been following with interest the discussions on Inheritance, as we
> are planning to use this.
>
> There may be alternate methods.  I understand that a view on a master
> table gives the same abilities.  Although I have to wonder if after
> multiple inheritance in both breadth and depth, whether the view method
> would suffer very large master table and excessive maintenance issues.
> But mainly the simplicity, and analogy to the OO techniques we are using
> in code design, make this attractive.  Looking specifically at
> transactional relations, which have many foreign keys and specific data
> for each instance of use.  Inheriting the parent relation for a new type
> of transaction as and when required, is appealing.
>
> I simply want to know whether it's a bug that the ancestor relations may
> have duplicate entries on its PK, or just an unfortunate side effect of
> inheritance?
>
> Thanks, Ben.
>

We use inheritence alonside OO techniques and it is very useful. The
duplicate keys is (I beleive) because of the way the relationship is
inherited using directed graphs.

The way that we have overcome the problem is so:

create table a (id bigserial, ...., primary key(id));

create table b (id bigserial, ..., primary key(id)) inherits (a);

This means that you will always have a unique key in the inherited table
as it 'replaces' the original id.

Does this answer the question or am I off the mark?

Jake


pgsql-novice by date:

Previous
From: Ben Clewett
Date:
Subject: Re: inheritance
Next
From: Pablo Dejuan
Date:
Subject: Re: inheritance