views:

19

answers:

1

I want to create a website for training multiple choice questions, the problem is that i don't want to repeat the question for each user, i will have many questions and the probability that random gets the same question is very small, and its important for me that user doesn't see the same question, so is it so pad demand to do this? and how could i do this.. i thought to save a list of all questions id, and use it to call new questions haven't been used and save the change....this way i have to save a string that loads on login, containing all questions, is this an efficient way to do it??

any ideas are welcomed to change the structure for better

+1  A: 

I think your base idea is correct. Store the ID's of the question a user already answered somewhere. Similar to

      asked_questions
--------------------------
user_id           int
question_id       int

With this, you can easily do

SELECT * FROM questions WHERE questions.id NOT IN (SELET asked_questions.question_id FROM asked_questions WHERE asled_questions.user_id = currentLoggedInUserId) LIMIT 10;

and have 10 questions the user has not seen yet.

DrColossos
Hi, i am worried about the storage efficiency, if i had 10,000 questions and 1000 users... its over 10 million records of 2 ints.... more than 80 GB, i thought to remember the last 100 questions in that table!! will this be a good solution, dont think a user will remember more than that... will this make it hard to design?? because i need to knoew the record id to be updated!!!!
seismael
If you use proper indexes, that shouldn't be a problem. 10million entries is not much and should be easily handeled by a well-designed database. you can store the date with each `asked_question` so you know when the user answered the question last and can decide based on the date.
DrColossos