Updated March 15, 2023
Introduction to MongoDB Relational Database
The following article provides an outline for MongoDB Relational Database. MongoDB is a No SQL database that is open source and document-oriented. It is written in C++ and provides high performance and availability. It provides auto-scaling and document-oriented databases. Initially, it was developed in 2007 in New York as PaaS( Platform as a Service) that was designed to work with big data technologies with fast features and flexible development. It provides scalability, better performance and high availability offering document-oriented storage that stores data as documents.
How to Use MongoDB?
- MongoDB works on key-value pairs. It has a database module that acts as a physical container for all of the collection. MongoDB can have multiple databases.
- It also consists of a collection that is equivalent to a table in RDMS, it can contain documents that are a set of key-value pairs these documents due to storing the values in KEY VALUE have dynamic schema modelling. Documents can have different fields, it provides the horizontal scalability.
- The document is the same as Tuple/Row in RDBMS, the data is stored as documents in MongoDB as JSON file formatted in name/value pair. The data is stored in BSON that is the Binary JSON.
- The cursor is a pointer in MongoDB that has the result set of a Query. We can iterate through the cursor to retrieve the result. We cannot use join in MongoDB as it is stored in a single collection.
- A name-value pair is called a field in a document, which can be zero or more fields.
Features of MongoDB
Given below are the features of MongoDB:
- No SQL Database: MongoDB is a No SQL database that is a document-oriented database.
- Replica: MongoDB supports the Master-Slave Replica. The master can perform the Read Write operation and the data is stored in Slave as a backup.
- Document Oriented: The data is stored as a document.
- MongoDB is written in C++.
- Schema Less: MongoDB is schema-less.
- Scalable: MongoDB is scalable and provides the property of ease of scaling out.
- Adhoc Query Support: MongoDB supports the Adhoc Query where a user can search by field and supports the regular expression.
- Indexing: We can index any field that is used in MongoDB.
- High Performance: MongoDB provides high performance to users and is relatively faster.
- It supports data with a dynamic schema where schema can be changed.
- High File Size Storage: MongoDB has the capacity of storing the high file storage having the ease of handling and querying the data.
- Easy Support and Failure Recovery: It provides easy support over data and failure recovery mechanisms to handle query processing data.
- Sharding: MongoDB stores data across multiple machines and that helps to handle bulk data.
- Freedom to run anywhere, MongoDB can run anywhere globally having the leverage of processing data throughout.
- Load Balancing: The data is horizontally split over MongoDB that allows load balancing where it can run over multiple servers and in case of any failure the data is up and recovered.
- Different data integrity pattern is not explicitly required in MongoDB. Normalization of data is not much required in MongoDB.
Examples of MongoDB Relational Database
Given below are the examples mentioned:
Let’s try making a key-value document data in MongoDB and try getting the data in.
This contains the name, age and phone.
Let’s find one Mongo Query and find the result.
This find method returns a cursor to the result. It selects the documents from a collection and the cursor is returned from the selected document. It returns a pointer and is returned by one.
The output creates the key-value pair with the _id column embedded in it.
The _id is a unique ID that is created that is the object ID for the key-value pair to be used.
Let’s check some of the queries that can be used with the MongoDB.
1. Creation of Database MongoDB: This query is used for the creation of the database.
Deletion of Database in MongoDB.
2. Db.dropDatabase(): This query is used to drop the database.
3. Creation of Collection: This query is used to create the collection.
4. Drop Collection: This query is used to drop the collection in Mongo.
From various examples and architecture, we tried to see how this MongoDB works and what use in the SQL level. The various query model showed the use case handling and working over MongoDB. We also saw the internal working and features of Mongo and its usage for various programming purposes. This article covered the basic MongoDB working, features and examples to clear the No SQL MongoDB.
This is a guide to MongoDB Relational Database. Here we discuss the introduction, how to use MongoDB? features and examples respectively. You may also have a look at the following articles to learn more –