Click here to Skip to main content
15,886,840 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello i want to know the approach to store multiple choice questions and display it on web page .
I already did display of single answer questions, but have to update it multiple choices
in table i have question id , user id, subject id, no of correct answers.
Posted
Updated 25-Feb-16 23:18pm

1 solution

This could be one way to structure:

Question
Id
Text

Answers
Id
Text
QuestionId

CorrectAnswers
QuestionId
AnswerId


Reason for having a separate table for correct answer is that one question can have more than one correct answers. If that is not the case, you can omit third table and just add a field called CorrectAnswerId to Questions table.

If there is a chance that same answer can be used for multiple questions, you might as well remove QuestionId from Answers table and add IsCorrect field to CorrectAnswers table. This will reduce the size of your database. However, if you make change to answer for one question, it will change it for all the questions that are using it.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900