title: Nested (children) comments within a single parent comment in MongoDB
body: <p>Question: Do I nest my child comments within a single parent comment or not?</p>
  
  <p>Overview:</p>
  
  <ul>
  <li><p>Creating comment system</p></li>
  <li><p>Comments can have children</p></li>
  <li><p>Right now each comment child or parent is stored as one record in a collection called <code>SubmissionCommentsSchema</code></p></li>
  <li><p>Child comments have a key => value of <code>parent_id</code> => <code>Object ID</code> where <code>Object ID</code> references a parent comment that has a <code>parent_id</code> of <code>null</code>.</p></li>
  </ul>
  
  <p>Schema looks like:</p>
  
  <pre><code>SubmissionCommentsSchema = new Schema({
    id : Schema.ObjectId,
    submission_id : {
      type: String
    },
    parent_id : {
      type: String,
      default: null
    },
    comment : {
      type: String,
      required: true
    },
    user_id: {
      type: String,
      required: true
    },
    username : {
      type: String,
      required: true
    },
    created : {
      type: Date,
      default: Date.now
    },
    reply : {
      type: Boolean,
      default: false,
      required: true
    },
    deleted : {
      type: Boolean,
      default: false
    }
  });
  </code></pre>
  
  <p>Example of a parent comment:</p>
  
  <pre><code>  { submission_id: '51899313634afe0000000051',
      comment: 'asdfadsf',
      user_id: '516e173f48670b44d20004dc',
      username: 'bobcobb',
      _id: 51899338634afe0000000055,
      deleted: false,
      reply: false,
      created: Tue May 07 2013 16:50:16 GMT-0700 (PDT),
      parent_id: null },
  </code></pre>
  
  <p>Example of a child comment referencing the above parent comment:</p>
  
  <pre><code>  { submission_id: '51899313634afe0000000051',
      comment: 'Testing one two four',
      user_id: '516b45f8ac6a1b488e000001',
      username: 'testing',
      _id: 519d93a83867470000000146,
      deleted: false,
      reply: false,
      created: Wed May 22 2013 20:57:28 GMT-0700 (PDT),
      parent_id: '51899338634afe0000000055' },
  </code></pre>
  
  <ul>
  <li>When serving these to a view, I pull them all back and loop through them to see which have <code>parent_id</code>s !== <code>null</code>. If so, then I put those in a list and append them to the parent comment and then dump those in the view.</li>
  </ul>
  
  <p>Should I just store the children comments within the original parent comment as a nested array?</p>