MongoDB

Introduction

--

MongoDB is a document database. And It stores data in JSON-like documents.

It Supports nested objects and arrays as values. And it also allows for flexible and dynamic schemas.

Moreover, MongoDB is a NoSQL document database which is querying with JavaScript. Therefore it has strong query capabilities with aggregation using JavaScript. And it uses spiderMonkey JavaScript engine. Where spiderMonkey is a Firefox JavaScript engine.

MongoDB also manage its clusters keeping a high availability.

Storage

Simply It can store files less than 16MB.

What’s more interesting is, If the file size exceeds 16MB it stores the files in an in built file storage known as Grid File System. Thereby GridFS is a versatile storage system.

Multi-document Transaction Feature

Multi-document transactions are atomic.

The operations that we perform can be acted as a transaction. Eg: Rollback features

But this feature is available only above version 4.2 of the MongoDB.

Furthermore, With distributed transactions, transactions can be used across multiple operations, collections, databases, documents, and shards.

Indexes

Indexes are special data structures.

It stores a small part of the collection’s data set in an way that it can traverse through it easily.

There are 6 types of indexes:

  1. Single Field index — Creation of user-defined ascending/descending indexes and it may support single query

2. Compound index— User-defined indexes on multiple fields/queries

3. Multi-key — Used to index the content stored in arrays

4. Text index — Supports searching for string content in a collection. And it does not store language specific words.

5. Geospatial indexes — Used for queries of geospatial coordinate data.

6. Hashed indexes — Used for hash based sharding

Indexes consist of 5 properties namely:

  • Unique
  • Partial
  • Sparse
  • TTL
  • Hidden

Replica setup

Replica sets provide redundancy and high availability. It is a set of mongod instances that maintain the same data set. Replica set is a distributed structure introduced by MongoDB. It can have up to 50 members and 7 voting members.

Sharding

Sharding is a strategy for conveying information across numerous machines. MongoDB utilizes sharding to help organizations with extremely huge informational collections and high throughput activities.

Sharding has keys. It also saves data with regard to a certain logic and data sepcification on different instances.

Mongo 3T Studio

Mongo 3T studio is an application that can be used to run mongoDB queries.

All the CRUD operations can be performed using this application.

CRUD Operations

  • Create / Insert
Figure I
  • Read / Find
Figure II
  • Update
Figure III
  • Delete
Figure IV

These are the basic create, read, update and delete functions that are performed using MongoDB.

--

--