MongoDB – Introduction

It is leading NoSQL database. It is an open-source document database. It is written in c++. It provides high performance, high availability, and easy scalability. It works on concept of collection and document.

Database -> Collection -> Document -> Key & Value

A single MongoDB server typically has multiple databases.

Database is a physical container for collections.

Collection is a group of MongoDB documents.

Document is a set of key-value pairs and has dynamic schema.

There is a _id for assuring of the uniqueness of every document. _id is a 12 bytes hexadecimal number. MongoDB generates _id for each document if not supplied. These 12 bytes first 4 bytes for the current timestamp, next 3 bytes for machine id, next 2 bytes for process id of mongodb server and remaining 3 bytes are simple incremental value.

4 Bytes 3 Bytes 2 Bytes 3 Bytes
Current Timestamp Machine ID Process ID Simple Incremental Value

MongoDB – Commands

Vikas Jindal