Re: inheritance

From: Jake Stride <nsuk(at)users(dot)sourceforge(dot)net>
To: Ben Clewett <B(dot)Clewett(at)roadrunner(dot)uk(dot)com>
Cc: PostgreSQL Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: inheritance
Date: 2003-07-09 17:10:47
Message-ID: 1057770645.1056.33.camel@tintagel.senokian
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Dmitry Tkach 2003-07-09 19:01:30 Re: inheritance
Previous Message Pablo Dejuan 2003-07-09 17:10:23 Re: inheritance