Re: Primary key inheritance problem

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: Matthew M Davis <mmd(at)teledavis(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Primary key inheritance problem
Date: 2004-08-29 18:34:59
Message-ID: 1093804499.29613.361.camel@linda
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, 2004-08-29 at 18:07, Matthew M Davis wrote:
> On Sunday 29 August at 12:34pm, Oliver Elphick had this to say:
>
> > Primary and foreign key constraints are not inherited. This is a defect
> > in the current system.
>
> It almost seems like a FEATURE to me, since it creates a different and
> easy way to create one-to-many relationships. But I didn't use it,
> since the documentation says this is a Bad Thing that may be fixed
> some day. If the child table inherits the primary key constraint from
> the parent, why not just put it in the same table?

If you understand inheritance from the point of view of object-oriented
programming, you want to be able to have a hierarchy where the top level
has characteristics which are extended further down.

So all mammals are animals and all dogs are mammals, and all three
groups share common characteristics which are properties of the parent
class. But mammals have characteristics which are not applicable to all
animals and so are not appropriate to the parent class; similarly, dogs
have properties which are not common to all mammals.

Now one particular animal is either a mammal or it is not, and if it is,
it is either a dog or it is not. What it is governs which class it
belongs to in the hierarchy. Nevertheless, I may want to know about the
characteristics of animals without enquiring into the particular
characteristics of mammals; in that case an enquiry on the top-level of
the hierarchy is appropriate and will gather all information about all
animals. If I want to make a further enquiry about properties peculiar
to mammals, it is appropriate to start my enquiry at that level in the
hierarchy. However a particular animal can only be in one particular
class, therefore it would be preferable for the primary key to extend
over the whole hierarchy.

--
Oliver Elphick olly(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
========================================
"Preach the word; be instant in season, out of season;
reprove, rebuke, exhort with all longsuffering and
doctrine." II Timothy 4:2

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Hervé Piedvache 2004-08-29 18:59:39 [GENERAL] RSS Feeds are dead on Web site
Previous Message Guy Naor 2004-08-29 18:12:12 Representating a family tree