MongoDB Tutorial

MongoDB Introduction

MongoDB is a NoSQL (Not only SQL) open source document-oriented database management system. This is suitable for modern internet applications. It provides dynamic queries, scalability, secondary indexes, fast atomic updates and we can easily use more than one database in a project.

It is open source so that, the source code is publicly available and free to modify and use in terms of its license.

It is written in C++, developed by 10gen and licensed under the GNU-AGPL. MongoDB first version v1.0 was released in November 2009.

The major advantages of MongoDB is scalability. The document oriented approach makes it easier to split up data across multiple servers. It automatically redistributes documents and routing user requests to the correct machines. If the application needs more capacity, we can add new machines.


Client Application and MongoDB Server

BSON is the binary serialization format, which is used to store documents and make remote procedure calls in MongoDB. So, basically it stores data as documents. The BSON implementation in MongoDB makes it fast, lightweight and provide facility for embedding objects and arrays within other objects and arrays.
The command mongod executes the core database server.

Mongodb Introduction

It compiles on all major operating systems, including Linux, Mac OS X, Windows.


Difference between MongoDB and RDBMS

We hope, you have some experience with RDBMS. MongoDB concepts are different from the relational databases. As you may know in a relational database, we have to make multiple complicated tables, and write complicated queries full of joins. But in mongodb, we can store most of the information in a single document. It replaces the "row" with more flexible "document". By using a document oriented approach, we can make complex hierarchical relationships with a single record. There is no need to define schemas in advance, that's making the development faster. We can easily add and remove fields as needed. This is good for storing data whose structure can't be known in advance.

RDBMS

MongoDB

Relational Database Non Relational, Document Oriented Database
Table - A table is a collection of data represented in rows and column. Collection - The collection holds document in MongoDB.
Row - A row in a table represents a set of related data. Document - Each record in MongoDB collection is a document. It is composed of key and value pairs OR binary representation of JSON documents.
Column - A column is a set of data values of similar data type. Field - A document contains one or more fields, each field contains a value of a specific data type.
It supports SQL query language. It supports JSON query language.
It supports foreign key. It does not support foreign key.
It does not support rich data model, auto-sharding and dynamic schema. It supports rich data model, auto-sharding and dynamic schema.
It supports table joins. It supports embedded documents.

The JavaScript shell

The MongoDB command shell is a Javascript based tool for administering and manipulating data in the database. It has capability to use Javascript code directly in the shell. We can also run Javascript files here using MongoDB program.


Database drivers

The MongoDB drivers are easy to use. The 10gen officially provides native drivers for all popular programming languages, like - C, C++, C#, Erlang, Haskell, Java, Perl, PHP, Python, Scala, and Ruby and there is also a community supported driver for other languages.


Corporate users of MongoDB

  • Facebook
  • SAP
  • LinkedIn
  • McAfee
  • MetLife
  • ebay






Read more articles