Re: Advice on foreign key and cascading delete design - postgresql 12.6

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: steve(at)tusol(dot)co(dot)uk
Cc: PostGreSQL <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Advice on foreign key and cascading delete design - postgresql 12.6
Date: 2021-04-13 14:47:18
Message-ID: 3190280.1618325238@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

"Steve Tucknott (TuSol)" <steve(at)tusol(dot)co(dot)uk> writes:
> I have a few tables that are subservient to multiple other tables
> (notes, addresses, attached documents etc).
> These tables carry the 'owning' table name and its record's PK.

> I can manually keep these tables tidy and avoid orphans, but is there a
> way within postgresql to reference these tables on a FK constraint to
> automatically delete the subservient recs when the parent is deleted?

Maybe I'm missing something, but aren't you just looking for the
ON DELETE CASCADE option of foreign key constraints?

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Steve Tucknott (TuSol) 2021-04-13 15:48:48 Re: Advice on foreign key and cascading delete design - postgresql 12.6
Previous Message Steve Tucknott (TuSol) 2021-04-13 12:40:51 Advice on foreign key and cascading delete design - postgresql 12.6