We just usually delete users. In other words, there is a column in the user table indicating that they are no longer active and do not change all queries, so that they only work with active users.
This has two advantages:
- it does not impose foreign key restrictions on other tables; and
- It saves all the data that you need to restore it at some point.
If the number of your users is in billions or your turnover is small, the retention of old users will not be emphasized by most databases.
This can be used to create a similar pattern for SO. When users "disappear", the questions and answers created by them still contain information about the author, but it is inactive.
If you provided NULLed user information (or even if you had one Unknown user to assign messages if you do not want to allow NULL), you will not have this information.
source share