MongoDB & BSON

From Coders.Bay Wiki
Jump to navigation Jump to search

MongoDB - DBMS

What is MongoDB?[edit]

MongoDB is an open-source document-oriented DBMS, also known as a NoSQL database. Instead of the usual relational tables it uses JSON-like documents with optional schemas, which are stored in collections. The format used is called BSON.

What is BSON?[edit]

BSON stands for Binary JSON and it was invented to be a faster version of JSON. The binary structure encodes the type and length information of the Data which allows it to be parsed more quickly. BSON also allows for comparisons and calculations to happen directly in the data and adds data types like dates and binary data which would otherwise be missing from MongoDB.


Why use MongoDB?[edit]

Structuring data in MongoDB is flexible, which makes it possible to store the data in a more readable way for users and increase the processing performance of the data. MongoDB is highly scalable which makes it preferred in storing big quantities of data.

A major feature of MongoDB is replication. A replica set consists of two or more copies of the data, and the original set is called primary. Reading and writing is done on the primary set until it fails. Then internally an election process starts to select which secondary set is becoming the new primary. This feature helps to counter server failure because the data is kept as a replica on different servers.

To balance out the load and keep performance high MondoDB is using sharding. This way the data is split into ranges and distributed across multiple shards. By adding more Servers the data will be further distributed.

Why not to use MongoDB?[edit]

There was a controversy with the standard security configuration on MongoDB that allowed unauthorized users to steal data and demand a ransom to recover it. Most of the affected databases were breached due to insufficient security configuration and the lack of authorization on the servers themselves. To counteract that, MongoDB's standard out of the box configuration now includes stricter security options.

At the moment, because of the conflict between western countries and Russia, the sanctions laid upon Russia are resulting in inability for Russian users to keep their data. All the data will be deleted after a grace period where it can be secured.

How to install MongoDB?[edit]

MongoDB has different Editions:

MongoDB Community Server MongoDB Enterprise Server MongoDB Atlas

Installing the Community Edition:[edit]

The easiest way to install MongoDB Community Edition ist through the install wizard. Download the .msi File from the MongoDB homepage and follow the instructions.

It is possible to only install part of the tools that are needed in the Custom part of the installation but for new users the complete installation is advised.


With the installation Wizard, the MongoDB GUI Compass will also be installed and on startup will show you the features available. The GUI makes it easy to start a new connection and access and create new Databases and Collections.

Compass_UI Compass_UI_2

Adding data is made easy with MondoDB Compass by just clicking on the add data button to be able to import from a file or Manually input data.


by Vidan Vincetic