r/DatabaseHelp • u/Impallion • Jun 17 '15
Database for survey system
I have 5 surveys, each with approximately 80 questions, which the user is tasked with rating from 1-100%. What is the best way to handle a database like this, and being able to run analytics on the results?
I have experience with MySQL and PostgreSQL, and my first reaction was to either have a column for each answer, or more probably a column for each survey, extracting the data and parsing it through some other language for analysis.
Alternatively, are there any other database structures that would work better?
1
Upvotes
View all comments
Show parent comment
1
u/BinaryRockStar Jun 17 '15
OK well then I would suggest a design like the following:
This design allows for multiple Surveys, each survey having multiple Questions with each question having a response type that shows whether it's a straight text response, a multiple choice, single choice etc. For these multiple answer questions, the possible responses are stored in QuestionResponse.
CompletedSurvey holds completed survey details, with each answer stored in CompletelySurveyAnswer, including a ResponseValue which (depending on the Question's ResponseType) can be a FK to the QuestionResponse table.
There will need to be some modification based on your exact requirements but I believe this is fairly flexible yet simple.
EDIT: I just realised multi-choice answers would have to have their answers stored in ResponseText which is messy. Otherwise there would need to be yet another table which holds each multi-choice answer.