Search code examples
mysqldatabase-designsurvey

Simple survey database design


I'm creating a survey for visitors of my event. However it's been a while since I created a database. So I need some help.

I found some solutions but they are way to extensive and that is something I don't need.

Visitors need to stay anonymous but they can leave their email behind (seperate table Emails that isn't linked to anything atm). They have about 20 questions, some are open, some are one option(radio) and some are multiple options (checkboxes). The questions need to be reusable. That's about it. I just don't know how to go beyond the many-to-many in the diagram you see below. Survey databasedesign

How do I go from here? An Answers table needs to have a relationship with? The Surveys_have_Questions, or with Questions?

Edit:

As the answer in the following links mentions, most surveys are based upon classic design patterns. Mine is one of those surveys. More info in the link below: What mysql database tables and relationships would support a Q&A survey with conditional questions?


Solution

  • I would probably model the event of a user taking a survey, perhaps a table called "User_Answer_Session", which has links to the survey and the user; and then "User_Answers", which are tied to the session and the question and include the actual blob of the answer. How exactly I modeled the answers would depend on a few things (mainly how robustly I wanted to be able to look them up). For instance, do I want to be able to index multiple-choice answers for extremely rapid reporting? If so, then you need to model for that. This may include creating a "Question_Options" table, which is a one-to-many between a question and the available options...

    This should get you thinking along a good path. :-)