I wanna make my own php quiz, but I'm not sure how I should make the database setup.
Should I make 3 tables, 1 with the questions, 1 with the alternatives and the last one containing the id of the question and the id of the righ answer ? is this a good way or is there a more easy way to do this ?
Thanks in advance
Best Regards
@mpersand
phpQuiz
Moderator: General Moderators
- AVATAr
- Forum Regular
- Posts: 524
- Joined: Tue Jul 16, 2002 4:19 pm
- Location: Uruguay -- Montevideo
- Contact:
maybe you need only two tables.
One with your questions, and one with the answers, and in this one mark the correct answer with some field
Table_Questions
QuId // id
QuTxt //Texto of the Question
Table_Answers
AnsId // id
AnsTxt // Text of the answer
AnsCorrect //check it if it is the correct answer
QuId // The id of the question
One with your questions, and one with the answers, and in this one mark the correct answer with some field
Table_Questions
QuId // id
QuTxt //Texto of the Question
Table_Answers
AnsId // id
AnsTxt // Text of the answer
AnsCorrect //check it if it is the correct answer
QuId // The id of the question
I think AVATAr suggestion is good. I would avoid McGruff's.
Sticking multiple options within a single column using a deliminator is practically a "repeating group" one of the big no-no's of database desing. (The table is not even in First Normal Form.) It will make adding/ reordering/ updating answer options very difficult compared to a proper design. It also makes it harder to generate stats on the quiz. If you want to preform aggregate queries to count the number of options for each question, a simple SQL query could do it with a proper design, but not with the deliminator based design.
The design also "hides" information from the database and hence violates the "Information Principle" which is possibly the most important design guideline in database design. It basically says nothing should have implicit meaning -- nothing hidden from the database.
Sticking multiple options within a single column using a deliminator is practically a "repeating group" one of the big no-no's of database desing. (The table is not even in First Normal Form.) It will make adding/ reordering/ updating answer options very difficult compared to a proper design. It also makes it harder to generate stats on the quiz. If you want to preform aggregate queries to count the number of options for each question, a simple SQL query could do it with a proper design, but not with the deliminator based design.
The design also "hides" information from the database and hence violates the "Information Principle" which is possibly the most important design guideline in database design. It basically says nothing should have implicit meaning -- nothing hidden from the database.