MongoDB Overview

I have started to work with MongoDB so think to start blogging about MongoDB. I will try to write very simple language which will give you great understanding on MongoDB concept to create and deploy a highly scalable and performance-oriented database.
MongoDB is an open-source document database is written in c++, and leading NoSQL database.
MongoDB is a cross-platform, document-oriented database that provides, high performance, high availability, and easy scalability. MongoDB works on the concept of collection and document.
Database: Database physically contains the collections. Each database gets its own set of files on the file system. A single MongoDB server usually has multiple databases.
Collection: This is equivalent to RDBMS table; basically collection is a group of MongoDB Documents. A collection exists within a single database. Collections do not insist on a schema. Documents within a collection can have different fields. Naturally, all documents in a collection are of similar or related purposes.
Document: Document is a set of key-value pairs. Documents have a dynamic schema. Dynamic schema means that documents in the same collection do not need to have the same set of fields or structure, and common fields in a collection's documents may hold different types of data.

Table Join
Embedded Documents
Primary Key
Primary Key (Default key _id provided by MongoDB itself)
Database Server and Client

Sample document
Below given example shows the document structure of a blog website which is simply a comma-separated key-value pair

   _id: ObjectId(4gf66u875)
   title: 'MongoDB Overview',
   description: 'MongoDB is no sql database',
   by: 'codefari',
   url: '',
   tags: ['mongodb', 'database', 'NoSQL'],
   likes: 100,
   comments: [  
         message: 'My first comment',
         dateCreated: new Date(2015,1,20,2,43),
         like: 0
         message: 'My second comments',
         dateCreated: new Date(2015,1,25,7,34),
         like: 5
_id is a 12 bytes hexadecimal number which assures the uniqueness of every document. You can provide _id while inserting the document. If you didn't provide then MongoDB provide a unique id for every document. 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.

1 comment:

  1. brief but nice one !

    few more details in easy way -


Please do not enter any spam link in the comment box.

Related Posts

Fatal Error: Peer authentication failed for user "postgres", when trying to get pgsql working with rails.

Problem: Sometimes, we get the following error when trying to make a connection in Rails.  FATAL ERROR: Peer authentication failed for us...