PostgreSQL Inheritance - 02-09-2004 , 07:29 PM
I'm a PostgreSQL newbie and I had a quick question concerning a setup that I
have. I current have three tables, a, b, and c. On my create table
statement for table a, I have the following:
create table a (
id VARCHAR(3) NOT NULL,
name VARCHAR(15) NOT NULL,
CONSTRAINT a_pk PRIMARY KEY (id)
) INHERITS (b);
For b, I have a similar table structure minus the inherits keyword, so all
data I enter for table a will appear in a select call for table b.
Now let's say I have a third table, table c. This table actually has a
foreign key relation to the id column for table b. My question is, since
data that is in table a can be viewed in table b, how can I enforce the
referential integrity using both a and b's id column via the inheritance???
or with PostgreSQL, can I only do this with the ids that are directly stored
in table b and not the inherited ids from a? The latter question seems to
reflect how PostgreSQL handles it now, but I wanted to see if I could do it
with the inherited data as well....
Alright, thanks guys