Database design for general web form

后端 未结 1 339
一向
一向 2021-01-21 11:02

I want to build a back end of a general web form which contains questions which the user can answer. There are multiple types of questions.

  • \"Normal\" text questio
1条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-21 11:42

    First off, let's agree to veto the idea of storing HTML in the database, except, maybe a few tags such as line-breaks, bold, emphasis and underline, for the question's text only. Defining the surveys and exploiting their output will be so much easier if the focus is on the text/semantics of the survey, rather than View details.

    To support View ("layout") configuration CSS could be the ticket. This would key on the ID of the question which would be used as ID to the div (or other html container) where the View decides to store the question. a few class names could also be listed in the question record, but defined in CSS.

    On the proposed database schema, the important stuff seems to be there. I don't see however where the submitted responses get stored; is that in submission + submitiondetails tables? If so, where do the MULTIPLE response type get stored, are they converted to text, into givenanswer? (I don't think they should, unless we prefer capturing slightly different values when the survey was modified during the campaign.)

    A few missing attributes and ideas:

    • MULTIPLE (or another type) should be made able to support "radio-button" type choices ("only-one-of"). a possible way to do this is to add an attribute to the type, to define the max number of choices allowed, a common survey thing: "pick 3 among the following..."
    • The question record could have a "campaign" or SurveyID, allowing to store multiple surveys in the same store.
    • Without geting too fancy, some questions could be predicated to a previous "boolean" type question. (If polled person respond "no" to own a car, do not ask about the frequency of oil changes...) This could be defined by a questionID and a ResponseValue (?text for genericity?).
    • question table: add a 'Page Number', allowing to group the questions (unless this info is defined in a question container concept such as "survey" or "campaign")
    • question table: add 'Sequence Number' allowing to get questions in a predefined order (unless such comes from a Survey/campaign table not shown here)
    • q_multiplechoice: (or whatever table is where the options for a given MULTIPLE CHOICE are listed; I'm having doubt about this table seeing its fields as showin in the question.) add a Sequence Number, allowing to list the options in a particular order.

    0 讨论(0)
提交回复
热议问题