March 27, 2012

Delete MySql rows, or mark "dead"?

Question by johnnietheblack

I’ve always had a weird feeling in my gut about actually deleting rows from certain types of tables.

For example, if I have a table of Users…when they delete their account, rather than fully deleting their row, I have been marking as “dead” or inactive. This allows me to retain a record of their existence if I ever need it again.

In situations like this – considering performance, overhead, etc – should I delete the row, or simply mark as inactive?

Which is more “common”?

Answer by Eric Petroelje

Personally, I almost always use “soft deletes” as you describe.

If space is a concern, I’ll have a job that will periodically clean up the soft-deleted records after they’ve been deleted for a certain amount of time.

Answer by Starx

Data are very valuable to be permanently deleted from the database. Mark as dead.

I generally give status for such cases. In this pattern

  1. 0 Inactive
  2. 1 Active
  3. 2 Trashed

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!