What Is MongoDB - Introduction, Architecture, Features & Example
What Is MongoDB - Introduction, Architecture, Features & Example
MongoDB Features
MongoDB Example
Key Components of MongoDB Architecture
Why Use MongoDB
Data Modelling in MongoDB
Difference between MongoDB & RDBMS
MongoDB Features
1. Each database contains collections which in turn contains documents. Each document
can be different with a varying number of fields. The size and content of each document
can be different from each other.
2. The document structure is more in line with how developers construct their classes and
objects in their respective programming languages. Developers will often say that their
classes are not rows and columns but have a clear structure with key-value pairs.
3. The rows (or documents as called in MongoDB) doesn't need to have a schema defined
beforehand. Instead, the fields can be created on the fly.
4. The data model available within MongoDB allows you to represent hierarchical
relationships, to store arrays, and other more complex structures more easily.
1. Scalability – The MongoDB environments are very scalable. Companies across the world
have defined clusters with some of them running 100+ nodes with around millions of
documents within the database
MongoDB Example
The below example shows how a document can be modeled in MongoDB.
1. The _id field is added by MongoDB to uniquely identify the document in the collection.
2. What you can note is that the Order Data (OrderID, Product, and Quantity ) which in RDBMS
will normally be stored in a separate table, while in MongoDB it is actually stored as an
embedded document in the collection itself. This is one of the key differences in how data is
modeled in MongoDB.
(/images/MongoDB/112015_1051_Introductio1.png)
1. _id – This is a field required in every MongoDB document. The _id field represents a unique
value in the MongoDB document. The _id field is like the document's primary key. If you
create a new document without an _id field, MongoDB will automatically create the field. So
for example, if we see the example of the above customer table, Mongo DB will add a 24
digit unique identifier to each document in the collection.
_Id CustomerID CustomerName OrderID
(/images/MongoDB/112015_1051_Introductio2.png)
Just a quick note on the key difference between the _id field and a normal collection field. The
_id field is used to uniquely identify the documents in a collection and is automatically added
by MongoDB when the collection is created.
Table Collectio In RDBMS, the table contains the columns and rows which are used to st
n ore the data whereas, in MongoDB, this same structure is known as a co
llection. The collection contains documents which in turn contains Fiel
ds, which in turn are key-value pairs.
Documen In RDBMS, the row represents a single, implicitly structured data item in
Row
t a table. In MongoDB, the data is stored in documents.
Colum Field In RDBMS, the column denotes a set of data values. These in MongoDB
n are known as Fields.
Joins Embedde In RDBMS, data is sometimes spread across various tables and in order t
d docum o show a complete view of all data, a join is sometimes formed across t
ents ables to get the data. In MongoDB, the data is normally stored in a singl
e collection, but separated by using Embedded documents. So there is
no concept of joins in MongoDB.
Apart from the terms differences, a few other differences are shown below
1. Relational databases are known for enforcing data integrity. This is not an explicit
requirement in MongoDB.
2. RDBMS requires that data be normalized (/database-normalization.html) first so that it can
prevent orphan records and duplicates Normalizing data then has the requirement of more
tables, which will then result in more table joins, thus requiring more keys and indexes.
As databases start to grow, performance can start becoming an issue. Again this is not an
explicit requirement in MongoDB. MongoDB is flexible and does not need the data to be
normalized first.
MongoDB Tutorials
1) What is MongoDB? (/what-is-mongodb.html)
AD
(https://www.facebook.com/guru99com/)
(https://twitter.com/guru99com)
(https://www.linkedin.com/company/guru99/)
(https://www.youtube.com/channel/UC19i1XD6k88KqHlET8atqFQ)
(https://forms.aweber.com/form/46/724807646.htm)
About
About Us (/about-us.html)
Advertise with Us (/advertise-us.html)
Write For Us (/become-an-instructor.html)
Contact Us (/contact-us.html)
Career Suggestion
SAP Career Suggestion Tool (/best-sap-module.html)
Software Testing as a Career (/software-testing-career-
complete-guide.html)
Interesting
eBook (/ebook-pdf.html)
Blog (/blog/)
Quiz (/tests.html)
SAP eBook (/sap-ebook-pdf.html)
Execute online
Execute Java Online (/try-java-editor.html)
Execute Javascript (/execute-javascript-online.html)
Execute HTML (/execute-html-online.html)
Execute Python (/execute-python-online.html)