Organizations have been using the Relational Database Management System for many decades. RDBMS is capable of providing a complete solution for database handling because we have qualified & experienced people who are implementing & maintaining these systems. But nowadays, organizations are looking for alternatives from this traditional infrastructure because of scalability. And the current need for business is to upgrade these systems.
MongoDB is a NoSQL category, open-source document-oriented database. It is popular due to its scalability & flexibility feature needed for various querying and indexing of high volume of data storage.
Basic requirements for Learning MongoDB
- Learn concepts of any programming language
- JSON knowledge will undoubtedly be a great help
- Basic idea of RDBMS
- Idea of any text editor
History of MongoDB
Back in 2007, when a NewYork based company 10gen, now referred to as MongoDB Inc, was on the verge of developing azure like service then only MongoDB was developed. Initially starting as Paas(Platform as a service), in the year 2009, MongoDB entered the market as an open-source database server.
MongoDB 2.4.9, released in January 2014, is the most stable version till now.
Features of MongoDB
- Document driven: We have various fields in the MongoDB database, unlike the rows and columns of the relational database, because of NoSQL flexibility. There are different collections of similar documents. Each document can vary according to content & size. Also, a unique id is given to every document.
- No Schema required: MongoDB is a schema-less database collection. Fields can be created as needed while in progress.
- Indexing for easy search: Searches of the query are even faster with any field getting indexed, with the help of primary as well as secondary indices.
- Support of Adhoc queries: The queries not known beforehand can be easily updated in real-time, which improve the performance of the database. Such queries are called Adhoc queries.
- Replication of Data: MongoDB uses the replication tool to distribute data to various machines. There are one master node and multiple slaves’ nodes. Whenever the primary or master node is down, maintenance becomes significantly cheaper. The execution of operation is smooth. Read and write feature is only available in the master node, whereas, in the replica, or slave only read mode is there.
- Aggregation Framework: We can perform multiple operations on the group of data. Various methods like single-purpose aggregation, map reduced function, and aggregation pipeline yield a single result.
- Storage via GridFS: The feature GridFS is used to divide the document into a small part called chunks, when files are larger than 16 MB. These chunks are stored in a separate document. Except for the last one, all other chunks are of the default size 255 KB.
- Dealing large data sets by Sharding: Methods of distributing huge data set across the web in multiple machines is called sharding. By managing the read/write operation, and to the proper division of data, we can balance the load through shards. Shard is a separate database of data & function. All the shards together form a single logical database.
From the traditional architecture of RDBMS, MongoDB offers the features of scalability, performance, flexibility, Global deployments. It mainly consists of:
- Database: The MongoDB server stores many databases with their collection of files on the file system. We can define it as an actual space for the collection of data.
- Collection: A collection behaves like a table in RDBMS. It contains a group of documents. A collection does not follow any specific structure.
- Document: Basically, in MongoDB collection of the record is called the document, which has field name & values. These are associated with a dynamic schema. With this dynamic schema feature, it accepts various data types in common fields. So, we are not forced to have same data types in common fields.
- -Id: This field represents a unique value in the document of MongoDB. It is a must required field. If a document is created without this field, the MongoDB automatically creates it. It acts as a primary key for the document.
- Cursor: Results of any type of query can be retrieved with the help of a pointer to the set of results called cursor.
- Field: The pair of name and value in a document is the field. These are just like the columns of relational databases.
MongoDB Data Modeling
MongoDB Create & Drop Database
MongoDB Create Collection
MongoDB – CRUD
• MongoDB Read Operations
• MongoDB Update Operations
• Mongodb –Delete Operations
MongoDB Read operations- query filters