Quantcast
Channel: dbi Blog
Viewing all articles
Browse latest Browse all 2879

Introduction to MongoDB

$
0
0

MongoDB is an open source NoSQL database management system oriented document. MongoDB allows manipulating structured and un-structured data. MongoDB is schema-less and used to store large volume of data. In this blog we are going to explain the main principle of this DBMS.
MongoDB stores data in documents. Documents are stored in BSON types, the JSON binary format. In fact, we manipulate JSON document in the MongoDB shell. Documents are encapsulated into collections. A document is composed of key-value pairs.

MongoDB architecture

Basically MongoDB is designed to works on cluster, and distributed data across multiple server of your architecture. Of course you can use MongoDB as a standalone server without clustering. You can also replicate your data across multiple servers, we will see in an upcoming blog the concept of replication. MongoDB provides you some features and concepts and you have to deploy the good architecture depending on your business need.

MongoDB_architecture

Why using MongoDB?

MongoDB provides some interesting features for your application and your architecture:

  • Horizontal Scalability (sharding): adding more machines in contrast to increase the performance of machines
  • High availability (replication): Data durability, disaster recovery.
  • Flexibility of the data model, no predictive schema, the data model can be designed tailor made for the application.
  • Unstructured data can be handled

MongoDB Data format

{
	"_id" : ObjectId("56951380c9b9fd993a4dc4ab"),
	"city" : "Delémont",
	"zip" : "2800",
	"loc" : {
		"y" : 47.3667,
		"x" : 7.3333
	},
	"state" : "Jura"
}

Documents are encapsulated between two braces, and composed of key-value pairs. Every document has a unique and mandatory “_id”, a 12 bytes field hexadecimal number. The first 4 bytes represent the current timestamp, the next 3 bytes for the machine id, next 2 bytes for the process id (mongod) and the 3 last one are an incremental value. This document is very interesting because we have a second document under the main document, an embedded document (there is no “_id”). In next blog we will see how to modeling your data in MongoDB and the differences between embedded document and linked documents. All documents are grouped into collections.

MongoDB_collection

Terminology is important to have an understanding of the system. Below a small comparison between MongoDB and RDBMS terminology:

MongoDB

RDBMS

Collection Table
Document Row
Field Column
Default _id field Primary key
Embedded documents or linked documents Joins

 

Finally the advantages of using MongoDB over RDBMS are multiple. The schema design of data is the most important point for me. With the rise of agile software development and continuous integration, structures and data types have evolved, to the point where not being in agreement with the basic principles of relational databases. Now the responsibility of the data schema is on the software developer not the database management system. Compared to RDBMS classic pattern, this new storage mode allows developers to have more flexibility to evolve data schema over time.

 

 

Cet article Introduction to MongoDB est apparu en premier sur Blog dbi services.


Viewing all articles
Browse latest Browse all 2879

Trending Articles