smobx smobx - 2 years ago 101
PHP Question

Database's table organization

My project stands in building an educational platform. The user will have 2 types of tests available. First one with more than 1000 questions with unlimited time to solve. The second one with random 60 questions from the 1000's (simulation test).

My questions are: I know i need to save the position the user is of the 1000 questions. Because the test is written in javascript and when i hit refresh, it goes back to the first question. My questions is, should i do another table in my database to save this variable or should i just make another row in my user's table?

the second question : i need to display the last 5 results the user has on the 60questions test. How should i do that, and after 5 are saved, how do i delete the oldest one and insert the last one?

Now, i only got one table in my database, the users table where i have some of the users info, I would really appreciate some tips on how it should be organised. Thank you very very much !

Answer Source

One way to do it is to have an answer table. The answer table would be something like;

id, userId, testNumber, questionNumber, answer, time

At any time you can look up the answers to the questions by any user on any test. You can sort them by the time. You will then have access to the last one, the last 5, you can find which are missing, if they are all done etc.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download