• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Soft Delete VS hard Delete

#1
Guys what are you thoughts on soft delete for db entries, this is typically where you have an extra field that has a flag of inactive / active.

So db entries don't actually get deleted but just tagged as inactive, and any query search, searches for all fields that are set as active.

This allow extra safety in case the end user accidentally deletes something they didn't wish to.

Is this extra work in the programming back end worth the hassle?

Thoughts please?
Practical guide to IgnitedCMS - Book coming soon
Reply

#2
(09-15-2018, 02:20 AM)ignitedcms Wrote: Guys what are you thoughts on soft delete for db entries, this is typically where you have an extra field that has a flag of inactive / active.

So db entries don't actually get deleted but just tagged as inactive, and any query search, searches for all fields that are set as active.

This allow extra safety in case the end user accidentally deletes something they didn't wish to.

Is this extra work in the programming back end worth the hassle?

Thoughts please?

Soft delete > hard delete. accidentally deletes can be faster restored. Time = money Smile
Reply

#3
Whilst I agree soft deletes are nice because it's easy to correct "mistakes" I think there are other implications.

If you have a table that is used in dozens and dozens of queries, then every single query is going to have to include an extra condition on the field that indicates whether the row is deleted or not. Any ommissions here could have undesired consequences that might not be noticed for quite a while. For example the calculation of a customer's balance that doesn't account for invoices that have been deleted won't be noticed until some invoices actually get deleted.
Reply

#4
(Yesterday, 03:30 AM)CINewb Wrote: Whilst I agree soft deletes are nice because it's easy to correct "mistakes" I think there are other implications.

If you have a table that is used in dozens and dozens of queries, then every single query is going to have to include an extra condition on the field that indicates whether the row is deleted or not.  Any ommissions here could have undesired consequences that might not be noticed for quite a while.  For example the calculation of a customer's balance that doesn't account for invoices that have been deleted won't be noticed until some invoices actually get deleted.

I completely agree, one reason I was against doing soft deletes is that exact example. In your query, say if you are doing invoices, if you forget to say, list all invoices where soft delete != true, then you could have a big problem on your hands.

That being said, it is more of a coding implementation issue rather than a system issue, but it does add an additional worry or headache for all other queries the programmer is writing.

Especially as EVERY database table should have a soft delete column if you are doing it properly.

My initial idea was, once I decided on having a soft delete for all tables, I would simply integrate this into my crud generator so I would never have the embarrassment of missing data.
Practical guide to IgnitedCMS - Book coming soon
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
3 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2018 MyBB Group.