Search Postgresql Archives

[pgsql] inherits and foreign key problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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);


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux