Reputation: 12718
I'm creating a web rpg and want to save user stats in a MYSQL database.
I've created a table called users
. Do I put their stats in that same table? Meaning, users
table has columns playername
, password
, score
, number of item a
, number of item b
. Or should I separate stats into a its own table stats
, and relate the user id to the stats?
EDIT:
Is this how I would manage stats per user?
Upvotes: 0
Views: 657
Reputation: 6570
If stats has a single value by user, you should add it as another column in the users table.
If there are several stats values by user, you should create another table and add a column for the user id as a foreign key.
UPDATE: complementing due to your edit.
if you want to keep track of different moments when a user had different levels and experiences in your game, yes. But if the idea is to keep just the current level and experience for each player, then no - they should be columns in the user table.
Upvotes: 1