pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Marc G. Fournier <scrappy@postgresql.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: FOREIGN KEYs ... I think ...
Date: Wed, 04 Jan 2006 20:54:47 -0500
Message-ID: <27177.1136426087@sss.pgh.pa.us> (raw)
In-Reply-To: <20060104213210.A1088@ganymede.hub.org>
References: <20060104213210.A1088@ganymede.hub.org>

"Marc G. Fournier" <scrappy@postgresql.org> writes:
> Now, what I want to do is add a FOREIGN KEY (again, I think) that when 
> incident_summary.status is changed (either closed, or reopened), the 
> associated records in incident_comments are changed to the same state ...

Why not just get rid of the status column in incident_comments, and
treat incident_summary.status as the sole copy of the state?  When you
need to get to it from incident_comments, you do a join.

The foreign key you really ought to have here is from
incident_comments.incident_id to incident_summary.id
(assuming that I've understood your schema correctly).

			regards, tom lane



view thread (7+ messages)  latest in thread

Message-ID: <27177.1136426087@sss.pgh.pa.us>
Permalink:  ../27177.1136426087@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/27177.1136426087@sss.pgh.pa.us

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, scrappy@postgresql.org
  Subject: Re: FOREIGN KEYs ... I think ...
  In-Reply-To: <27177.1136426087@sss.pgh.pa.us>

* 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