title: sql database design: model attribute has infinite results
body: <p>I'm currently storing user-generated surveys in JSON files, and am now converting these to a sql database. Regarding this portion of JSON:</p>
  
  <pre><code>"surveys": [
          {
              "surveyId": 1,
              "name": "Landing Page Survey",
              "active": true,
              "panes": [
                  {
                      "type": "question",
                      "name": "Question",
                      "head": "Is there anything preventing you from signing up for a free 14-day trial?",
                      "response": "textbox",
                      "options": [
                          {
                              "data": "Time",
                              "target": "Response 1",
                              "placeholder": "",
                              "list": "f7b3cdeed8"
                          },
                          {
                              "data": "Money",
                              "target": "Response 1",
                              "placeholder": "",
                              "list": "local"
                          },
                          {
                              "data": "I'm not interested",
                              "target": "Thanks",
                              "placeholder": "",
                              "list": "local"
                          }
                      ],
                      "button": "Send"
                  },
                  {
                      "type": "response",
                      "name": "Response 1",
                      "head": "Thanks for your interest in our product. Enter your email address to have a team member follow-up with you.",
                      "response": "email",
                      "options": [
                          {
                              "data": "data",
                              "target": "Thanks",
                              "placeholder": "Your email",
                              "list": "f7b3cdeed8"
                          }
                      ],
                      "button": "Submit"
                  },
                  {
                      "type": "thanks",
                      "name": "Thanks",
                      "head": "Thanks for your feedback!",
                      "response": "multichoice",
                      "options": [
                          {
                              "data": "data",
                              "target": "",
                              "placeholder": "put response here",
                              "list": "local"
                          }
                      ],
                      "button": "Button text"
                  }
              ]
  </code></pre>
  
  <p>The JSON isn't that important, just posting so you can see the idea.. surveys.panes are the questions of the survey. Each survey could have an infinite number of questions in it, so I'm struggling with how to store those.</p>
  
  <p>Originally I was thinking of having a surveys table with columns for the questions, 'question_1_type, question_1_text', etc.. This would work if each survey was limited to an amount of questions (10 for example, so I could create 10 sets of columns). This feels horribly wrong though.</p>
  
  <p>Or is it more correct to create a questions table, and for each question in a survey create a row in the questions table. Link it to the survey table with an id, then when you want to output the survey JSON for an API or whatever, just do a bunch of joins across the survey and questions table.</p>
  
  <p>Also, if a survey question is multiple choice, it could have an infinite number of response options also, so would you have to build a table for those as well? Then for each survey JSON build you'd have to join across the surveys, questions, and question_options table. That seems like a lot of overhead running all the joins..</p>
  
  <p>But as I understand, it's incorrect to store anything but one value in a column (an array for example) as it defeats the relational idea of a sql db.</p>
  
  <p>Very noob question.. I haven't quite wrapped my head around correct database design. Appreciate any help!</p>