[pgsql] inherits and foreign key problem

From: "Magicloud Magiclouds" <magicloud(dot)magiclouds(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: [pgsql] inherits and foreign key problem
Date: 2007-04-24 02:30:15
Message-ID: 3bd412d40704231930q33582708s8b5eaa79a744d5a5@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dear all,
I have some tables like below, and now i have one record for each
in simple_texts, simple_directories and side_types. Now I want to
insert one record into sides (from simple_directory to simple_text
with side_type), but it report error: can not insert or update
"sides", against foreign key "sides_from_fkey". detail: key (from)=(2)
is not present in table "base_nodes".
How does this happen? How to resolve?

Thanks.
---
CREATE TABLE base_nodes
(
id bigserial NOT NULL UNIQUE
);
CREATE TABLE name_descriptions
(
name varchar (256) NOT NULL PRIMARY KEY,
description text NOT NULL,
UNIQUE (id)
) INHERITS (base_nodes);
CREATE TABLE side_types
(
UNIQUE (id),
PRIMARY KEY (name)
) INHERITS (name_descriptions);
CREATE TABLE sides
(
"from" int8 NOT NULL REFERENCES base_nodes (id) ON DELETE CASCADE,
"to" int8 NOT NULL REFERENCES base_nodes (id) ON DELETE CASCADE,
"type" int8 NOT NULL REFERENCES side_types (id) ON DELETE CASCADE,
PRIMARY KEY ("from", "to", "type")
) INHERITS (base_nodes);
CREATE TABLE users
(
"password" char (128) NOT NULL,
UNIQUE (id),
PRIMARY KEY (name)
) INHERITS (name_descriptions);
CREATE TABLE simple_texts
(
context text NOT NULL,
UNIQUE (id),
PRIMARY KEY (name)
) INHERITS (name_descriptions);
CREATE TABLE simple_directories
(
UNIQUE (id),
PRIMARY KEY (name)
) INHERITS (name_descriptions);

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2007-04-24 02:33:03 Re: PG service restart failure (start getting ahead of stop?)
Previous Message Robert Treat 2007-04-24 02:15:59 Re: Postgresql Help