title: database schema for storing questionnaires and multiple choice answers
body: <p>We need some help in designing database schema for questionnaires and multiple choice answers. </p>
  
  <p>The first options is to design a question table and an answer table like below</p>
  
  <pre><code> * Question Table
     - question_id    auto integer
     - question       varchar
  
   * Answer Table
     - user_id        integer
     - question_id    integer
     - answer         integer 
  </code></pre>
  
  <p>However, the issue with this design is that, when a user submit answers to questionnaires, multiple rows need to be inserted and hence both write as well retrieving will be slower. Also, the table will grow very big. However, the advantage is that it's expandable and new questions can be added easily. </p>
  
  <p>Another approach is to have all the answers in one row but in different column, like this</p>
  
  <pre><code> * Answer Table
     - user_id        integer
     - answer_1       integer 
     - answer_2       integer 
     ...
     - answer_n       integer 
  </code></pre>
  
  <p>Advantage is that, at a time only one row to write or retrieve and hence it will be much faster than the first approach. However, schema will be rigid and if any new questions is added, db schema will have to be changed to accomodate a new column.</p>
  
  <p>We have over 3 million users and multiple questionnaires per user. Hence the speed is definitely a criterion. Based on this criterion, which one do you prefer? Any other alternatives? </p>
  
  <p>Thanks</p>