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
The statements entered can be saved to a file or snippet for later use. At any point, you can also execute the statements you have entered. To save a snippet of code entered into the query editor, click Save SQL to Snippets List ( ) from the SQL query toolbar, enter a name (optional), and click OK.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With