Connecting Tech Pros Worldwide Forums | Help | Site Map

Storing Multiple Survey Formats and Answers

Newbie
 
Join Date: Oct 2008
Posts: 4
#1: Nov 30 '08
I am writing a web application with a MySQL backend that will have multiple users taking various surveys. Each survey has a different number of questions; each question has two types of answers: string and enum; each enum has different numbers of values.

I want to be able to dynamically create the survey, assign questions, set question types (string/enum), assign enum variables if necessary, and save the data for each survey.

I am completely lost as to how the structure of the database should be in order to account for the different types of questions and answers. Help is greatly appreciated.

KUB365's Avatar
Administrator
 
Join Date: Jul 2005
Location: Portland, OR
Posts: 970
#2: Dec 2 '08

re: Storing Multiple Survey Formats and Answers


Here's a quick mockup

table: survey
table: questions
table: results

Expand|Select|Wrap|Line Numbers
  1.  
  2. survey
  3. -----------
  4. surveyid
  5. surveytitle
  6. surveystartdate
  7. surveyenddate
  8. survey_totalquestions
  9.  
  10. questions
  11. -----------------
  12. questionid
  13. question_surveyid
  14. question_title
  15. question_type(enum,string)
  16. question_string
  17. question_enum_values (can insert array in here corresponding to each enum value)
  18.  
  19. results:
  20. ------------------------------------
  21. survey_userid
  22. survey_id
  23. question_id
  24. question_results
  25.  
That's probably the quick bare bones way i'd attack it. Though you can get very complex with survey collection data. Another way to quickly learn db schema for survey applications is browse through the db schema of an opensource survey application. Try freshmeat or sourceforge to find one
Reply