Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Super Moderator JohnDubya's Avatar
    Join Date
    Nov 2006
    Location
    Missouri
    Posts
    634
    Thanks
    12
    Thanked 18 Times in 18 Posts

    How to deal with deleting users when they have associated content

    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!

  • #2
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    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.
    John

  • Users who have thanked PappaJohn for this post:

    JohnDubya (01-18-2008)

  • #3
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    ^^sounds good to me.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #4
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    Sounds good to me too. In fact I agree so much that I couldn't help posting a reply stating such.

  • #5
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    Quote Originally Posted by kbluhm View Post
    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.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #6
    Super Moderator JohnDubya's Avatar
    Join Date
    Nov 2006
    Location
    Missouri
    Posts
    634
    Thanks
    12
    Thanked 18 Times in 18 Posts
    haha, thanks for the replies...and concurring opinions. =D

  • #7
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    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.

  • Users who have thanked arnyinc for this post:

    JohnDubya (01-18-2008)

  • #8
    Regular Coder the-dream's Avatar
    Join Date
    Mar 2007
    Location
    Northamptonshire, UK
    Posts
    477
    Thanks
    8
    Thanked 4 Times in 4 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •