Re: INHERIT and FOREIGN KEY issues - Mailing list pgsql-novice

From Kedar Rasik Parikh
Subject Re: INHERIT and FOREIGN KEY issues
Date
Msg-id 20090524234136.fxjtgf41ogswwo4o@port1.netcore.co.in
Whole thread Raw
In response to INHERIT and FOREIGN KEY issues  (Luiz Eduardo Cantanhede Neri <lecneri@gmail.com>)
Responses Re: INHERIT and FOREIGN KEY issues
List pgsql-novice
I believe you will have to say good bye to the foreign key constraint.

Its is not inherited, only the schema is, constraints and index will
have to be separately created per child table.


-Regards

Kedar Parikh


Quoting Luiz Eduardo Cantanhede Neri <lecneri@gmail.com>:

> Hi,
> I'm trying to do something like this:
>
> BEGIN;
>
> CREATE TABLE A
> (
> idA serial not null primary key,
> someColumn text
> );
>
> CREATE TABLE B
> (
> someData text
> ) INHERITS(A);
>
> CREATE TABLE C
> (
> idC serial not null primary key,
> anotherColumn text
> );
>
> CREATE TABLE BC(
> idB int4,
> idC int4,
>  FOREIGN KEY (idB) REFERENCES B(idA),
>  FOREIGN KEY (idC) REFERENCES C(idC)
> );
>
> COMMIT;
>
> But When it is going to create the table BC, it gives an error:
>
> ERROR:  there is no unique constraint matching given keys for referenced
> table "b"
>
> My question is: Shouldn't it get Table A primary key and create the foreign
> key?
>
> Thx
> Luiz Eduardo
>





pgsql-novice by date:

Previous
From: Daniel Staal
Date:
Subject: Re: INHERIT and FOREIGN KEY issues
Next
From: Tom Lane
Date:
Subject: Re: INHERIT and FOREIGN KEY issues