Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      June 1, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      June 1, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      June 1, 2025

      How To Prevent WordPress SQL Injection Attacks

      June 1, 2025

      7 MagSafe accessories that I recommend every iPhone user should have

      June 1, 2025

      I replaced my Kindle with an iPad Mini as my ebook reader – 8 reasons why I don’t regret it

      June 1, 2025

      Windows 11 version 25H2: Everything you need to know about Microsoft’s next OS release

      May 31, 2025

      Elden Ring Nightreign already has a duos Seamless Co-op mod from the creator of the beloved original, and it’ll be “expanded on in the future”

      May 31, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Student Record Android App using SQLite

      June 1, 2025
      Recent

      Student Record Android App using SQLite

      June 1, 2025

      When Array uses less memory than Uint8Array (in V8)

      June 1, 2025

      Laravel 12 Starter Kits: Definite Guide Which to Choose

      June 1, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Photobooth is photobooth software for the Raspberry Pi and PC

      June 1, 2025
      Recent

      Photobooth is photobooth software for the Raspberry Pi and PC

      June 1, 2025

      Le notizie minori del mondo GNU/Linux e dintorni della settimana nr 22/2025

      June 1, 2025

      Rilasciata PorteuX 2.1: Novità e Approfondimenti sulla Distribuzione GNU/Linux Portatile Basata su Slackware

      June 1, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»Databases»Busting the Top Myths About MongoDB vs Relational Databases

    Busting the Top Myths About MongoDB vs Relational Databases

    February 10, 2025

    I was talking with a friend of mine recently about deciding between databases for an upcoming project. I asked him his thoughts on MongoDB. He told me that he did not think it would work based on what he knew about it. The only issue was that everything he learned about MongoDB was from 2013. He had not kept up with over a decade of improvements and updates. From talking with other developers this seems to be a pretty common situation. A lot of developers got a first impression of MongoDB in 2012-2014 and made up their minds based on that. In this post, we will dive into some database history and look at how MongoDB compares to relational databases today.

    As a quick refresher, there are a number of types of databases, but we will be focusing on relational and NoSQL document databases since those are two of the most popular types in use today. Relational databases were introduced in the 1970s and store data in tables. While the term NoSQL was coined in 1998 by Carlo Strozzi, it took a few more years for NoSQL databases and their more flexible approach to storing data to really take off. In 2009 MongoDB launched with the idea of storing data in documents similar to JSON objects. When I am explaining the basic difference between relational and document databases to my family, I usually say one is like a spreadsheet and the other is like a Google Doc. I am still not sure how much my grandma understands about what my job is, but at least she knows the difference between database types now.

    OK, now that we have covered the basics, we will take a look at misconceptions that come up when comparing MongoDB to relational databases.

    Myth 1: MongoDB does not have a schema

    Schemata define the structure of data in a database. With relational databases, you typically design your schema based on normalizing your data. Normalizing means you split up your data into different tables so that you do not duplicate data. These defined schemata are great if you can anticipate all your future data needs and elegantly design them in advance. Updating these schemata to add new fields can add extra work and downtime for your application.

    A set of data tables showing how relational data is split up. One table is labled Users, one is labeled professions, and the third is labeled cars.
    Figure 1. A simple set of relational data split across 3 tables.

    With MongoDB, your schema is dependent on the needs of your application. This is a more flexible approach to schema design. Now even though there is flexibility, there are still best practices like the rule that “data that is accessed together should be stored together.”

    Here is an example of the relational data from above stored in MongoDB:

    {
    "first_name": "Paul",
    "surname": "Miller",
    "cell": "447557505611",
    "city": "London",
    "location": [45.123, 47.232],
    "profession": ["banking", "finance", "trader"],
    "cars": [
        {
            "model": "Bentley",
            "year": 1973
        },
        {
            "model": "Rolls Royce",
            "year": 1965
        }
    ]
}


    You can see in this example that you are able to get all the data on “Paul Miller” without having to do JOINS on three different tables. You can do JOINS in MongoDB, but more on this later.

    With a flexible schema, developers are able to start building applications without having to design beforehand the definitive schema, and then constraining themselves to it. You can easily add new fields to your schema whenever the application requires it. If you want to have that more structured schema, you can use MongoDB’s schema validation feature. If you need your schema to evolve over time, you can also easily implement the schema versioning pattern.

    Ultimately I think this myth of MongoDB having no schema comes down to two things. First, it did not have schema validation in the early days (it was added in version 3.6 in 2017). The other reason comes from the flexibility developers have in creating their schema based on the needs of their applications. Freedom and flexibility does not mean not having a schema; it just means it is important to follow best practices to create an elegant schema that makes your application run optimally.

    Myth 2: MongoDB is not ACID compliant

    Databases need ways to make sure that operations and the resulting data are reliable even when errors or power failures occur. The main way they do this is by implementing four properties: atomicity, consistency, isolation, and durability, also known as ACID.

    MongoDB is ACID compliant. Every time that you perform any create, read, update, and delete operation on a single document, data integrity is preserved. MongoDB handles data one document at a time. Otherwise, it would not be a document database. It would be a chaotic, unpredictable database. Can you imagine lots of writers trying to overwrite the same document at the same time? I have been in some Google docs with 10+ writers all contributing at the same time, and it certainly does not feel ACID compliant.

    That covers single documents, but what happens with multidocument transactions? Multidocument transactions are used frequently in relational databases, since you often have to access multiple tables when doing things like updating a customer record. MongoDB guarantees multidocument ACID transactions from and to any location in your MongoDB cluster. It has supported this guarantee since version 4.0 back in 2018.

    In fact, transactionality is one of MongoDB’s greatest strengths. Many financial services companies trust MongoDB transactions for core banking and trading use cases. The all-or-nothing guarantee of MongoDB multidocument transactions has got your back.

    Myth 3: MongoDB cannot make JOINS to handle relational data

    Earlier we showed how relational databases rely on data split across multiple tables for efficient schema design. To work with relational data, you often need to pull data from those tables and combine them using JOINS.

    MongoDB can do JOINS with the $lookup command. But the fact that you can do something does not mean you should. MongoDB data is modeled in a different manner than relational data. In MongoDB, data that is accessed together is stored together. With most of the data in a single document instead of spread across multiple tables, you would not need to do any JOINS since the data is already in the right place. This shift from the relational model to the document model is a big mindset shift, but once you experience the benefits, it is hard to go back. However, if you still need to do JOINS with MongoDB, the command $lookup is your best ally. You can even create a VIEW (added in 2016) to join two collections.

    The myth that JOINS are not possible ultimately comes down to the basic difference between the relational and document models. Data accessed in tables and data accessed in documents require different approaches, but generally, even though you can do JOINS in MongoDB, you will not need to if you have designed the schema for your documents well.

    To learn more about MongoDB, head over to MongoDB University and take our free Intro to MongoDB course.

    Sign up for a free Atlas cluster today to see what MongoDB Atlas is capable of.

    Check out the full video to learn about the other 6 myths that we’re debunking in this series.

    Source: Read More

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleCreating My First Game Prototype in a Browser: The Journey So Far
    Next Article HydePHP – The Static Site Generator with Caen De Silva

    Related Posts

    Artificial Intelligence

    Markus Buehler receives 2025 Washington Award

    June 1, 2025
    Artificial Intelligence

    LWiAI Podcast #201 – GPT 4.5, Sonnet 3.7, Grok 3, Phi 4

    June 1, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    IncarnaMind: An AI Tool that Enables You to Chat with Your Personal Documents (PDF, TXT) Using Large Language Models (LLMs) like GPT

    Development

    Your Oura Ring just got one of its biggest feature updates ever – for free

    News & Updates

    How a Design Leader Connects the Dots to UX Research

    Web Development

    New Chrome Zero-Day Vulnerability CVE-2024-4761 Under Active Exploitation

    Development

    Highlights

    CVE-2025-46822 – Apache Spring Boot Java Path Traversal Vulnerability

    May 21, 2025

    CVE ID : CVE-2025-46822

    Published : May 21, 2025, 6:15 p.m. | 2 hours, 26 minutes ago

    Description : OsamaTaher/Java-springboot-codebase is a collection of Java and Spring Boot code snippets, applications, and projects. Prior to commit c835c6f7799eacada4c0fc77e0816f250af01ad2, insufficient path traversal mechanisms make absolute path traversal possible. This vulnerability allows unauthorized access to sensitive internal files. Commit c835c6f7799eacada4c0fc77e0816f250af01ad2 contains a patch for the issue.

    Severity: 0.0 | NA

    Visit the link for more details, such as CVSS details, affected products, timeline, and more…

    Generative AI-powered game design: Accelerating early development with Stability AI models on Amazon Bedrock

    March 26, 2025

    7 Ways META Governments Are Boosting Cybersecurity

    June 2, 2024

    Community News: Latest PECL Releases (02.11.2025)

    February 11, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.