Introduction to MongoDB Database

Tram Ho

Prologue

Hello guys, this is the first article in the “What I Know About MongoDB” series of articles about an extremely popular NoSQL DB, MongoDB.

In this article, I will share an overview of MongoDB in terms of:

  • What is NoSQL?
  • What is MongoDB?
  • Why and When to Use MongoDB
  • The pros/cons of mongodb
  • Outstanding features of mongodb

Come on let’s get started!

image.png

What is NoSQL?

If you are an IT person, then surely at school you have learned about Relational Database (RDBS) with standard design standards 1, standard 2, standard 3… However, In parallel with the types of relational database management systems RDBMS (Relational Database Management System also has non-relational database management systems, called NoSQL DB (NoSQL stands for Not-Only SQL or None-Relational SQL).

If you already have an RDBMS, why do you need a NoSQL DB anymore, here’s why:

  • NoSQL DB addresses the shortcomings and limitations of RDBMS types in terms of speed, features, scalability, and more.
  • NoSQL DB can be used for structured, semi-structured or unstructured data types. It is not constrained by a fixed data model
  • With NoSQL DB you can extend data without worrying about things like creating foreign keys, primary keys, checking constraints etc.
  • NoSQL DB uses dynamic schema for unstructured data, making data integration with different types of applications simpler and faster.
  • NoSQL DB ignores data and transaction integrity in exchange for fast performance and scalability.
  • Popular NoSQL DBs include MongoDB, Cassandra, Hbasse, Redis, CouchDB

What is MongoDB?

MongoDB is a NoSQL, open-source, cross-platform, object-oriented database software. Tables (called collections in MongoDB) have a flexible structure that allows to organize and store data in a flexible way that does not require the strict structure of other SQL databases.

From that approach, mongodb can be used to store complex structured data. Complex data can be saved into tables (in mongodb, the concept of tables – tables is called collection ) as json should provide high usability and performance.

Strengths of mongodb

It is not natural that mongodb is so popular among NoSQL DBs, simply because it has many advantages:

  • Mongod stores records as json documents and is stored as a BSON archive. These records can be queried directly as Json and this has many benefits:
    • It’s a pretty natural form of data storage
    • Both structured and unstructured data can be stored in the same record structure
    • Can use nested json data to store complex data
    • Json makes adding/removing data fields much simpler

    Example storing record as Json:

  • Scalability: MongoDB supports scaling with Sharding. This makes it easy for us to extend the mongodb cluster
  • Great development community

When to use MongoDB

If you read this far, maybe you, or your company have chosen to use mongodb. The choice of a DB type depends on a lot of factors both from the technical side to the later development and operating costs.

However, you can refer to some more suitable cases of using mongodb such as:

  • Use document to store data, easily add and remove, expand arbitrary data.
  • Your data is complex or unstructured
  • Applications are Insert-intensive (write-intensive)
  • Need system with high redundancy mechanism (High Availability)
  • Need a system that can scale quickly and easily

Some terms of MongoDB

When you are used to working with RDBMS, switching to MongoDB will be a bit confusing at first because some of the concepts of RDBMS will be different from MongoDB.

You can see a mapping between the conceptual equivalents of RDBMS and MongoDB as follows: image.png

In the next section, we will dig a little deeper into how the MongoDB system architecture works!

Share the news now

Source : Viblo