I’m developing a simple custom Drupal Module for creating Quizz, and I need some help with the SQL part.
I’d like to keep a trace of registered used who answered the Quizz, but don’t know how to build the relationship.
Basically, I have 2 tables with these columns:
Users:
idnameemailstatus
and
Content_Type_Quizz:
idstart dateend dategood answerexplanation
There’s also a third table with the quizz answers, but I don’t think it would help in my situation.
Should I add a field in the Content_Type_Quizz table with the user id? Or create a new table Content_Type_Quizz_AnsweredBy with the Quizz id, the answer and the User id?
Thanks for your help!
It is a many to many relation; a quizz can be answered by many users and a user can answer multiple quizzes. You will need 3 tables: users, quizzes and quizz_answer (or quizz_user).
The users table will hold the users, quizzes will hold the quizzes and quizz_answer will hold the user answer to the quizz.
I think the quizz_answer table should have 3 column; user_id, quizz_id and the answer to the quizz. I believe you need to revisit your quizz table structure because I don’t understand the good answer and explanation columns.