user3871
user3871

Reputation: 12718

DB schema for single player web RPG

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?

enter image description here

Upvotes: 0

Views: 657

Answers (1)

Leo
Leo

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.

see http://www.databasejournal.com/features/mysql/article.php/3906761/Cardinality-in-MySQL-Data-Modeling.htm

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

Related Questions