Then you could do
FOREIGN KEY (foreign_id, NULL) REFERENCES foreign_table(id, deleted_at)11–20 of 514 posts
Then you could do
FOREIGN KEY (foreign_id, NULL) REFERENCES foreign_table(id, deleted_at)"The concept behind soft deletion is to make deletion safer, and reversible." That's one part. The other part is that in many industries you have regulatory data retention and audit requirements. This is arguably the most valuable and common reason to perform Logical deletes.
That works for updates too, by preserving the old data and showing you a time machine like backlog. But the archive database gets too large over time and you need to purge it periodically. You can create some delete triggers for automating this "save before delete" behavior.
"The concept behind soft deletion is to make deletion safer, and reversible." That's one part. The other part is that in many industries you have regulatory data retention and audit requirements. This is arguably the most valuable and common reason to perform Logical deletes.
Why not just use an audit table, to keep from littering your indices?
Earlier quoted context omitted.
Yep, we have an abstraction layer on top of the ORM to provide common queries. "Give me all X" will always return stuff not soft deleted. Data people also like to go diving through old data, and without getting into data warehousing and stuff like that, it's not too complex to support a single flag to enable us to keep old stuff.
They might like to, but you should definitely consider if saving data no longer required for your business violates privacy regulation/ethical considerations.
You could even sprinkle cryptographic guarantees into the mix. This would be very challenging to do with mutable DB rows.
The "Code leakage" problem can easily be solved by using views. Or am I missing something?
Soft deletion is certainly very situationally worth it. I've found the most value when 1. it is well supported at the ORM layer and 2. business requirements dictate strong auditability of data. While I have undeleted items on occasion, I've used soft deletes more frequently to debug and build a timeline of events around the data. For context, I've worked in fintech where I often needed to review backoffice approvals,…
I feel like a lot of developers underutilize the capabilities of the massively advanced database engines they code against. Sure, concerns about splitting logic between the DB and app layers are valid, but there are fairly well developed techniques for keeping DB and app states, logic and schemas aligned via migrations and partitioning and whatnot.