Ask HN: Best practices – Should I ever actually delete data?

2 points by MalcolmDiggs ↗ HN
Imagine you're building a simple CRUD web application. Users can create stuff, mess with stuff, delete stuff, etc.

Is it ever a good idea to actually delete something as a response to user-behavior? Lately I've been defaulting to adding an "is_active" attribute/column/property to the data I store. When a user tries to delete something, I just switch that boolean from true to false.

The upside is I never actually delete anything (and can retrieve it if the customer freaks out because they deleted something on accident), the downside is just that as well...growing datasets that are not actually doing any good, except for being able to save-the-day in very rare customer-support contexts. And the downside of having to include "is_active == true" in most queries I send to retrieve data.

How do you guys handle this?

I was thinking of creating worker-scripts to regularly purge the database of non-active data (dump it to a flat file and send it all to Amazon Glacier or something)

4 comments

[ 3.5 ms ] story [ 19.6 ms ] thread
I'd say it has a lot to do with how your app/platform is used along with use cases for your platform.

If you're snapchat and you promise people that you delete customer images after 15 seconds then you sure as hell better delete them.

However if you are Trello and you delete a task, I can see a reason for doing a "soft delete" and allow a customer to recover their task in-case it was an accident. They actually offer an "archive" option first before a hard delete. Now I can imagine even if the hard delete happened that maybe Trello still doesn't delete the task and not jeopardize their business.

If I decide to keep the data, it would depend on me figuring out few things such as:

1) how likely it is the user comes back for that data? 2) are there analytics which I can run on this data? 3) is the cost of storing this data more than the value if its lost?

That's good advice, thank you for the tips.
Typically I will not delete the record but will set an Inactive or Deleted bit on the record and exclude those from queries, unless the data is sensitive in nature.

I do this after years of experience of users wanting to retrieve deleted data, even years from when the record was originally deleted.

On larger datasets I'll then have a task run at a specified timeframe that will go through and cleanup/delete all of the Inactive records.

Interesting, very close to where I was heading. Thank you for the insight.