MongoDB
MongoDB is an open-source document database that provides
high performance, high availability, and automatic scaling.
In simple words you can say that - Mongo DB is a document
oriented database. It is an open source product, developed
and supported by a company named 10gen.
MongoDB is available under General Public license for free and it
is also available under Commercial license from the
manufacture.
The manufacturing company 10 gen has given the definition of
Mongo DB:
"Mongo DB is scalable, open source, high performance, document
oriented database." - 10 gen
MongoDB was designed to work with commodity servers. Now it
is used by company of all sizes, across all industry.
Purpose to build MongoDB
This may be a very genuine question that - "what was the
need of MongoDB although there were many databases in
action?"
This is a very simple answer:
All the modern applications require big data, fast features
development, flexible deployment and the older database
systems not enough competent, so the MongoDB was
obviously needed.
Main purpose to build MongoDB:
Scalability
Performance
High Availability
Scaling from single server deployments to large, complex
multi-site architectures
Key points of MongoDB
Develop Faster
Deploy Easier
Scale Bigger
Example of document oriented
database
MongoDB is a document oriented database. It is a key feature of
MongoDB. It offers a document oriented storage. It is very simple you
can program it easily.
MongoDB stores data as documents, so it is known as document
oriented database.
FirstName = "Ajeet",
Address = "Laxmi Nagar",
Spouse = [{Name: "Chaaru"}].
FirstName ="Ravi",
Address = "Loni"
There are two different documents (separated by ".").
Storing data in this manner is called as document oriented database.
Mongo DB falls into a class of databases that calls Document Oriented
Databases. There is also a broad category of database known as No SQL
Databases.
Features of MongoDB
These are some important features of MongoDB:
1. Support ad hoc queries
In MongoDB, you can search by field, range query and it also supports
regular expression searches.
2. Indexing
You can index any field in a document.
3. Replication
MongoDB supports Master Slave replication.
A master can perform Reads and Writes and a Slave copies data from
the master and can only be used for reads or back up (not writes)
4. Duplication of data
MongoDB can run over multiple servers. The data is duplicated to keep
the system up and also keep its running condition in case of hardware
failure.
5. Load balancing
It has an automatic load balancing configuration because of data
placed in shards.
Conti……..
6. Supports map reduce and aggregation tools.
7. Uses JavaScript instead of Procedures.
8. It is a schema-less database written in C++.
9. Provides high performance.
10. Stores files of any size easily without complicating
your stack.
11. Easy to administer in the case of failures.
12. It also supports:
JSON data model with dynamic schemas
Auto-sharding for horizontal scalability
Built in replication for high availability
Now a day many companies using MongoDB to create new
types of applications, improve performance and availability.
MongoDB Advantages
MongoDB is schema less. It is a document database in
which one collection holds different documents.
There may be difference between number of fields,
content and size of the document from one to other.
Structure o
f a single object is clear in MongoDB.
There are no complex joins in MongoDB.
MongoDB provides the facility of deep query because it
supports a powerful dynamic query on documents.
It is very easy to scale.
It uses internal memory for storing working sets and
this is the reason of its fast access.
Distinctive features of MongoDB
Easy to use
Light Weight
Extremely faster than RDBMS
Where MongoDB should be used
Big and complex data
Mobile and social infrastructure
Content management and delivery
User data management
Data hub
Performance analysis of MongoDB
and RDBMS
In relational database (RDBMS) tables are using as
storing elements, while in MongoDB collection is
used.
In the RDBMS, we have multiple schema and in each
schema we create tables to store data while, MongoDB
is a document oriented database in which data is
written in BSON format which is a JSON like format.
MongoDB is almost 100 times faster than traditional
database systems.
MongoDB Datatypes
Data Types Description
String String is the most commonly used datatype. It is used to store data. A string
must be UTF 8 valid in mongodb.
Integer Integer is used to store the numeric value. It can be 32 bit or 64 bit depending
on the server you are using.
Boolean This datatype is used to store boolean values. It just shows YES/NO values.
Double Double datatype stores floating point values.
Min/Max Keys This datatype compare a value against the lowest and highest bson elements.
Arrays This datatype is used to store a list or multiple values into a single key.
Object Object datatype is used for embedded documents.
Null It is used to store null values.
Symbol It is generally used for languages that use a specific type.
Date This datatype stores the current date or time in unix time format. It makes you
possible to specify your own date time by creating object of date and pass the
value of date, month, year into it.