Elie Hannouch: Article - MongoDB 101, Your first steps to build the next big thing - PART 1

Introduction

  • Hello amazing people, I’m Elie the MongoDB user group lead in Lebanon :lebanon:, I’m happy to share with you the first article, discovering mongoDB, it’s key features, defining our first steps to build the next big thing in the future.

What is a database?

  • A database is a collection of data stored and organized in a specific manner, allowing efficient data manipulation (retrieval, insertion, modification, deletion). Such databases are used to store a wide range of information’s, scaling from a small collection of data like contact lists, to a large and complex data set powering critical missions’ applications like e-commerce websites, ticketing systems, CRM’s …

Relational vs. No-Relational databases

  1. Relational databases: A relational database, is a way of structuring information’s in tables, rows, and columns with the ability to establish relations between them by joining these tables, making it more understandable, where you can get insights about the relationship between various data points. Some of the most well-known Relational Database Management Systems include MySQL, PostgreSQL, Microsoft SQL Server, and Oracle Database.

  2. No SQL databases: It’s a non-tabular database that store data differently than relational tables. NoSQL databases come in a variety of types based on their data model, including key-value, document, column-based and graph databases. Providing a schema flexibility, easy to scale techniques with large amounts of data and high user loads. Some of the most well-known non-relational databases includes MongoDB, Apache Cassandra, Redis, Couchbase and Apache HBase.

MongoDB: Build the next big thing :shamrock:

  • MongoDB is a scalable, flexible NoSQL document database used for storing, retrieving, and managing large amounts of unstructured and semi-structured data, such as text, images, and videos.

  • MongoDB stores data in flexible, JSON-like documents, meaning fields can vary from document to document and data structure can be changed over time, allowing developers to map the objects in their application code making data easy to work with.

  • MongoDB is a distributed database at its core, so high availability, horizontal scaling, and geographic distribution are built in and easy to use

MongoDB key features :trophy:

  1. Document Model:

    • MongoDB as a document-oriented DB, has been designed with developer productivity and flexibility in mind, where data is stored in documents and documents are grouped in collections, giving developers a natural friendly environment, where they can focus on the data they need to store and process, rather than worrying about how to split the data across different rigid tables.

    • Documents in MongoDB are stored in the BSON format, which is a binary-encoded JSON format. This also allows for the storage of binary data, which is useful for storing images, videos, and other binary data in flexible schema way where the documents in a single collection don’t necessarily need to have exactly the same set of fields giving developers the ability to iterate faster and migrate data between different schemas without any downtime.

  2. Sharding: For horizontal scalability. :cloud:

    • Sharding is a database scaling technique that involves horizontally partitioning data across multiple servers, in order to handle increased loads of read and write operations and improve performance. Each partition, or shard, contains a subset of the data, allowing the database to distribute the workload and improve the overall speed and efficiency of data access.

         


  1. Replication: For better data availability and stability.
  • When your business data only resides in a single server, it acts as a single point of failure with the multiple potential errors that may happen, such as a server crash, hardware failure, or even a service interruption, making the access to your data nearly impossible.

  • Here the replication technique in MongoDB come to action, where it refers to the process of synchronizing data across multiple servers.

  • A MongoDB replication set is a group of MongoDB servers that maintain identical data sets. The primary purpose of replication is to ensure high availability of data by providing redundancy and failover capability.

  • In the event of a primary server failure which accepts all write operations and applies those same operations across secondary servers, replicating the data, any one of the secondary servers can be elected to become the new primary node, ensuring that the data remains available to clients.

    image

  • Replication also helps to increase read performance by allowing clients to read from secondary nodes and can also improve write performance by spreading write operations across multiple servers.

  1. Authentication :closed_lock_with_key:

    • MongoDB authentication is a process of verifying the identity of a user who is trying to access the MongoDB database. This is used to control access to the data stored in the database and ensure that only authorized users are able to perform operations like reading, writing, and updating the data.

    • MongoDB supports several authentication methods, including Salted Challenge Response Authentication Mechanism (SCRAM), which is the default, LDAP authentication, Kerberos authentication, and X.509 certificate authentication, when SCRAM is used, the user is required to provide an authentication database, username, and password.

  2. Database Triggers :alarm_clock:

    • Database triggers in MongoDB Atlas are a powerful feature that allow you to execute code when certain events occur in your database.
  3. Ad-Hoc Queries

    • In MongoDB an Ad-hoc query is a one time or infrequent query that get executed against the database with a purpose to retrieve specific piece of data.

    • The term “ad-hoc” refers to the fact that these queries are not pre-defined or part of a regularly scheduled process. Ad-hoc queries in MongoDB are often used by end-users or analysts to perform ad-hoc analysis or retrieve specific data for a one-time use case.

    • These queries can be created and executed dynamically, using the MongoDB query language (MQL), and can search for data based on specific criteria such as values in specific fields or conditions within the documents.

  4. Load balancing

    • Load balancing in MongoDB is the process of distributing incoming database traffic across multiple servers to improve performance and avoid overloading any single server. This helps to ensure high availability and reduce the risk of a single point of failure. Load balancing in MongoDB can be done through various methods, such as client-side load balancing, server-side load balancing, or sharding the data across multiple servers.
And now we reached the end of our first article, feel free to read it, 
share it with your fellows so everything stay from the community to the community. 

Stay tuned our second article will published soon, diving in MongoDB Atlas.
5 Likes

This is a great quick read for anyone planning to get a quick 101 about MongoDB! Thanks @eliehannouch.