facebook

MongoDB VS MySQL( The Differences Explained)

By Sudip Kiran Das

MongoDB VS MySQL( The Differences Explained)

Mysql has become popular options for organizations around the globe for the past two decades when there is a requirement for the relational database. However, when diversity and volume of data have increased with time, most of the developers prefer a non-relational database like MongoDB.

How Data is Stored?

MongoDB is an open-source database which is developed by MongoDB Inc. MongoDB stores data in JSON data format. Mainly, it is more like Binary JSON format(BSON).

Whereas Mysql is a popular open-source relational database management system (RDBMS) that is developed and maintained by Oracle Corporation. MySQL stores data into tables using the structured query language (SQL) to access the data.

Hierarchical upper of a record:

In MongoDB, all documents belong to a particular class or groups and it is stored in collections.

Example: collection of user.

In Mysql, a ‘table’ is used to store rows (records) of similar type.

SQL or NoSQL:

Suppose in a table, if there are any columns named “name”, “address” and there is to add a new field as “age”, it will not be taken as “age is not defined in schema.

But in MongoDB, any new field can be inserted irrespective of the schema and thus it is known as a dynamic schema.

Differences in Terminology:

There are several differences in terminology between MongoDB and MySQL.

MySQL MongoDB

Table Collections

Row Document

Column Field

Join Embedded documents, linking

Data Representation:

The way data is represented and stored in both Mysql and MongoDB databases is quite different.

A document in MongoDB

{

name: “Sudip”,

middle_name: “kiran”,

surname: “Das”

contact: “1234567890”

}

A record in Mysql

name middle-name surname contact

Sudip Kiran Das 1234567890

How are their queries different:

Selecting records from the customer table:

MySQL: SELECT * FROM customer

MongoDB: db.customer.find()

Inserting records into the customer table:

MySQL: INSERT INTO customer (cust_id, branch, status) VALUES (‘cust_01’, ‘A’, ‘Active’)

MongoDB: db.customer.insert({ cust_id: ‘cust_01’, branch: ‘A’, status: ‘Active’ })

Updating records in the customer table:

MySQL: UPDATE customer SET branch = ‘development’ WHERE cust_id = ‘ cust_01’

MongoDB: db.customer.update( { cust_id: ‘cust_01’ }, { $set: { branch: ‘development’ } } )

Which Database Is Right For Your Business?

When you are making the choice between MySQL and MongoDB, there are several types of factors to consider:

MySQL: Any type of application that requires multi-row transactions such as an accounting system, should be better suited for a relational database. MongoDB is not a suitable option to deploy for this particular case.

MongoDB: MongoDB will be well-suited for 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 offers.

Sudip Kiran Das Subscriber
Web Developer , Openweb Solutions

Web Developer at Openweb Solutions

Posts created 2

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top
shares