Search code examples
phpmysqldatabaseredbean

Keep allocation history after deleting a user


I have 3 tables - user, book and bookissues

When a user is deleted I want to keep the bookissues associated with the user (for book records). I also want to know what the users name and email was.

What would be the best solution for this?

Using redbean for ORM


Solution

  • Do a "soft" delete. Make a 'deleted' flag in the users table.

    Laravel has a good example of how this is done. http://laravel.com/docs/eloquent#soft-deleting