¿Cómo debo estructurar mis tablas? [cerrado]

I am creating a little online quiz/game. I have a users-table containing a unique auto-increment id, username campo, un password campo y una 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:

  1. Keep track of how many attempts the user has done for a given task
  2. Keep track of his last attempt
  3. Keep track of where he failed
  4. Keep track of his shortest successful attempt
  5. 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.

Gracias de antemano.

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.

preguntado el 25 de agosto de 12 a las 10:08

Show us some work you have already done -

What do you mean? I have not started creating the table structure because I'm not sure of how I want to do it. I've output my thoughs above in the question. -

I understand you have made a detailed writing of what you want.. but you have to do some more work on structuring tables & then ask here saying "Is this structure looking okay?" rather than "How should I structure?". -

Ah alright, I understand. I have created some basic structures, which I described in the text (did not mentioned I've tried them though). Initially I tried having a table for each task with all the information needed. But then I would have to look through each table to find out what the user has accomplished. Having them all in one table would solve that but I'm not sure that's an optimal solution, and that's when I decided to ask here. -

1 Respuestas

I didn't get your question completely, but I think following structure might help you:

    1. users(userid, username, password, ipaddress)
    2. tasks(taskid, task_description,...)--any other details you want
    3. task_attempted(userid, taskid, last_successful_attempt, shortest_successful_attempt, last_attempt, last_failed_testid);
    4. tests(testid, taskid, ...)--other details

Please clarify your third requirement:

Keep track of where he failed

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.

Respondido 25 ago 12, 10:08

Thank you. This solution is what I was thinking too when I said "have everything in one table". Keeping track of where the user failed will be an indicator for me to know which test for the specific task the user failed at. I have edited the question too, which will hopefully give you a clearer picture of what I am doing. - Firas Dib

thanks lindrian for more details, i hope this will help you - codeomnitrix

Thanks, this sounds great. Basically I will have two large tables and two smaller. The two large: one for all the tests for the tasks and one for all the user attempts for the tasks. The small: one for all the tasks and one for the users. Have I understood you correctly? - Firas Dib

yes, you are right. Please accept the answer if it was helpful - codeomnitrix

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.