deleting referenced data

From: Andreas Fromm <Andreas(dot)Fromm(at)physik(dot)uni-erlangen(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: deleting referenced data
Date: 2003-08-26 14:06:06
Message-ID: 3F4B694E.6080106@physik.uni-erlangen.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I have The following situation:

CREATE TABLE data1 (
id SERIAL PRIMARY KEY,
data INTEGER
);

CREATE TABLE data2 (
id SERIAL PRIMARY KEY,
data INTEGER
);

CREATE TABLE data3 (
id SERIAL PRIMARY KEY,
data INTEGER
);

CREATE TABLE relations (
id SERIAL PRIMARY KEY,
data1 INTEGER REFERENCES data1,
data2 INTEGER REFERENCES data2,
data3 INTEGER REFERENCES data3
);

When I delete a record of the table realtions I also want to delete the
record on the data-tables if there is no other record referencing them.
How can I do this?

Regards

Andreas Fromm

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-08-26 14:07:02 Re: Index usage
Previous Message Jan Wieck 2003-08-26 13:54:55 Re: Buglist