Advice on foreign key and cascading delete design - postgresql 12.6

From: "Steve Tucknott (TuSol)" <steve(at)tusol(dot)co(dot)uk>
To: PostGreSQL <pgsql-novice(at)postgresql(dot)org>
Subject: Advice on foreign key and cascading delete design - postgresql 12.6
Date: 2021-04-13 12:40:51
Message-ID: c1cfdf4054e8480d28fbf7fb2e15912d3996ee69.camel@tusol.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

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?

OR have I got the structure all wrong anyway and is there a cleaner way
of holding, say notes, for records on a whole range of tables?

Thanks all.

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2021-04-13 14:47:18 Re: Advice on foreign key and cascading delete design - postgresql 12.6
Previous Message Simon Connah 2021-04-09 07:47:06 Can't work out what is wrong with this code