deleting referenced data - Mailing list pgsql-general

From Andreas Fromm
Subject deleting referenced data
Date
Msg-id 3F4B694E.6080106@physik.uni-erlangen.de
Whole thread Raw
Responses Re: deleting referenced data  (Richard Huxton <dev@archonet.com>)
List 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


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: many columns with references to one table
Next
From: Raymond
Date:
Subject: Excel 97 Export to Postgres