My head’s spinning from reading all the pro’s & con’s articles about soft-delete. But that’s the only way I know to achieve this:
maintain the foreign keys & user info (history data)
Even if the user is deleted/inactive, there are foreign keys in comments, attachments and stories tables. So that it can still be identified that it was him who wrote this comment etc.
Other info:
deactivated users cannot login, won’t be included in lists.
But if I use soft delete, it’s not really good adding an extra column in the WHERE in sql statement every time I query for that table.
What to do? Hope you guys can give some inputs.
Note: I use mysql and ROR
If you “soft delete” users, you don’t add an extra column in the WHERE clause of every SQL statement. Instead, build one view that returns only active users, and the queries that need to know about active users use that query. They don’t use the base table.
It might look something like this.
Depending on how much development you’ve done so far, you might want to rename the users table, and name the new view “users” instead. Something along these lines . . .
Now any query that used to hit the table “users” will instead hit the view “users”. Logical data independence–this is why views and tables share the same namespace in the relational model.