SQL design for survey with answers of different data types

前端 未结 4 591
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-06 06:32

I am working on an online survey. Most questions have a scale of 1-5 for an answer. If we need to add a question to the survey, I use a simple web form, which does an INSERT

4条回答
  •  走了就别回头了
    2021-01-06 06:40

    You want to create a QuestionType table that corresponds to a QuestionType class. Allow the persisted Answer filled in by your users to be free-form text, and leave it up to the QuestionType to determine what the answer means.

    So- if it's true/false, the Answer could be 'T' or 'F'.

    If it's multiple choice, the Answer could be the index of the selected choice.

    If it's a text box the users fills in, save the text they enter.

提交回复
热议问题