Re: Primary key inheritance problem

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
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:33:33
Message-ID: 20040829093224.M53096@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-general


On Fri, 27 Aug 2004, 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.
> Here's a little sample to show my problem :
>
> CREATE TABLE foo_a
> (
> pk_idmyfoo INT2 PRIMARY KEY NOT NULL,
> myfoo_name VARCHAR(10)
> );
>
> CREATE TABLE child_foo
> (
> child_foo_nickname VARCHAR(20)
> ) INHERITS (foo_a);
>
> CREATE TABLE childfoo_bookmarks
> (
> fk_idchildfoo INT2 NOT NULL REFERENCES child_foo (pk_idmyfoo),
> url VARCHAR(250)
> );
>
> The error I get is :
> ERROR: there is no unique constraint matching given keys for referenced
> table "child_foo"
>
> What can I do to solve that problem ?

Well, to shut up the message you can add a constraint to child_foo's
version of pk_idmyfoo. However, as a note, that'll not guarantee
uniqueness between foo_a's pk_idmyfoo values and child_foo's ones.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Oliver Elphick 2004-08-29 16:34:08 Re: Primary key inheritance problem
Previous Message Kaloyan Iliev Iliev 2004-08-29 16:12:26 Re: Migrating between versions. Problem with regexp