What is MongoDB:
MongoGB is a free and open source cross-platform
document-oriented program.
Classified as a NoSQL Database Program, MongoDB uses
JSON-like documents with schema. MongoDB is developed by MongoDB Inc.
{
"_id": "5cf0029caff5056591b0ce7d",
"firstname": "Sudipt",
"lastname": "Sahu",
"address": {
"street":
"VIP Road",
"city":
"kolkata",
"state":
"WB",
"zip":
"700091"
},
"hobbies": ["surfing", "coding"]
}
MongoDB stores
data in flexible, JSON-like documents, meaning fields can vary from document to
document and data structure can be changed over time MongoDB is
a distributed database at its core, so high availability, horizontal
scaling, and geographic distribution are built in and easy to use
Ad hoc
queries, indexing, and real time aggregation provide powerful ways to
access and analyze your data
What is JSON
JavaScript Object Notation
(JSON) is an open, human and machine-readable standard that facilitates data
interchange, and along with XML is the main format for data interchange used on
the modern web. JSON supports all the basic data types you’d expect: numbers,
strings, and Boolean values, as well as arrays and hashes.
Document
databases such as MongoDB use JSON documents in order to store
records, just as tables and rows store records in a relational database.
What Is BSON
The name “BSON” is based on the term JSON and stands
for “Binary JSON”. MongoDB represents JSON documents in binary-encoded format
called BSON behind the scenes
Programming Language
for MongoDB
MongoDB has official
drivers for major programming languages and development environments.
Ø PHP
Ø Python
Ø Java
Ø Node.Js
– Not a PL , it’s a run time environment for Java Script
Ø C++
Ø C#
Software used
The primary interface to the database has been the mongo
shell. Since MongoDB 3.2, MongoDB Compass is introduced as the native GUI.
There are products and third-party projects that offer user interfaces for
administration and data viewing
Ø mongoDb
community server Database
Ø Robo
3T (RoboMongo) – GUI Tool to operate MongoDB
3 versions available
for MongoDB
- MongoDB Atlas - MongoDB
is also available as an on-demand fully managed service. MongoDB Atlas
runs on AWS, Microsoft Azure, and Google Cloud Platform
- MongoDB Enterprise Server - MongoDB
Enterprise Server is the commercial edition of MongoDB, available as part
of the MongoDB Enterprise Advanced subscription
- MongoDB
Community Server - The MongoDB Community Edition is free and available for
Windows, Linux, and OS X
Difference between MongoDB & RDBMS
Below
are some of the key term differences between MongoDB and RDBMS
Database
– Database is a physical container for collections. Each database gets its own
set of file system. A single MongoDB server typically has multiple databases.
Collection
– collection is a group of MongoDB documents. It is the equivalent of an RDBMS
table. A collection exists within a single database. Collection do not enforce
schema. Documents within a collection can have different fields. Typically, all
documents in a collection are of similar or related purpose.
RDBMS |
Definition |
MongoDB |
Definition |
Database |
Database |
||
Table |
Table contains the columns and rows which are used to store
the data |
Collection |
collection is a group of MongoDB documents. It is the
equivalent of an RDBMS table. A collection exists within a single database.
Collection do not enforce schema. Documents within a collection can have
different fields. all documents in a collection are of similar or related
purpose |
Row |
Document |
A document is a set of key-value pair. Documents have dynamic
schema. Collection do not need to have the same set of fields or structure,
and common fields in a collection
documents may hold different types of data.
|
|
Column |
Field |
Key in MongoDB. |
|
Join |
To get the data from different tables sometimes we need to
perform Joins |
Embedded Document, $lookup |
No any concept of Join in MongoDB. In MongoDB, the data is
normally stored in a single collection, but separated by using Embedded
documents |
Index |
Index |
||
Primary key |
Specify any unique column or column combination as primary key. |
Primary key |
In MongoDB, the primary key is automatically set to the _id field. |
RDBMS (Structure) VS. MongoDB (Structure)
How MongoDB Makes it
Easy
·
Documents. Using MongoDB’s document model,
you can incorporate any type of data, no matter what it looks like or where it
comes from. JSON documents support all the basic data types you’d expect (e.g.,
numbers, strings, binary data, arrays) without requiring you to define or
enforce a schema.
·
Dynamic Schemas. Schemas in MongoDB are
self-describing. Iterate on the schema without having to rethink it entirely.
Pull in new data when you need to. MongoDB documents can also vary in
structure, which means documents from one system don’t need to have all the
same fields as documents from another.
·
MongoDB’s expressive query language, indexing, and aggregation
capabilities make it possible to find and filter the data, no matter how the
business needs to access it.
Main Features of
MongoDB?
Ø Ad hoc queries - MongoDB supports field, range query, and regular expression searches
Ø Indexing - Fields in a MongoDB document can be
indexed with primary and secondary indices. Indexes support the efficient
execution of queries in MongoDB. Without indexes, MongoDB must perform a collection
scan, i.e. scan every document in a collection, to select those documents
that match the query statement.
Ø Replication - MongoDB provides high availability with replica sets. A replica set consists of two or more copies of the data. Each replica set member may act in the role of primary or secondary replica at any time. All writes and reads are done on the primary replica by default. Secondary replicas maintain a copy of the data of the primary using built-in replication. When a primary replica fails, the replica set automatically conducts an election process to determine which secondary should become the primary. Secondaries can optionally serve read operations, but that data is only eventually consistent by default.
Ø
Load balancing - MongoDB uses the
concept of sharding to scale horizontally by splitting data across multiple
MongoDB instances. MongoDB can run over multiple servers, balancing the load
and/or duplicating data to keep the system up and running in case of hardware
failure.
No comments:
Post a Comment