Database design suggestion
I'm currently building an app that involves questions and answers.
- Admins create a questionnaire with questions and related answers
- The user in the frontend answers.
The difficult point comes when I have to save all the answers and the chosen one because I have several answer type:
- open answer [user write something and I save it]
- multiple answer [user choose from a pool of prewritten answers]
- scale [ a range of numbers ]
open and multiple answers can be combined.
How would you design this part?
-
admins
-
users
-
surveys
-
survey_questions
- survey_id
- question
- survey_answer_id
-
survey_answers
- survey_id
- survey_question_id
- answer
-
survey_user_answers
- survey_id
- survey_question_id
- user_id
- answer
A survey can/has many questions. You can make use of the JSON/array type to store the possible answer options.
That's just one way to do it..
Please or to participate in this conversation.