Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

alessandrobelli's avatar

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?

0 likes
1 reply
Braunson's avatar
Braunson
Best Answer
Level 18
  • admins

  • users

  • surveys

    • admin_id
    • name
  • 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..

1 like

Please or to participate in this conversation.