Re: Advice on foreign key and cascading delete design - postgresql 12.6 - Mailing list pgsql-novice

From Tom Lane
Subject Re: Advice on foreign key and cascading delete design - postgresql 12.6
Date
Msg-id 3190280.1618325238@sss.pgh.pa.us
Whole thread Raw
In response to Advice on foreign key and cascading delete design - postgresql 12.6  ("Steve Tucknott (TuSol)" <steve@tusol.co.uk>)
Responses Re: Advice on foreign key and cascading delete design - postgresql 12.6  ("Steve Tucknott (TuSol)" <steve@tusol.co.uk>)
List pgsql-novice
"Steve Tucknott (TuSol)" <steve@tusol.co.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



pgsql-novice by date:

Previous
From: "Steve Tucknott (TuSol)"
Date:
Subject: Advice on foreign key and cascading delete design - postgresql 12.6
Next
From: "Steve Tucknott (TuSol)"
Date:
Subject: Re: Advice on foreign key and cascading delete design - postgresql 12.6