[GENERAL] Inheritance and foreign keys

Поиск
Список
Период
Сортировка
От Jayadevan M
Тема [GENERAL] Inheritance and foreign keys
Дата
Msg-id CAFS1N4gPH0ihnhxvtTETL_cvwsR_nhLocr6S=BHc03YKAnR67A@mail.gmail.com
обсуждение исходный текст
Ответы Re: [GENERAL] Inheritance and foreign keys
Re: [GENERAL] Inheritance and foreign keys
Список pgsql-general
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

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

Предыдущее
От: anthonymarc
Дата:
Сообщение: [GENERAL] Buy counterfeit money ( morganmoore401@gmail.com)euros,dollars,pounds, SAR,ZAR,AED
Следующее
От: Andreas Kretschmer
Дата:
Сообщение: Re: [GENERAL] Inheritance and foreign keys