Differences between MongoDB and MySQL on various parameters are discussed below:
What are MongoDB and MySQL?
|MongoDB is an open-source database developed by MongoDB, Inc. MongoDB stores data in JSON-like documents that can vary in structure. It is a popular NoSQL database.||MySQL is a popular open-source relational database management system (RDBMS) that is developed, distributed and supported by Oracle Corporation.|
How Data is Stored?
|In MongoDB, each individual records are stored as ‘documents’.||In MySQL, each individual records are stored as ‘rows’ in a table.|
HIERARCHICAL UPPER OF A RECORD
|Documents belonging to a particular class or group as
stored in a ‘collection’.
Example: collection of users.
|A ‘table’ is used to store rows (records) of similar type.|
SQL or NoSQL
|MongoDB is what is called a NoSQL database. This means that pre-defined structure for the incoming data can be defined and adhered to but also, if required different documents in a collection can have different structures. It has a dynamic schema.||MySQL as the name suggests uses Structured Query Language (SQL) for database access. The schema can not be changed. The inputs following the given schema are only entered.|
Example: In a table, if there are columns for name, address and there is need to enter ‘age’ in new column in one of the entries, it will not take it as the column is not defined in schema.
This can be achieved in MongoDB, any new field can be inserted irrespective of the schema and is thus known to have dynamic schema.
|MongoDB was designed with high availability and scalability in mind, and includes out-of-the-box replication and sharding.||MySQL concept does not allow efficient replication and sharding but in MySQL one can access associated data using joins which minimizes duplication.|
Differences in Terminology
There are differences based on terminology between MongoDB and MySQL.
The difference between the way data is represented and stored in both the databases is quite different.
MongoDB stores data in form of JSON-like documents and MySQL stores data in form of rows of table as mentioned earlier.
Example: To show how data is stored and represented in MongoDB and MySQL.
- MySQL | Common MySQL Queries
- MongoDB and Python
- MongoDB : An introduction
- MongoDB: Getting Started
- Difference between RDBMS and MongoDB
- Introduction about Node.js and MongoDB
- MongoDB | Create Database using MongoShell
- MongoDB | Delete Database using MongoShell
- Signup Form Using Nodejs and MongoDB
- Nodejs - Connect MongoDB with Node app using MongooseJS
- Defining, Creating and Dropping a MongoDB collection
- MongoDB python | insert(), replace_one(), replace_many()
- MongoDB Python | Insert and Update Data
- Guide to Install MongoDB with Python | Windows
- MongoDB python | Delete Data and Drop Collection
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.