...

View Full Version : How to deal with deleting users when they have associated content



JohnDubya
01-18-2008, 05:00 PM
I'm wondering how you guys deal with this issue I've run upon. On my app, our users can post reviews for books and stuff like that. Each review goes into a MySQL db entry that links to the person_id of the user in a `person` table.

But if we were to delete one of those users, we don't want to lose his reviews. If we delete his info from the `person` table, the review will be associated with that user's info (via his person_id) that will now be deleted...so therefore, it will show an error since that user no longer exists. How do you guys deal with this? Do you just never delete users? Do you have an `inactive` field in the `person` table for each user and set that to 1 instead of deleting? Any help or suggestions are appreciated, thanks!

PappaJohn
01-18-2008, 05:03 PM
Do you have an `inactive` field in the `person` table for each user and set that to 1 instead of deleting?
That would be my approach.

StupidRalph
01-18-2008, 05:57 PM
^^sounds good to me.

kbluhm
01-18-2008, 06:51 PM
Sounds good to me too. In fact I agree so much that I couldn't help posting a reply stating such.

StupidRalph
01-18-2008, 07:24 PM
Sounds good to me too. In fact I agree so much that I couldn't help posting a reply stating such.

Well that settles it. Its Friday, I say we just call it a day. :D

JohnDubya
01-18-2008, 08:24 PM
haha, thanks for the replies...and concurring opinions. =D

arnyinc
01-18-2008, 08:53 PM
I just wanted to add a "me too". As a matter of fact, for audit trails and tracking, it will saves you TONS of time to use that strategy in a lot of situations. We always had customers complaining about "lost" or missing data. It would take us quite a bit of time to rebuild from a backup and try to figure out what happened. Now I have an isDeleted flag on most tables and UPDATE instead of DELETE. So we can either call the customers idiots and tell them who deleted it or just re-enable it and smile.

the-dream
01-18-2008, 10:53 PM
As well as having an 'inactive' column you could change the users username to 'Anonymous' or 'Inactive'. Just so you are not displaying users that are no longer a member of the site.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum