MongoDB Overview - MongoDB

How MongoDB works?

MongoDB is a cross-platform, document oriented database which offers, high performance, high availability, and simple scalability. MongoDB basically works on concept of collection and document.

Database

Database is a physical container for collections and each database will have its own set of files on the file system. A single MongoDB server will have multiple databases.

Collection

Collection has a group of MongoDB documents and is similar to RDBMS table. Collection exists within a single database and a collection does not enforce a schema. Documents within a collection will have different fields and all the documents in a collection are of similar or related purpose.

Document

Document is a set of key-value pairs and they have dynamic schema. Dynamic schema means that documents in the same collection will not have the same set of fields or structure. Common fields in a collection's documents can hold various types of data.

Below table shows the relationship of RDBMS terminology with MongoDB.

RDBMS

MongoDB

Database

Database

Table

Collection

Tuple/Row

Document

column

Field

Table Join

Embedded Documents

Primary Key

Primary Key (Default key _id provided by mongodb itself)

Database Server and Client

Mysqld/Oracle

mongod

mysql/sqlplus

mongo


Below example shows the document structure of a blog site, which is simply a comma separated key value pair.

Sample Document

_id is a 12 bytes hexadecimal number which ensures the uniqueness of every document and _id value can be provided while inserting the document. If you are providing _id value then MongoDB if itself will provide a unique id for every document. In these 12 bytes, first 4 bytes are for the current timestamp, next 3 bytes are for machine id, next 2 bytes are for process id of MongoDB server and remaining 3 bytes are simple incremental VALUE.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

MongoDB Topics