Foreign key to all inherited tables
От | Darrin Ladd |
---|---|
Тема | Foreign key to all inherited tables |
Дата | |
Msg-id | F57M7VHTUC0dHgQBGCY00007b18@hotmail.com обсуждение исходный текст |
Ответы |
Re: Foreign key to all inherited tables
|
Список | pgsql-general |
Hi, I was wondering if there is a way to have a foreign key reference to the primary key column of all tables throughout an inheritance tree. For example, I have a parent_table with a unique_id (type serial) and a child table which inherits the parent_table (inheriting the unique_id). I would like to have another table have a field, unique_id, who's value must be in the unique_id field of the parent or the child. I tried adding an asterix to the end of the foreign key table refrence, {CONSTRAINT fk_other_table FOREIGN KEY (unique_id) REFERENCES parent_table* (unique_id)} but the parser didn't like that. Then I tried creating a check constraint on the field in the 'other_table' to check if the value was 'IN (SELECT unique_id from parent_table*)'. The table creation went fine, but when I tried to insert any values into the table it produced an error: ExecEvalExpr: unknown expression type 108. Does anyone have a work-around for this? Thanks! Darrin ________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
В списке pgsql-general по дате отправления: