Published by : International Journal of Engineering Research & Technology (IJERT)
[Link] ISSN: 2278-0181
Vol. 8 Issue 05, May-2019
A Review on Various Aspects of MongoDb
Databases
Anjali Chauhan
[Link] Scholar, CSE Department,
Rawal Institute of Engineering and Technology,
Faridabad, Haryana, India
Abstract—MongoDB is most popular among the NoSQL that provides high performance, high availability and easy
databases. For building data warehouses, it is a great tool scalability. MongoDB works on concept of collection and
especially because of its ability to fully utilize so called document.
“sharding-nothing cluster architecture.” It is an open source • Database - Database is a physical container for collections.
database, which makes it ideal for building high performance
data warehouses. In this paper, a review of various aspects of
Each database gets its own set of files on the file system.
MongoDB is discussed and some key issues are framed. In • Collection - Collection is a group of MongoDB
future research can be done on any of these issues. So this paper documents. It is the equivalent of a RDBMS table.
opens some areas for research in MongoDB databases. Collections do not enforce a schema. Documents within a
collection can have different fields. Typically, all
Keywords — No-SQL, MongoDB, Database, RDBMS, Non- documents in a collection are of similar or related
relational databases purpose.
I. INTRODUCTION • Document - A document is a set of key- value pairs.
Documents have dynamic schema. Dynamic schema
MongoDB is an open-source document database that means that documents in the same collection do not need
provides high performance, high availability, and automatic to have the same set of fields or structure, and common
scaling. A record in MongoDB is a document, which is a data fields in a collection’s documents may hold different
structure composed of field and value pairs. MongoDB types of data.
documents are similar to JSON objects. The values of fields {
may include other documents, arrays and arrays of documents. _id:ObjectId(7df78ad8902c)
The advantages of using documents are: Title:’MongoDB Overview’
• Documents (i.e. objects) correspond to native data types in Description:’ MongoDB is no sql database
many programming languages. Comments: [
• Embedded documents and arrays reduce need for { user:’user1’,
expensive joins. Message:’my first comment’,
• Dynamic schema supports fluent polymorphism. dateCreated: new Date(2011,1,20,2,15),
A. Key Features of MongoDB },
• High Performance – MongoDB provides high { user:’user2’,
performance data persistence. In particular, it supports for Message: ‘my second comments’
embedded data models reduces I/O activity on database dateCreated: new Date (2011,1,25,7,45),
system, indexes support faster queries and can include }
keys from embedded documents and arrays. }
• Rich Query Language - MongoDB supports a rich query • Sample Document - Above example shows the document
language to support read and write operations (CRUD) as structure of a blog site, which is simply a comma
well as Data aggregation, Text Search. separated key value pair.
• High Availability – MongoDb’s replication facility, called C. Advantages of MongoDB
replica set, provides automatic failover and data Any relational database has a typical schema design that
redundancy. A replica set is a group of MongoDB servers shows number of tables and the relationship between these
that maintain the same data set, providing redundancy and tables. While in MongoDB, there is no concept of
increasing data availability. relationship. Advantages of MongoDB over RDBMS can be
• Horizontal Scalability – MongoDB provides horizontal described as:
scalability as part of its core functionality. Sharding • MongoDB is a document database in which one collection
distributes data across a cluster of machines. holds different documents. Number of fields, content and
B. Overview of MongoDB size of the document can differ from one document to
MongoDB is an open-source document database and another.
leading NoSQL database. MongoDB is written in C++. • Structure of a single object is clear.
MongoDB is a cross-platform, document oriented database • No complex joins.
IJERTV8IS050031 [Link] 90
(This work is licensed under a Creative Commons Attribution 4.0 International License.)
Published by : International Journal of Engineering Research & Technology (IJERT)
[Link] ISSN: 2278-0181
Vol. 8 Issue 05, May-2019
• Deep query ability. MongoDB supports dynamic queries available albeit primary key is one of the most important key
on documents using a document-based query language of the table; it is used to identify each row of the table
that’s nearly as powerful as SQL. uniquely. There are four main operations used to access the
• Ease of scale out. MongoDB is easy to scale. database they are known as CRUD namely, Create, Read,
• Conversion/mapping of application objects to database Update and Delete associated with the data. These operations
objects not needed. use the Structured Query Language –SQL. ACID properties
• Uses internal memory for storing the (windowed) working are one of the most significant and important attributes of a
set, enabling faster access of data. SQL database. This is the key difference between SQL and
NoSQL database systems. The NewSQL approach on the
D. Uses of MongoDB other hand, conserves and supports the properties of relational
MongoDB has document oriented storage; data is stored in model, at the same time incorporating the features of NoSQL
the form of JSON style documents. It can be indexed on any model.
attributes. We can also explain where to use MongoDB: TABLE I. MYSQL VS MONGODB TERMS
• Big Data
• Content Management and Delivery
• Mobile and Social Infrastructure MySQL MongoDB
• User Data Management Database Database
• Data Hub Table Collection
E. Importance of MongoDB Index Index
MongoDB is a document-oriented database. This is “as
opposed to” other types of DBs: Relational, Graph, Row BSON document
Key/Value, Queue, FTS, Map/Reduce, etc. The leads to Column BSON field
lessons like: data organization relative to query patterns, Join Embedded documents and linking
indexing options, handling polymorphic objects in code, Primary key Primary key
performing manual joins on the client.
Group by Aggregation
MongoDB is also a DB that highlights the use of multiple
servers in two ways: Replica Sets and Sharding Unlike MySQL, where the database is presented
Replica Sets: graphically in the form of a table, in MongoDB, a database
•Redundancy and failover has the following graphic structure:
•Zero downtime for upgrades and maintenance {
•Master-slave replication “_id”: “d4acaf3a76e4378b853eb15fde21672”,
•Strong consistency “username”: “andra”,
•Delayed consistency “email”: andra@[Link],
•Geospatial features }
Sharding: {
• Distributes a single logical database system across a “_id”: “d4rvgf3a76e4378b853eb15fde21672”,
cluster of machines “username”: “iona”,
• Uses range-based partitioning to distribute documents “email”: iona@[Link],
based on a specific shard key }
• Automatically balances the data associated with each The example above shows a database for users, each user
shard having an id that is unique and automatically generated, a
• Can be turned on and off per collection(table) username and an email address.
This leads to lessons around things like “write safety”, The application will have 3 classes of users, namely the
handling master fail-over, shard keys and shard balancing. administrators, the moderators and the regular users. Each
MongoDB also provides a simple framework for performing user has the right to create a private forum/subforum. Within a
map/reduce or aggregation operation across multiple subforum, the moderators have the right to edit/delete the
computers. This leads to lessons around projection of objects subforum and they can also moderate other users’ discussions,
and basic aggregation primitives. while regular users are only allowed to post discussions and
leave comments. If a relational database has been used, the
II. COMPARATIVE STUDY columns for forums and subforums should have appeared at
all forum users, although normal users will never have the
As shown in Table 1, in MongoDB, some MySQL terms, right to create, modify or delete them, unless of course, they
such as table or row, get another name, namely collection, are the administrators of that particular forum. Using
respectively BSON document. In other words, we can say that MongoDB, these fields regarding the forum and subforum
MongoDB contains collections, collections contain documents will appear only to users who have that right (moderators and
and a document contains multiple fields. administrators), thus significantly reducing storage space,
In the classical RDBMS model, the data is organized in which is much higher using MySQL.
the form of relations and is represented in a table consisting of As in relational databases, MongoDB also has one-to-
rows and columns. Relational databases employ the usage of a many relationships, but in this case the concept of foreign key
parameter known as key. There are several types of keys is not used; instead, the concept of annotations is used. Thus,
IJERTV8IS050031 [Link] 91
(This work is licensed under a Creative Commons Attribution 4.0 International License.)
Published by : International Journal of Engineering Research & Technology (IJERT)
[Link] ISSN: 2278-0181
Vol. 8 Issue 05, May-2019
in this case, regarding a forum, the connection between the IV. CONCLUSION AND FUTURE SCOPE
forum and its subforums is as follows: in the forum document,
the subforums are referenced using the annotation. MongoDB is currently the most popular Document-
MongoDB provided lower execution times than MySQL oriented DB, but it is hardly the most robust or performant
in all four basic operations (Insert, Select (query), Update, implication. MongoDB is a relative newcomer in the database
Delete), which is essential when an application should provide arena, and is the most popular among the NoSQL databases. It
support to thousands of users simultaneously. is a great tool for building data warehouses, especially
because of its ability to fully utilize so called “shared-nothing
III. ISSUES WITH MONGODB cluster architecture.” It is an open-source database, which
makes it ideal for building high performance data warehouses.
MongoDB is a popular option for database storage. It’s It is also well documented, well supported, and easy to install,
easy to learn and faster than competing RDBMs, but still there integrate into PHP, and test. Also, because it is so new,
are some potential pitfalls in it. It’s denormalised, meaning updated versions are released practically every day, so one has
data is stored in a nested document structure rather than to approach the project for which MongoDB is considered
relational tables. This makes for faster lookups as Mongo with a sense of adventure. The next generation NonSQL
doesn’t rely on expensive join operations seen with MySQL (NoSQL) databases are mostly non-relational, distributed and
and other database engines. Despite such strengths, there are horizontally scalable and are able to satisfy most of the needs
several problems with MongoDB that one should consider of the present day applications. The main characteristics of
using it as a database engine. these databases are schema-free, no join, nonrelational, easy
• Problems with Reliability – MongoDB writes are replication support, simple API and eventually consistent.
asynchronous by default. The main advantage of this is The result of this study open new avenues for future
you don’t have to wait for confirmations for every insert research of performance of data access when there are
or update operation before the next one starts. This makes hotspots in data because it supposes all the data will be
updates faster but less reliable. Even if some of the accessed in same patterns. A future scope of this work would
updates are unsuccessful, the write operation will still be the implementation of the third model in MongoDB,
partially [Link] this engine, it’s all or nothing. directly or indirectly.
While this may be slower, it’s a more consistent and REFERENCES
reliable way to perform writes operations. When things
only partially work you can end up with data [1] Benymol Jose, Sajimon Abraham,” Exploring the Merits of NoSQL: A
Study Based on MongoDB”, 978-1-5090-6590-5/17/$31.00 ©2017
inconsistencies and buggy data.
IEEE
• Problems with Schema-less Design – Since MongoDB is [2] YunhuaGu, ShuShen, Jin Wang, Jeong-UkKim,”Application of NoSQL
denormalised, it doesn’t adhere to a relational schema. Database MongoDB”, 978-1-4799-8745-0/15/$31.00©2015 IEEE
Everything is stored in nested JSON objects called [3] Cornelia Gyrödi, Robert Gyrödi, George Pecherle, AndradaOlah,”A
Comparative Study: MongoDB vs. MySQL”, 978-1-4799-7650-
documents. While this allows for greater flexibility with
8/15/$31.00 ©2015 IEEE
your data models, it forces more schema based design [4] [Link]
decisions on the app logic than the db. Without the [5] [Link]
schema in place, the rules and regulations of your data [6] [Link]
[7] [Link]
models are dictated by your app logic rather than the db
itself. .
IJERTV8IS050031 [Link] 92
(This work is licensed under a Creative Commons Attribution 4.0 International License.)