Making a foreign key chain - good idea or bad idea?

From: Frank Joerdens <frank(at)joerdens(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: Making a foreign key chain - good idea or bad idea?
Date: 2001-01-24 17:30:50
Message-ID: 20010124183049.A8283@rakete.joerdens.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I just did something which seems to work alright and which makes sense
to me now but which I have a funny feeling about. It may be good
standard practice (and I just don't know about it) or dangerously
foolish or just plain silly: I created a foreign key reference on a
column that is also the primary key for this table as in

create table institute (
id int4 references index ( id ) PRIMARY KEY,
. . .

and then used that column as a reference for a foreign key constraint in
a couple of other tables:

create table boss (
institute_id int4 references institute ( id ),
. . .

create table staff (
institute_id int4 references institute ( id ),
. . .

I am not really sure what happens when I delete or modify the id column
in the table at the top of this "chain". Except for this uncertainty I
don't think this scheme would pose a problem, but I may be wrong. Can
anyone enlighten me?

Ta, Frank

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Jie Liang 2001-01-24 18:12:36 Re: How to change the ownership of the table?
Previous Message Albert REINER 2001-01-24 17:23:02 Re: plpgsql language