How to save game-progress in a MySQL database

mysql

Solution

Answer to your Question 1

I would not approach your problem this way. I would create 3 tables: a `Levels` table (primary key of 'levelKey'), a `Users` table (primary key of 'userKey') and a `User_Levels` table with a composite key of 'levelKey' and 'userKey'. When a user completes a level, just insert into the `User_Levels` table. Then to see if a user has completed a level is a simple select:

SELECT 'a' FROM User_Levels WHERE userKey = ? AND levelKey = ?

If the number of rows is > 0, the user has completed the level

Problem

I am developing a website that is a kind of game. The users' progress is saved in a MySQL-database. I want to go about this by having a table saves with a column save (ID) and a column progress, where progress is of datatype text. When the user starts out, progress is set to (e.g.) '0'. If he proceeds to level 1, progress is set to '0#1', level two makes it '0#1#2'. The order of levels is free and I want to save it. So progress could be '0#4#2#15' and so on. Is this a good way to do this? I have no experience with SQL and I don't want to do something incredibly stupid. I've read so much confusing info about tables, foreign keys and whatnot... I want to thank you for your time reading this and I'm looking forward to answers. Ryan

Original source