cascading backwards

From: Paul Makepeace <postgresql(dot)org(at)paulm(dot)com>
To: PostgreSQL Novice <pgsql-novice(at)postgresql(dot)org>
Subject: cascading backwards
Date: 2003-05-08 21:55:16
Message-ID: 20030508215516.GA14445@mythix.realprogrammers.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

If a table A contains a foreign key to table B is it possible to have
a DELETE remove the targetted row in B when there are no longer any
other references in A to it? Either with SQL or using some other
PostgreSQL facility.

As an example,

Body:
body_id data
1 "some news"

Page:
page_id body_id name
10 1 "news"
11 1 "recent news"

If page_id=10 is deleted, nothing extra happens. If page_id=11 is
deleted, body_id=1 goes with it.

Many thanks, Paul

--
Paul Makepeace ....................................... http://paulm.com/

"If kangaroos graduate, then it shall rain in ghana on my sweet
potatoes."
-- http://paulm.com/toys/surrealism/

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Ron Johnson 2003-05-08 23:16:55 Re: cascading backwards
Previous Message Pam Wampler 2003-05-08 15:22:39 upgrade tips