46 ms·
Would a safer method be to have a <entities>-deleted table and migrate a deleted record to that table when it’s ‘deleted’. I’m not versed in databases but I’d
by graftak 3y ago
Would a safer method be to have a <entities>-deleted table and migrate a deleted record to that table when it’s ‘deleted’.
I’m not versed in databases but I’d expect you can even set additional access rules to individual tables making cross referencing very hard.
- nielsbot 3y agoThat's what the article suggests (at the end)
- joshstrange 3y agoYes that would work and be safer in a number of ways. I think I always avoided that because it requires 2 operations (delete and insert) and a tiny bit of added complexity. I think I’ll try that approach the next time I do something like this.
- vaidhy 3y agoYes and no. If you are thinking of a no-sql database, then this is an easy approach. However, I would expect most of the systems to be using normalized tables and this approach would be pretty hard due to relational constraints. You would have to have a separate database copy running for deleted entries so that it can be consistent within itself.
- graftak 3y agoThey way I see it relationships to the deleted record must always be nullified/marked deleted, because otherwise you get broken records referencing deletions. And relationships from a deleted record might as well persist because the foreign key will (fingers crossed) remain untouched. Again, not versed in db at all so this is likely total rubbish.
- vaidhy 3y agoYou are correct.. But if you move the deleted record to a different db, you have to follow the chain of relationships and move more records to the "deleted" db. Which means you would have a create a full database to maintain the entity relationships.