Skip site navigation (1) Skip section navigation (2)

Re: FOREIGN KEYs ... I think ...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: FOREIGN KEYs ... I think ...
Date: 2006-01-05 01:54:47
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
"Marc G. Fournier" <scrappy(at)postgresql(dot)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
(assuming that I've understood your schema correctly).

			regards, tom lane

In response to


pgsql-sql by date

Next:From: Marc G. FournierDate: 2006-01-05 03:12:27
Subject: Re: FOREIGN KEYs ... I think ...
Previous:From: Marc G. FournierDate: 2006-01-05 01:49:52
Subject: FOREIGN KEYs ... I think ...

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group