What is an effective way to store a questionnaire in a database?

Since the questionnaires can always change, and the questions themselves can be long, it seems silly to use the questions as column names. Is there any agreement or proven method for storing the questionnaire in the database?

I thought of having a table with (Question-ID, Question), and then a second table for the question and answer identifier. But this solution may be too slow, because a third connection is required to join questions to a specific user.

+3
source share
4 answers

What happened to joining? That the whole point of the relational database, the union.

Save questions in one table.

Keep answers to questions in another table.

, , QuestionID .

, . .

+2

, , . - - , .

0

, /, , -. . db, -.

0

, , , - .

JonH. , , .

:

  • : Id (PK), , , OrderNumber, SectionId (FK to QuestionsSections.Id), AnswerTypeId (FK to AnswerType.Id)
  • : Id (PK), Answer, SubmitDate, UserId (FK to Users.Id), QuestionId (FK to Questions.Id)
  • : Id (PK), ,
  • Questions: QuestionnaireId (PK, FK to Questionnaire.Id), QuestionId (PK, FK to Questions.Id)
  • QuestionsSections: Id (PK), Name, Description, OrderNumber
  • : Id (PK), ,

In addition, you may prefer to create a special table for answer options (for example, radio stations, flags, etc.) or activity tracking tables depending on the needs of your application.


The following are links that may be helpful (suggested sequence for reading from top to bottom):

0
source

Source: https://habr.com/ru/post/1784095/


All Articles