I have a table which stores users, another table which stores post information and a third table which stores comments.
I want to allow unregistered and registered users to comment on posts.
What is the best practice database design for that? How should I store unregistered or registered commenter information in the database?
You could create a dummy user record with the name, email, website of the guest user in your users table and link the comment to the dummy user’s ID.
Edit: Given the additional information you’ve added in comments:
Create a basic
Userstable withCreate a second
RegisteredUserstable with the additional fields you require for registered users and define the relationship between the two tables as Users.Id = RegisteredUsers.Id.The
Commentstable would then have aCreatedByUserIdfield whereCreatedByUserId = Users.Id.