Re: Primary key inheritance problem

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: Bruno Baguette <pgsql-ml(at)baguette(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Primary key inheritance problem
Date: 2004-08-29 16:34:08
Message-ID: 1093797247.29613.347.camel@linda
Views: Raw Message | Whole Thread | Download mbox
Lists: pgsql-general

On Fri, 2004-08-27 at 11:58, Bruno Baguette wrote:
> Hello,
> I've a strange problem with inheritance on PostgreSQL 7.4.1. It seems
> like tables don't inherits the primary key of the 'mother' table.
> The error I get is :
> ERROR: there is no unique constraint matching given keys for referenced
> table "child_foo"

Primary and foreign key constraints are not inherited. This is a defect
in the current system.

> What can I do to solve that problem ?

Create an index table to provide a unique key for the whole hierarchy.
Each member of the hierarchy has a foreign key reference to it na has
its own primary key on the referencing field. Use triggers to update
the index table.

Oliver Elphick olly(at)lfix(dot)co(dot)uk
Isle of Wight
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 Tom Lane 2004-08-29 16:45:34 Re: Migrating between versions. Problem with regexp
Previous Message Stephan Szabo 2004-08-29 16:33:33 Re: Primary key inheritance problem