I am developing an a game application and is debating which is the correct way to handle which user is the owner of a played game.
You can either play as an anonymous guest who only has to provide your location or as a registered user. All users are stored in the database. Once you complete a game a database entry is added with you score and I also want to log who played the game.
The table looks as follows:
USERS ( id | user_name | password | country ) GAMES ( id | user_id | score )
As of now I just store a reference to USERS(id) in GAMES(user_id), how should I handle anonymous users though?
One way is to store every anonymous user as just an id and location and then add a column to GAMES called anonymous_id. But then one of user_id or anonymous_id would have to be NULL for every game depending on if the player was registered or not.
Another way would be to just add all the anonymous users to the USER table and allow user_name and password to be null.
Is there a better way to handle this?
Any advice appreciated.