MySQL Vs MongoDB

MongoDB– One single main benefit over MySQL is its ability to handle large unstructured data. It is magically faster. People are experiencing real world MongoDB performance mainly because it allows users to query in a different manner that is more sensitive to workload.

When to use MongoDB?

  • When you need high availability of data with automatic, fast and instant data recovery.
  • In future, if you’re going to grow big as MongoDB has in-built sharding solution.
  • If you have an unstable schema and you want to reduce your schema migration cost.
  • If you don’t have a Database Administrator (but you’ll have to hire one if you’re going to go BIG).
  • If most of your services are cloud-based, MongoDB is best suitable for you, as its native scale-out architecture enabled by ‘sharding’ aligns well with horizontal scaling and agility offered by cloud computing.

When to use MySQL?

  • If you’re just starting and your database is not going to scale much, MySQL will help you in easy and low-maintenance setup.
  • If you’ve fixed schema and a data structure aren’t going to change over the time like Wikipedia.
  • If you want high performance on a limited budget.
  • If high transaction rate is going to be your requirement (like BBC around 30,000 inserts/minute, 4000 selects/hour)
  • If data security is your top priority, MySQL is the most secure DBMS.

Who uses MySQL OR MongoDB?

  • MySQL : Some Organisations that use MySQL include Pinterest, Twitter, Youtube, Netflix, Spotify, US Navy, NASA, Walmart and Paypal.
  • MongoDB: Used by many organisations including Klout, Citrix, Twitter, T-Mobile, Zendesk, Sony, Hootsuite, SurveyMonkey, MuleSoft, Foursquare and InVision.

What Types Of Replication / Clustering Are Available?

  • MySQL: MySQL supports master – slave replication and master – master replication (as of MySQL 5.7.6 and later). Multisource replication allows you to replicate from several masters in parallel.
  • MongoDB: MongoDB supports built-in replication, sharding, and auto-elections. Using auto-elections, you can set up a secondary database to automatically take over if the primary database fails. Sharding allows for horizontal scaling, which is difficult to implement in MySQL.

Which Database Is Right For Your Business?

  • MySQL: There are many use cases for a relational database like MySQL. Any type of application that requires multi-row transactions such as an accounting system, would be better suited for a relational database. MongoDB is not an easy replacement for legacy systems that were built for relational databases.
  • MongoDB: On the other hand, there are a variety of use cases where MongoDB is well-suited. Some of these include real-time analytics, content management, the internet of things, mobile, and other types of applications that are new and can take advantage of what MongoDB has to offer.

Integrity Model- ACID and BASE

  • MongoDB: This follows the BASE (Basic Availability, Soft-state and Eventual consistency) model till below version of 4.x. MongoDB also added ACID transactions in MongoDB 4.0
  • MySQL: This follows the ACID (Atomic, Consistent, Isolated and Durable) model. This means that once a transaction is complete, the data remains consistent and stable on the disc which may include distinct multiple memory locations.

CAP Theorem: Consistency, Availability & Partition

  • MongoDB: MongoDB database under the CAP theorem opts for Consistency & Partition tolerance (i.e. CP). What does this mean? This means that the consistent view of the database will be available for all the clients to see.
  • MySQL: MySQL database under the CAP theorem opts for Consistency & Availability (i.e. CA). What does this mean? This means that data will be consistent between all nodes as long as nodes are online.

  • 23
    Shares

One Reply to “MySQL Vs MongoDB”

Comments are closed.