It is better to save the possible answers in a separate table. This allows you to get any number of answers to a question, not just 4. It also allows you to ask different answers. If you have more than one quiz, you may also need the Quites table.
Quizes: id name Questions: id quiz prompt Answers: id question prompt QuizResult (someone taking a quiz) id quiz
Now the right thing to answer is getting a lot more complicated. I prefer higher implementations here:
Every question matters, and every answer matters.
The system I recently worked with you can assign a point value for each question and each answer. Wrong answers often got 0, right answers got the full amount. You can also get partially correct answers using this method. This is the method I would go with.
You can go and say that each question costs 10 points, or you can assign different weights to different questions:
Questions: id quiz prompt value (you can make this question worth more or less) Answers: question prompt value (you can make this answer worth more or less)
Save the correct answer in the answer table
A simpler (but less reliable) solution is to simply say which answer is correct in the "Answers" table.
Answers: question prompt is_correct
Save the correct answer in the question table
I would not recommend it. When you create a question, it will not have the correct answer until you enter it. This means at least 3 questions to correctly ask a question. If you use foreign key dependencies, this will quickly become annoying.
Reece45
source share