From: | Dennis Muhlestein <dennis(at)zserve(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org(dot)pgsql-sql(at)postgresql(dot)org |
Subject: | Foreign Keys and Inheritance |
Date: | 2001-06-01 15:38:48 |
Message-ID: | 9f8cu9$i29$1@news.tht.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-sql |
If I have table A, which contains a primary key,
and table B which inherits from A.
How can I Create a Foreign Key on table C that references A, but will
also pass if a record in inserted in to B.
for instance:
create table A
(
prim_key char(20) not null primary key
);
create table B
(
) INHERITS A;
create table C
(
data char(2) not null primary key,
constraint fk_C FOREIGN KEY ( data ) REFERENCES A ( prim_key ) ON DELETE
CASCADE ON UPDATE CASCADE
)
With this setup, my record must be inserted in to A or I'll get a
referential integrity problem when I insert in to C.
I want to be able to insert in to A, B , or another table inherited from A,
and have table C recognize that as it's foreign key.
Thanks
From | Date | Subject | |
---|---|---|---|
Next Message | Steve Wampler | 2001-06-01 15:40:14 | Can't restart postmaster! |
Previous Message | Sergey E. Volkov | 2001-06-01 15:37:33 | Re: Pgsql vs Interbase: Transaction benchmark |
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Berkus | 2001-06-01 16:21:17 | Re: Date manipulation |
Previous Message | David BOURIAUD | 2001-06-01 14:51:49 | [Fwd: Problem with pg_index.] |