3 ms·
Often other tables have foreign keys to the record to be deleted. What’s a good pattern for treating those related tables for every time a relationship row gets
by blumomo 4y ago
Often other tables have foreign keys to the record to be deleted.
What’s a good pattern for treating those related tables for every time a relationship row gets deleted/removed as per the OP blog post?
- config_yml 4y agoReally depends on the related data, but there‘s the option to use ON DELETE CASCADE|RESTRICT and set null or set default. Cascade can be a bit of a footgun, as this can trigger a waterfall of deletes.
- danparsonson 4y agoCascades can also lead to deadlocks as I found to my cost the one and so far only time I tried using hard deletes.