Ask how to design such a questionnaire database to be the most reasonable? A questionnaire contains 500 questions, each of which has five options. some ABCDE are general options, and some questions have other options, which must be entered by the user. As follows:
1. your title
A.111
B .222
C.333
D.444
E.555
2. your school
A.111
B .222
C.333
D.444
E. Others (please note :_________)
This questionnaire is required
1. you can count the number of candidates for each option on each question.
2. view the selection of each question for each user (print out the questionnaire)
How can I design such a database to facilitate the select operation in the future?
The most stupid way (my first response) is to handle a table containing more than 500 fields.
ID userid username timu1 timu2 timu3 ...... Timu500
In this way, there are too many fields, and some other fields selected for the question are not included yet.
Ask the heroes for help.
Reply to discussion (solution)
You don't need a 500 field. one is enough. you can save it with formatted data.
But the most important thing is the statistical needs. how to design a table to facilitate statistics?
Mysql limited number of fields <4096, line length <65535 bytes
Therefore, the actual number of available fields must be determined based on the field width and encoding type.
I used to solve this problem by considering whether this is a questionnaire.
A questionnaire means that all the questions should be read. of course, only some items (paging, jump questions, and other operations) may be displayed. in this case, there is no need to separate all fields, you can simply format json or xml. do not leave the workload to the database.
If it is not a questionnaire, but a question bank, that is to say, when generating a questionnaire, you should select several questions from these questions to form a questionnaire. in this way, it is not a field problem, but a problem record, each question is recorded as a record
In addition, for surveys (exams are similar in nature), the most important thing is to answer the questions rather than the questionnaire. as long as the questionnaire can be read, it is enough to give a complete reference to the answers, of course, the logic of some questionnaires is very complicated (the options between question jumps or questions are related ).
My suggestion is to take the time to create a table in the answer sheet to facilitate statistics. Once a questionnaire is formed, there are basically no additions, deletions, and modifications. If the answer sheet needs to be analyzed in detail, it involves statistics knowledge, A single "cross-analysis" may overwrite the original answer sheet design scheme.
I used to solve this problem by considering whether this is a questionnaire.
A questionnaire means that all the questions should be read. of course, only some items (paging, jump questions, and other operations) may be displayed. in this case, there is no need to separate all fields, you can simply format json or xml. do not leave the workload to the database.
If it is not a questionnaire, but a question bank, that is to say, when generating a questionnaire, you should select several questions from these questions to form a questionnaire. in this way, it is not a field problem, but a problem record ......
Thank you. how can we design a rational database to facilitate statistics? I am a newbie, so I have a lot of advice.
My suggestion is to separate different tables as long as the statistical methods are different.
For example, if you use different methods to make statistics for surveys A and B, the two tables are separated.
If the statistical methods are the same, you can put them in the same table and add a field to distinguish AB.
If the difference in statistical methods does not involve database reading, for example, reading all the arrays and then using different methods, there is no need for table sharding.
I used to use one table for Questionnaire, answer, and logic.