title: Making a blog; can't decide between MongoDB and MySQL
body: <p>Right, so I'm about to start writing a blog for my website using Node.js (as much as a learning process as anything), and I've been fiercely debating with myself which of either MySQL or MongoDB to use.</p>
  <p>Searching around has produced a few &quot;how to write a blog in Mongo&quot; guides, but they don't seem to cover the sort of things I'm running into issues with. Here's my dilemma:</p>
  <p>If I was to use <em>MySQL</em>, I would imagine my schema being something along these lines:</p>
  <h3>Posts:</h3>
  <pre><code>ID, USER, DATE, TITLE, TAGS
  </code></pre>
  <h3>Comments:</h3>
  <pre><code>POST_ID, USER, DATE, MESSAGE
  </code></pre>
  <h3>Users:</h3>
  <pre><code>ID, SCREEN_NAME, IMAGE_URL
  </code></pre>
  <p>So, each post has associated comments, and posts and comments have associated users. The advantage is that if a user wishes to change their screen name, or image, only one row in the users table needs to be updated. However, offhand I'm not sure however how I would, say, get all of the posts containing X tags, unless perhaps I have multiple fields for multiple potential tags?</p>
  <p>Alternately, using something like <em>MongoDB</em>, I was looking at formatting it like this:</p>
  <h3>Posts collection:</h3>
  <pre><code>{ 
      {
      _ID: something
      USER: {id: id, name: &quot;screen name&quot;, image: &quot;image_url&quot;}
      DATE: ...
      TITLE: ...
      TAGS: [tag1, tag2...]
      COMMENTS: 
           [
           {USER:someone, DATE:something, MESSAGE:&quot;hi&quot;},
           {USER:someone, DATE:something, MESSAGE:&quot;another message&quot;}
           ]
      },
      {
      _ID: something,
      USER: {id: id, name: &quot;screen name&quot;, image: &quot;image_url&quot;},
      DATE: ...
      TITLE: ...
      TAGS: [tag1, tag2...]
      COMMENTS: 
           [
           ...
           ]
      },
  }
  </code></pre>
  <p>So, comments are embedded within each post, which seems natural.</p>
  <p>Here, one query can retrieve me all of the posts which match which is great. On the other hand, what if I need to update the screen name or image that a user uses? It seems hard to dig into embedded objects within a given document, let alone update all of the relevant records across every post.</p>
  <p>I could move the comments into a separate collection to make them more accessible, but I'd still be faced with doing lots of updates on things like screen names.</p>
  <h3>So...</h3>
  <p>Essentially, I would prefer to use MongoDB, as what it can do, it can do very easily, and getting to work with one language across the board is nice. However, I cant help but feel that I need to adopt a relational approach in order to get things done &quot;properly&quot;.</p>
  <p>Has anyone had any experience doing something similar in either, or both languages?</p>
  <p>What is your take on this, and specifically how do you handle the relationship between users and comments/posts?</p>
  <p>Thanks in advance for any help :)
  James</p>