Advice on foreign key and cascading delete design - postgresql 12.6
Steve Tucknott (TuSol) <steve@tusol.co.uk>
From: "Steve Tucknott (TuSol)" <steve@tusol.co.uk>
To: PostGreSQL <pgsql-novice@postgresql.org>
Date: 2021-04-13T12:40:51Z
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.