MySql database design for a quiz

Posted by Mark on Stack Overflow See other posts from Stack Overflow or by Mark
Published on 2010-05-02T17:48:13Z Indexed on 2010/05/02 17:57 UTC
Read the original article Hit count: 112

Filed under:
|

I'm making an online quiz with php and mysql and need a bit of help deciding how to design the database for optimal insert of questions/answers and to select questions for the quiz. The table will hold 80 questions each with 4 possible options plus the correct answer.

When retrieving the questions and options from the database I will randomly select 25 questions and their options.

Is it better to make a single column for all questions, options, and correct answers? For example:

ID | Q | OPT1 | OPT2 | OPT3 | OPT4 | ANS

Or would it be better to make a column for each individual question, option, and correct answer? For example:

Q1 | Q1_OPT1 | Q1_OPT2 | Q1_OPT3 | Q1_OPT5 | Q1_ANS | Q2 | Q2_OPT1 | Q2_OPT2...

© Stack Overflow or respective owner

Related posts about mysql

Related posts about php