Skip site navigation (1) Skip section navigation (2)

INHERIT and FOREIGN KEY issues

From: Luiz Eduardo Cantanhede Neri <lecneri(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: INHERIT and FOREIGN KEY issues
Date: 2009-05-24 17:54:47
Message-ID: 252e1f290905241054w71f73101j1d5226fd8e6cffb2@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-novice
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

Responses

pgsql-novice by date

Next:From: Kedar Rasik ParikhDate: 2009-05-24 18:11:36
Subject: Re: INHERIT and FOREIGN KEY issues
Previous:From: Jasen BettsDate: 2009-05-24 11:43:08
Subject: Re: FW: RETURNING in stored procedure

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group