Table Inheritance and foreign key problem. - Mailing list pgsql-general

From Kostas Maistrelis
Subject Table Inheritance and foreign key problem.
Date
Msg-id 377c89a20607230459l79271c5fnc25e09dc9d62ab36@mail.gmail.com
Whole thread Raw
Responses Re: Table Inheritance and foreign key problem.  (Alvaro Herrera <alvherre@commandprompt.com>)
Re: Table Inheritance and foreign key problem.  (Reece Hart <reece@harts.net>)
List pgsql-general
I make 3 tables with this senario:
b (id) extends a (id)
and
c (id) references a (id)

i insert one record to  table b (id = 1)
and then i try to insert a record in table C  (id = 1)
but it is not possible, i get error
(look at the sql statements above)


NOTE
if the C (id) references the b (id) the insert in  table C
is possible.

I try this to postgresql 8.1.2 and 8.1.4


above is the exact SQL STATMENTS:

============================================

DROP TABLE a;
DROP TABLE b;
DROP TABLE c;

CREATE TABLE  a (id integer primary key);

CREATE TABLE  b (id integer primary key) INHERITS (a);

CREATE TABLE c (id integer primary key references a(id));

insert into b values (1);





SELECT * from b;
 id
----
  1
(1 row)


SELECT * from a;
 id
----
  1
(1 row)


INSERT INTO c VALUES (1);
ERROR:  insert or update on table "c" violates foreign key constraint
"c_id_fkey"
DETAIL:  Key (id)=(1) is not present in table "a".



============================================


Thanks

Kostas Maistrelis.

pgsql-general by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: join table with empty fields and default
Next
From: Alvaro Herrera
Date:
Subject: Re: Table Inheritance and foreign key problem.