[pgsql] inherits and foreign key problem
| От | Magicloud Magiclouds |
|---|---|
| Тема | [pgsql] inherits and foreign key problem |
| Дата | |
| Msg-id | 3bd412d40704231930q33582708s8b5eaa79a744d5a5@mail.gmail.com обсуждение исходный текст |
| Ответы |
Re: [pgsql] inherits and foreign key problem
|
| Список | 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);
В списке pgsql-general по дате отправления: