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

From: nospam(at)hardgeus(dot)com
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 03:58:33
Message-ID: 60352.66.190.208.241.1136433513.squirrel@www.hardgeus.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

As the other responders mentioned, from the schema you described, it
doesn't look like you really need two separate tables. However, if you
do, foreign keys aren't what you're looking for to solve your problem.

That's not what foreign keys do. The only thing a foreign key provides is
a guarantee that if any records in B (the referencing table) still
reference a record in table A (the referenced table) then you cannot
delete that referenced record.

As far as the actual data in table B being modified to match table A,
that's something completely unrelated to foreign key integrity. That is
something I would recommend maintaining at the application level. Or, if
you're a trigger guy, do it in a trigger.

John

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2006-01-05 08:40:56 Re: JOIN question with multiple records
Previous Message Jim Johannsen 2006-01-05 03:31:47 Re: FOREIGN KEYs ... I think ...