I have a message model which belongs to a user. Users can be deleted,
but messages cannot. What can I do to reference a user that created a
message when it no longer exists?:
1) Create a dummy user. When a user is deleted, assign the dummy user
id to all of its messages.
2) Have a condition to check if the user exists, if not, don't show
the user info.
3) Don't really delete the user, just flag it or change its state to
inactive.
These 3 occured to me. Any other options I should have in
consideration? Which one should I follow?
I have a message model which belongs to a user. Users can be deleted,
but messages cannot. What can I do to reference a user that created a
message when it no longer exists?:
1) Create a dummy user. When a user is deleted, assign the dummy user
id to all of its messages.
2) Have a condition to check if the user exists, if not, don't show
the user info.
3) Don't really delete the user, just flag it or change its state to
inactive.
These 3 occured to me. Any other options I should have in
consideration? Which one should I follow?
I would use 3. 1 is not worth serious consideration (dummy records are
seldom good things), and while 2 would work, it wouldn't let you
differentiate between messages from different inactive users.