| |
MongoDB was released in 2009. | MySQL has been maturing since 1995 and has grown a large following. MySQL is currently owned by the Oracle Corporation. |
MongoDB, Inc Supplies Ongoing Development. | Oracle Corporation Supplies Ongoing Development |
MongoDB was written in C++, C, and JavaScript and has binaries for the following systems: Linux, OS X, Solaris, and Windows. | MySQL is written in C and C++ and has binaries for the following systems: Microsoft Windows, OS X, Linux, AIX, BSDi, FreeBSD, HP-UX, IRIX, NetBSD, and more. |
MongoDB used by many organizations including Klout, Citrix, Twitter, T-Mobile, Zendesk, Sony, Hootsuite, SurveyMonkey, MuleSoft, Foursquare, and InVision. | MySQL used by Pinterest, Twitter, YouTube, Netflix, Spotify, US Navy, NASA, Walmart, and Paypal. |
In MongoDB, data is stored in JSON-like documents that can have varied structures. | MySQL stores its data in tables. |
To improve query speed, MongoDB can store related data together, which is accessed using the MongoDB query language. | MySQL uses the structured query language (SQL) to access the data. |
MongoDB is schema-free, allowing you to create documents without having to define the structure of the document first. These documents can be easily changed by adding or deleting fields. | MySQL uses schemas to define the database structure, requiring that all rows within a table have the same structure with values being represented by a specific data type. |
In MongoDB, if an index is not found, every document within a collection must be scanned to select the documents that provide a match to the query statement. | With MySQL, if an index is not defined, the database engine must scan the entire table to find all relevant rows. |
Queries Example:db.student.find()
db.student.insert
({ stu_id: '101', branch: 'A' }) | Queries Example:SELECT * FROM student
INSERT INTO student
(stu_id, branch) VALUES ('l01','A') |
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. | 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. |
Features- Provides high performance
- Auto-sharding
- Run over multiple servers
- Supports Master-Slave replication
- Data is stored in the form of JSON style documents
- index any field in a document
- It has an automatic load balancing configuration because of data placed in shards
| Features- Scalable
- Easy to use
- High Security
- Supports Novell Cluster Services
- Fast
- Runs on many operating systems
|
Pros of MongoDB- Support ad-hoc query
- High-Speed Database
- Schema-less database
- Horizontally scalable database
- Performance is very high
| Pros of MySQL- supports large databases, up to 50 million rows or more in a table
- open-source
- Implement a variety of user interfaces
|
Cons of MongoDB- Doesn’t support joins
- Data Size is High
- Nesting of documents is limited
- Increase unnecessary usage of memory
| Cons of MySQL- No built-in support for XML or OLAP
- Support is available for the free version
- Take a lot of time and effort to create incremental backups
|