Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8698693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:46:57+00:00 2026-06-13T01:46:57+00:00

Right, so I’m about to start writing a blog for my website using Node.js

  • 0

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.

Searching around has produced a few "how to write a blog in Mongo" guides, but they don’t seem to cover the sort of things I’m running into issues with. Here’s my dilemma:

If I was to use MySQL, I would imagine my schema being something along these lines:

Posts:

ID, USER, DATE, TITLE, TAGS

Comments:

POST_ID, USER, DATE, MESSAGE

Users:

ID, SCREEN_NAME, IMAGE_URL

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?

Alternately, using something like MongoDB, I was looking at formatting it like this:

Posts collection:

{ 
    {
    _ID: something
    USER: {id: id, name: "screen name", image: "image_url"}
    DATE: ...
    TITLE: ...
    TAGS: [tag1, tag2...]
    COMMENTS: 
         [
         {USER:someone, DATE:something, MESSAGE:"hi"},
         {USER:someone, DATE:something, MESSAGE:"another message"}
         ]
    },
    {
    _ID: something,
    USER: {id: id, name: "screen name", image: "image_url"},
    DATE: ...
    TITLE: ...
    TAGS: [tag1, tag2...]
    COMMENTS: 
         [
         ...
         ]
    },
}

So, comments are embedded within each post, which seems natural.

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.

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.

So…

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 "properly".

Has anyone had any experience doing something similar in either, or both languages?

What is your take on this, and specifically how do you handle the relationship between users and comments/posts?

Thanks in advance for any help 🙂
James

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:46:58+00:00Added an answer on June 13, 2026 at 1:46 am

    This question most definitely does not come down to performance since both MongoDB and SQL would pick a small dataset such as this the exact same way and so there would be no real measurable performance gain.

    The main idea of MongoDB in this situation is the ability to nest many tables within one and so making less queries to update your information, for example, instead of querying 12 tables you just query one. Not only that but sometimes the schema can be more natural to how you actually use the data.

    I would change a few things in your schema:

    USER: {id: id, name: "screen name", image: "image_url"}
    

    This should just be an ObjectId that relates to a user row and again in the comments:

    {USER:someone, DATE:something, MESSAGE:"hi"}
    

    use an ObjectId for the USER field. These ObjectIds would relate to a user collection. Also take out those capital letters, I sense that will be a pain to code around.

    As for dealing with relations:- you nest repeatable information to an entity as subdocuments (which would normally be normalised out in 1st NF), however that doesn’t mean you should nest to infinity, 3 levels maximum is normally advisable for querying compatibility also bare in mind the boundaries of app entities such as blog, post and user.

    Now you have to manage none nested relations such as the blog and user row (since posts will have comments etc nested). The way to solve these relations is client side, since MongoDB has no relational ideals (it’s a RDB heretic).

    You would simply do what MySQL would normally do server-side client side, of picking out the user individually and then picking out the posts based on that user id instead of picking out a huge result set of each row being a join between user and post tables.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I am using sqlite within a ios application, and I want to
I am reading a book about Javascript and jQuery and using one of the
Right guys, here's a bit of a discussion -- I'm creating a website with
Right now I am writing some Python code to deal with massive twitter files.
Right now I've been maintaining a second sandbox project where I test concepts and
Right now I'm using the following command to compile a coffeescript file each time
Right now I'm using OleDbDataAdapter objDataReader = new OleDbDataAdapter(); objDataReader.SelectCommand = myCommand; objDataReader.Fill(myDataTable); But
Right now, to be sure I am getting what I want I am using
Right now, I have three models Post, Comment and User (using Devise ) associated
Right below the start of the <body> tag, I want to include a script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.