Introduction to MongoDB

MongoDB is one of the most popular NO-SQL databases. The word is derived from humongous.

It’s a relatively new breed of database that has no concepts of tables, joins, foreign keys, transactions etc.

It is an open-source document-oriented database developed by MongoDB inc. in 2009.

So MongoDB doesn’t use table, row, column format to store data, rather it uses a storage format called BSON which is similar to JSON.

MongoDB is used for high volume data storage.

A simple MongoDB structure :

{
  name:'Jack',
  age:22,
  city:'brooklyn'
}

Key components of MongoDB Architecture

Database

It is a physical container for data. We can store multiple databases on a single MongoDB server.

Document

A set of key-value pairs is known as Document.

Basically, a record is called a document that is associated with a dynamic schema. The benefit of having a dynamic schema is that a document in a single collection does not have to possess the same structure or field.

Collection

This is a grouping of MongoDB documents.

Consider the collection as Table in RDBMS. The entire collection exists within a single database.

There is no schema when it’s come to a collection.

MongoDB

Why use MongoDB?

  • Document Oriented: Instead of multiple relation structure like RDBMS, MongoDB stores the data in document format. This makes MongoDB very flexible and adaptable to real business.
  • Indexing : Indexes can be created to improve performance of search within MongoDB.
  • MongoDB has exceptional scalability. It makes it easy to fetch the data and provides continuous and automatic integration. Along with these benefits, there are multiple reasons why you need MongoDB:
  • No downtime while the application is being scaled
  • Performs in-memory processing.
  • Text search.
  • Graph processing.
  • Global replication.

Difference between MongoDB and MySQL:

MySQLMongoDB
The query language is structured query language.The query language is JavaScript.
It represent data in tables and rows.It represents data as key-value pair.
Defining tables and columns is required.Defining the schema is not required.
It support joins.It does not support join.
It has a risk of SQL injection attacks.Because of itโ€™s design, MongoDB is less of an attack.
MySQL is slower as compared to NoSQLMongoDB is faster.

Hope you like this!

Keep helping and happy ๐Ÿ˜„ coding

Next
Previous

Related