Powered by Blogger.

Monday, August 26, 2019

What Is MongoDB

MongoDB is a cross-platform, document oriented database that provides, high performance, high availability, and easy scalability. MongoDB works on concept of collection and document.

MongoDB is an open-source document database and leading NoSQL database. MongoDB is written in C++. This tutorial will give you great understanding on MongoDB concepts needed to create and deploy a highly scalable and performance-oriented database.

                                                          Components of Mongo


Database is a physical container for collections. Each database gets its own set of files on the file system. A single MongoDB server typically has multiple databases.


Collection is a group of MongoDB documents. It is the equivalent of an RDBMS table. A collection exists within a single database. Collections do not enforce a schema. Documents within a collection can have different fields. Typically, all documents in a collection are of similar or related purpose.


A document is a set of key-value pairs. Documents have 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.
The following table shows the relationship of RDBMS terminology with MongoDB.


In MongoDB, each document stored in a collection requires a unique _id field that acts as a primary key. ... The _id field has the following behavior and constraints: By default, MongoDB creates a unique index on the _id field during the creation of a collection. The _id field is always the first field in the documents.

Embedded Documents

Collections and embedded documents in MongoDB. ... This distinction is very important because, although MongoDB is schema less in nature, whether or not an element of your database is structured as embedded documents or a separate collection will change your code a fair amount

Table JoinEmbedded Documents
Primary KeyPrimary Key (Default key _id provided by mongodb itself

MongoDB Features

    1. Each database contains collections which in turn contains documents. Each document can be different with a varying number of fields. The size and content of each document can be different from each other.
    2. The document structure is more in line with how developers construct their classes and objects in their respective programming languages. Developers will often say that their classes are not rows and columns but have a clear structure with key-value pairs.
    3. As seen in the introduction with NoSQL databases, the rows (or documents as called in MongoDB) doesn't need to have a schema defined beforehand. Instead, the fields can be created on the fly.
    4. The data model available within MongoDB allows you to represent hierarchical relationships, to store arrays, and other more complex structures more easily.

No comments:

Post a Comment