title: MongoDB design for scalability
body: <p>We want to design a scalable database. If we have N users with 1 Billion user responses, from the 2 options below which will be a good design? We would want to query based on userID as well as Reponse ID. </p>
  
  <ol>
  <li>Having 2 Collections one for the user information and another to store the responses along with user ID. Each response is stored as a document so we will have 1 billion documents.</li>
  </ol>
  
  <pre>
      User Collection
      {
        "userid" : "userid1",
        "password" : "xyz",
        ,
        "City" : "New York",
      },
      {
        "userid" : "userid2",
        "password" : "abc",
        ,
        "City" : "New York",
      }
  
  
      responses Collection
      {
        "userid": "userid1",
        "responseID": "responseID1",
        "response" : "xyz"
      },
      {
        "userid": "userid1",
        "responseID": "responseID2",
        "response" : "abc"
      },
      {
        "userid": "userid2",
        "responseID": "responseID3",
        "response"  : "mno"
      }
  </pre>
  
  <ol>
  <li>Having 1 Collection to store both the information as below. Each response is represented by a new key (responseIDX). </li>
  </ol>
  
  <pre>
      {
        "userid" : "userid1",
        "responseID1" : "xyz",
        "responseID2" : "abc",
        ,
        "responseN"; "mno",
        "city" : "New York"
      }
  </pre>