pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Frank Joerdens <frank@joerdens.de>
To: pgsql-sql@postgresql.org
Subject: Making a foreign key chain - good idea or bad idea?
Date: Wed, 24 Jan 2001 18:30:50 +0100
Message-ID: <20010124183049.A8283@rakete.joerdens.de> (raw)

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 



view thread (2+ messages)  latest in thread

Message-ID: <20010124183049.A8283@rakete.joerdens.de>
Permalink:  ../20010124183049.A8283@rakete.joerdens.de/
Also on:    postgresql.org/message-id/20010124183049.A8283@rakete.joerdens.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: frank@joerdens.de
  Subject: Re: Making a foreign key chain - good idea or bad idea?
  In-Reply-To: <20010124183049.A8283@rakete.joerdens.de>
  References: <20010124183049.A8283@rakete.joerdens.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox