Here is a simple example of my problem
CREATE TABLE parent (
id SERIAL PRIMARY KEY
);
CREATE TABLE child (
name text
) INHERITS (parent);
-- Populating child table
INSERT INTO child (name) VALUES ('Alex');
INSERT INTO child (name) VALUES ('Simba');
INSERT INTO child (name) VALUES ('Jafar');
CREATE TABLE test(
parentId INTEGER REFERENCES parent (id)
)
-- I checked Alex has id of 1 and it is present in parent table
INSERT INTO test(parentId) VALUES (1);-- This line does not work
I geting the following message: insert into test(parentId) VALUES (1)
ERROR: insert or update on table "test" violates foreign key constraint "test_parentid_fkey" DETAIL: Key (parentid)=(1) is not present in table "parent".
Why do i get this ERROR ?