I am creating a little online quiz/game. I have a users-table containing a unique auto-increment id, a username field, a password field and a ip field (from where it was created).
That handles the log in and stuff like that.
Then I need to track the users process. The user has to complete several tasks, or levels. However you wish to view it.
The requirements are the following, for each task:
- Keep track of how many attempts the user has done for a given task
- Keep track of his last attempt
- Keep track of where he failed
- Keep track of his shortest successful attempt
- Keep track of his most recent successful attempt.
What I am asking is basically how I should structure my tables for this to work as smooth as possible and require as little annoying SQL-queries and code as possible.
Should I have one table for each task with each row bound to a username and fields corresponding the list above? Or one large table with a row bound to the username that indicated which task and all the fields corresponding the list above?
I am not sure, which is why I am asking.
Worth mentioning: Anything I currently have is not set in stone, so I can change anything you want.
Any help and/or suggestions are much appreciated.
Thanks in advance.
EDIT:
I will also have one table with each task: tasks(id, name, description, finish_message)
And with that I need to have a new table structure for the tasks similar to the one I described above for the users and tasks, but for the tasks and tests.
I didn’t get your question completely, but I think following structure might help you:
Please clarify your third requirement:
If I am not getting you wrong user might not be able to proceed to give next test of a task until she finishes current test successfully, so you can add one more field for test_id for keeping track of failed test_id in particular task.