? QA Design Gurus: Introduction to MongoDB Database

May 9, 2016

Introduction to MongoDB Database


What is MongoDB?

10gen definition on MongoDB – “Scalable, open source, high performance, document oriented database”.

How MongoDB works?

MongoDB is a cross-platform document-oriented database. Classified as a NoSQL database, MongoDB eschews the traditional table-based relational database structure in favour of JSON-like documents with dynamic schemas (MongoDB calls the format BSON), making the integration of data in certain types of applications easier and faster. MongoDB works on concept of collections and documents.
MongoDB Features

Document-Oriented Storage-

MongoDB can store the business subject in the minimal number of documents. A document is a set of key-value pairs. Documents have dynamic schema. Dynamic schema means that the documents in the same collection do not need to have the same set of fields or structure, and common fields in a collection's documents may hold different types of data.

 
Ex1:                                                      Ex2:   
             {                                                             { 
               id: "1",                                                  id: "1",
               name: "TEST"                                      name: "TEST",
            }                                                        address: {
                                                                                  street: “test street”,
                                                                                               city:”test city”   ,  
                                                                                                state: "MA",
                                                                                                zip: "12345"
                                                                                             }
                                                                            }
High Availability
 
MongoDB provides high availability using replication facility, called replica sets. Replication is the process of synchronizing data across multiple servers. Replication provides redundancy and increases data availability with multiple copies of data on different database servers, replication protects a database from the loss of a single server.

Easy Scalability

Scalability is the ability of a database system to handle a growing amount of work in a capable manner or its ability to be enlarged to accommodate that growth.
High Performance

One of the key features of MongoDB is high performance and It is achieved with its data models and special type of indexing technique.
MongoDB supports embedded data model; it reduces the I/O activity on database system. Data in MongoDB for a record is stored in a single document nested blocks.  So the data retrieving is very efficient and improves the performance.

Advantages of MongoDB over RDBMS


Instead of storing data in tables here rows are replaced by Documents (basic unit of Data in Mongo DB just like a ROW in RDMS) and Collections (collection is a group of documents.) which allow representing complex relationships. It can manage huge amount of data and can load data across a cluster. Mongo DB can perform some features which relational database cannot do.

o   Schema less: MongoDB is document database in which one collection holds different documents. Number of fields, content and size of the document can be differ from one document to another. 
o   Structure of a single object is clear 
o    No complex joins: It removes the need for complex transactions or joins due to
                          the advantages of having data for a record contained within a single document. 
              o   Deep query ability  
                      o   MongoDB supports dynamic queries on documents using a document based
                        query language that's nearly as powerful as SQL
o   Performance tuning is done with MongoDB
o   Ease of scale out: MongoDB is easy to scale
o   Ease of Use (Developer Friendly)
o   Mongodb is an open source software
o   Java Scripts are used instead of long Procedures
o   MongoDB stores files of any size without complicating your stack.
o   Most Importantly Mongo DB supports secondary indexes and geospatial indexes.
o   Mongo DB supports Map reduce and Aggregation Tools
o   Conversion/mapping of application objects to database objects not needed
o   Simple to Administer the Mongo DB in cases of failures
Compare MongoDB to RDBMS

MongoDB is not a relational database but it has some of the imperative features of RDBMS and has got implausible speed. 
 
o   MongoDB(NoSQL) database is high performance compared to RDBMS
o   RDBMS is high functional than MongoDB

Limitations of MongoDB

 
o   No Joins support
o   No complex transactions support
o   No constraints support database level
o   Consumption of disk space is more
o   Indexes take up lot of RAM
o   12-node limit to the replica-set strategy
o   No support for transactions
o   Manual changes to master node in the master-slave strategy
o   32-bit MongoDB only handles 2GB of data

No comments:

Post a Comment