Subscribe to DSC Newsletter

The comparison between MongoDB, the poster child of NoSQL, and MySQL has been raging for a while now. It is important that you know the difference between the two as this will assist you in making an informed decision.


The Major Differences between MongoDB and MySQL

1. There is a difference in the representation of data in the two databases. In MongoDB, data represents in a collection of JSON documents while in MySQL, data is in tables and rows. JSON documents can compare to associative arrays when using PHP and directory objects when using Python.

2. When it comes to querying, you have to put a string in the query language that the DB system parses. The query language is called Structured Query Language, or SQL,from where MySQL gets its name. This exposes your DB susceptible to SQL injectionattacks. On the other hand, MongoDB’s querying is object-oriented, which means you pass MongoDB a document explaining what you are querying. There is no parsing whatsoever, which will take some time getting used to if you already use SQL.

3. One of the greatest benefits of relational databases like MySQL is the JOIN operation. The operation allows for the querying across several tables. Although MongoDB doesn’t support joints, it supports multi-dimensional data types like other documents and arrays.

4. With MySQL, you can have one document inside another (embedding). You would have to create one table for comments and another for posts if you are using MySQL to create a blog. In MongoDB, you will only have one array of comments and one collection of posts within a post.

5. MySQL supports atomic transactions. You can have several operations within a transaction and you can roll back as if you have a single operation. There is no support for transactions in MongoDB and the single operation is atomic.

6. One of the best things about MongoDB is that you are not responsible for defining the schema. All you need to do is drop in documents. Any 2 documents in a collection need not be in the same field. You have to define the tables and columns before storage in MySQL. All rows in a table share the same columns.

7. MongoDB’s performance is better than that of MySQL and other relational DBs. This is because MongoDB sacrifices JOINS and other things and has excellent performance analysis tools. Note that you still have to index the data and the data in most applications is not enough for them to see a difference. MySQL is criticized for poor performance, especially in ORM application. However, you are unlikely to have an issue if you do proper data indexing and you are using a database wrapper.

8. One advantage of MySQL over NoSQL like MongoDB is that the community in MySQL is much better than NoSQL. This is mostly because NoSQL is relatively new while MySQL has been around for several years.

9. There are no reporting tools with MongoDB, meaning performance testing and analysis is not always possible. With MySQL, you can get several reporting tools that help you rove the validity of your applications.

10. RDBSs function on a paradigm called ACID, which is an acronym for (Atomicity, Consistency, Isolation, and Durability). This is not present in MongoDB database.

11. MongoDB has a Map Reduce feature that allows for easier scalability. This means you can get the full functionality of MongoDB database even if you are using low-cost hardware.

12. You do not have to come up with a detailed DB model with MongoDB because of is non-relational. A DB architect can quickly create a DB without a fine-grained DB model, thereby saving on development time and cost.

MongoDB: A Brief Overview

  • Several organizations that have to deal with big data are increasingly using MongoDB. MongoDB is a good tool in handling database comprising unstructureddata.
  • The NoSQL idea saw first creation in 1998. Carlo Strozzi was the first person to create the DB management system that was characterized by stream-operator paradigm for accessing data, instead of the traditional SQL syntax. The steam- operator paradigm resembles a mathematical operation. However, NoSQLs like MongoDB still use RDBMS model.
  • MongoDB is one of the most popular NoSQL solutions. Its main purpose is to assist in data storage and the solution can indeed store documents on the World Wide Web. MongoDB was first built in 2007. One of its most outstanding features is data storage in a dynamic schema, as opposed to the tabular DB characteristic of SQL.
  • The MongoDB data bases on the JSON (Java Script Object Notation) format. JSON allows for the transfer of data between web applications and servers using a human readable format. Before JSON, XML was used for this. JSON is defined in MongoDB’s BSON (Binary JSON). The binary format of BSON provides reliability and greater efficiency when it comes to speed and storage space.
  • Clients who want a document-oriented DB mostly use MongoDB. The most prominent of these is Craigslist with over 2 billion records in MongoDB storage. Other prominent users are Shutterfly with over 18 billion photos, Foursquare, New York Times and Forbes, among many others.

MySQL: A Brief Overview

  • MySQL is synonymous with RDBMS. Its first release was in 1995 under the GNU GPL License. MySQL gained popularity in the web application world because of its LAMP and other software stack (all that have the AMP acronym). LAMP (Linux-Apache-MySQL-PHP) is a software stack that you will find in many web applications.
  • Oracle, the current owners of MySQL after acquiring Sun Microsystems, sells MySQL to private customers and Oracle DB for big corporate customers.
  • The major drawback of SQL in today’s world is that most of the data today is non-structured data, meaning the traditional tabular model of SQL is ineffective. According to Merril Lynch’s 1998 estimation, between 80% and 90% of a company’s data is unstructured.

So, which is the better option? The answer lies in the type of data you have, but more and more people are going the NoSQL way and this is why companies like Remote DBA Support are offering this MongoDB solution.

Views: 8992


You need to be a member of AnalyticBridge to add comments!

Join AnalyticBridge

Comment by Jeffrey Ng on June 27, 2015 at 10:55am

good stuff! is MongoDB the best NoSQL product?

how about the connectivity from R / Python? Which is easier and popular?

Follow Us

On Data Science Central

On DataViz

On Hadoop

© 2017 is a subsidiary and dedicated channel of Data Science Central LLC   Powered by

Badges  |  Report an Issue  |  Terms of Service