Re: Primary key inheritance problem - Mailing list pgsql-general

From Oliver Elphick
Subject Re: Primary key inheritance problem
Date
Msg-id 1093797247.29613.347.camel@linda
Whole thread Raw
In response to Primary key inheritance problem  (Bruno Baguette <pgsql-ml@baguette.net>)
Responses Re: Primary key inheritance problem
List 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@lfix.co.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


pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Primary key inheritance problem
Next
From: Tom Lane
Date:
Subject: Re: Migrating between versions. Problem with regexp