• 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
(09-22-2018, 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

#5
(09-15-2018, 02:20 AM)ignitedcms Wrote: Is this extra work in the programming back end worth the hassle?

It depends heavily on what you are building and what your end goals are.

If you are building your own toolset that you will use for most, if not all, future development, I'd say it's probably worth considering putting it in from the start.

If you are building your own product, but it's one off project so the code is not shared with future projects, you'd probably have to consider if adding soft-delete is more important than adding some business critical functionality.

If you are working on fixed budget client project, and they haven't specifically asked for it, not that I'm advocating putting in minimum effort for client work, effectively they are probably more interested in their business logic going in instead of nice to have features, especially if their budget is stretched.

If it's long term client project or project you do for your employer, so you do want to keep good long term relationship, it could be nice way to add cherry on top, earn some brownie-points.
Reply

#6
Another thing I'd like to add to this thread discussion, is one alternative is have a modal popup or tooltip come up that when you do press delete you are prompted with an 'Are you sure?' message. This doesn't entirely solve the issue at hand but at least it is one fail safe, and I think every good software tool should check twice before allowing the user to permanently delete something.
Practical guide to IgnitedCMS - Book coming soon
Reply

#7
if you take GDPR into consideration and the right to be forgotten, then in some cases hard delete is better
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


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