Foreign Keys and Inheritance 
Author Message
 Foreign Keys and Inheritance

Currently you can't do that.  Foreign keys are only referencing the
explicitly named tables.  This will probably change around the time
that someone goes in and does alot of work on inheritance.  BTW:
primary keys (and unique) also do not inherit.


> 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
> (

> create table C
> (
>         data char(2) not null primary key,
>         constraint fk_C FOREIGN KEY ( data ) REFERENCES A ( prim_key ) ON DELETE
> )

> 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.

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command

Mon, 24 Nov 2003 01:05:51 GMT
 [ 1 post ] 

 Relevant Pages 

1. PLEASE help with foreign key and inheritance pr

2. PLEASE help with foreign key and inheritance problem

3. PLEASE help with foreign key and inheritance proble

4. inheritance and primary/foreign keys

5. inheritance and foreign keys

6. inheritance and foreign key

7. Another naive question, inheritance and foreign key

8. inheritance and foreign keys

9. Inheritance and Foreign Keys

10. inheritance and foreign keys

11. foreign key w/o foreign/primary key

12. Trigger to check a foreign key without using foreign key

Powered by phpBB® Forum Software