What is Mongo DB?
MongoDB is an open source database and which is one of the leading NoSQL database available in the market. It is based on document and collection concept which is very different from traditional databases. MongoDB is written in C++ language as building blocks.
Main Benefits of Mongo DB
- Cross Platform
- High Performance
- High availability
- Easy scalability
Difference between Mongo DB vs Traditional Databases or RDBMS
Below table shows all the difference between mongo db and RDBMS. Its shows you list of terminologies used in both the databases systems. On left hand side we have terms used in mongo db whereas right side shows terms used in traditional databases or RDBMS databases.
|Embedded Documents||Table Join|
|key _id||Primary Key|
What is Collection?
In terms of mongo db collection is collection or group of documents in mongo database. It is almost same concept as TABLE we have in RDBMS database. This collection consist of multiple documents inside each collection and we can multiple collections inside one database. This document inside collection can have multiple fields which specify columns in RDBMS database.
NOTE : Collection do not have any schema this is what no Sql comes into picture.
What is Document?
Document in context of mongo db is set of key value pair which holds data inside collection and there is no scheme for document. You can add extra field or remove from document based on your need. So documents inside collection can hold different kind of data with different schema and fields.
Primary Key in Collection
Primary key in collection is unique key to identify unique document. It is called as key _id as well and consist of key value pair. This unique key is 12 bytes hexadecimal number which is unique in collection. These 12 bytes hexadecimal number contains first 4 bytes for the current time stamp, next 3 bytes for machine id, next 2 bytes for process id of MongoDB server and remaining 3 bytes are simple incremental value.