title: Mongodb real basic use case
body: <p>I'm approaching the noSQL world.
  I studied a little bit around the web (not the best way to study!) and I read the Mongodb documentation.
  Around the web I wasn't able to find a real case example (only fancy flights on big architectures not well explained or too basic to be real world examples).</p>
  
  <p>So I have still some huge holes in my understanding of a noSQL and Mongodb.</p>
  
  <p>I try to summarise one of them, the worst one actually, here below:</p>
  
  <p>Let's imagine the data structure for a post of a simple blog structure:</p>
  
  <pre><code>{
  "_id": ObjectId(),
  "title": "Title here",
  "body": "text of the post here",
  "date": ISODate("2010-09-24"),
  "author": "author_of_the_post_name",
  "comments": [
                {
                "author": "comment_author_name",
                "text": "comment text",
                "date": ISODate("date")
                },
                {
                "author": "comment_author_name2",
                "text": "comment text",
                "date": ISODate("date")
                },
                ...
              ]
  }
  </code></pre>
  
  <p>So far so good.</p>
  
  <p>All works fine if the <code>author_of_the_post</code> does not change his name (not considering profile picture and description). 
  The same for all <code>comment_authors</code>.</p>
  
  <p>So if I want to consider this situation I have to use relationships:</p>
  
  <pre><code>"authorID": &lt;author_of_the_post_id&gt;,
  </code></pre>
  
  <p>for post's author and</p>
  
  <pre><code>"authorID": &lt;comment_author_id&gt;,
  </code></pre>
  
  <p>for comments authors.</p>
  
  <p>But MongoDB does not allow joins when querying. So there will be a different query for each <code>authorID</code>.</p>
  
  <p>So what happens if I have 100 comments on my blog post?</p>
  
  <pre><code>1 query for the post
  1 query to retrieve authors informations
  100 queries to retrieve comments' authors informations
  
  **total of 102 queries!!!**
  </code></pre>
  
  <p>Am I right? </p>
  
  <p>Where is the advantage of using a noSQL here?
  In my understanding 102 queries VS 1 bigger query using joins.</p>
  
  <p>Or am I missing something and there is a different way to model this situation?</p>
  
  <p>Thanks for your contribution!</p>