Re: [GENERAL] Inheritance and foreign keys

Поиск
Список
Период
Сортировка
От Andreas Kretschmer
Тема Re: [GENERAL] Inheritance and foreign keys
Дата
Msg-id 99566864-30E0-4AD0-BCCA-EABBC5ABFF42@a-kretschmer.de
обсуждение исходный текст
Ответ на [GENERAL] Inheritance and foreign keys  (Jayadevan M <maymala.jayadevan@gmail.com>)
Список pgsql-general
Not possible - yet.

Am 25. Mai 2017 13:48:59 MESZ schrieb Jayadevan M <maymala.jayadevan@gmail.com>:
Hi,

I designed three tables so that one table inherits another, and the third table references the parent table. If a record is inserted into the third table and the value does exist in the parent table indirectly, because it is present in the inherited table, I still get an error. 
Is some option available while creating the foreign key so that it will consider the data in the child tables also while doing a constraint validation?

create table myt(id serial primary key);
create table mytc (like myt);
alter table mytc inherit myt;
insert into myt values(1);
insert into mytc values(2);
 select * from myt;
 id 
----
  1
  2

create table a (id integer    references myt(id));
insert into a values(2);
ERROR:  insert or update on table "a" violates foreign key constraint "a_id_fkey"
DETAIL:  Key (id)=(2) is not present in table "myt".


Regards,
Jayadevan

--
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.

В списке pgsql-general по дате отправления:

Предыдущее
От: Jayadevan M
Дата:
Сообщение: [GENERAL] Inheritance and foreign keys
Следующее
От: Achilleas Mantzios
Дата:
Сообщение: Re: [GENERAL] Inheritance and foreign keys