Foreign key to all inherited tables - Mailing list pgsql-general

From Darrin Ladd
Subject Foreign key to all inherited tables
Date
Msg-id F57M7VHTUC0dHgQBGCY00007b18@hotmail.com
Whole thread Raw
Responses Re: Foreign key to all inherited tables  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List 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 by date:

Previous
From: "Arthur M. Kang"
Date:
Subject: Server Overload
Next
From: mikeo
Date:
Subject: Re: hidden data fields