OverviewMongoDB - General IntroductionMongoDB 7.0 New FeaturesMongoDB Compass and its featuresInstallation and set-up (tutorial starts here)DataOperationsAbout AuthorsSai Manasa IvaturiSrinivas vaddi
Overview
In this article we will do a deep dive into how we could leverage MongoDB Compass to learn how to build queries with filters, aggregations, and pipelines and create complex queries in the pipeline with stage manager and also learn about the new features of MongoDB 7.0 such as time series collections, resumable index builds, schema analysis and more.
This tutorial is intended for anyone who has a basic knowledge of MongoDB and its terminology. Only a laptop is required to work and follow this tutorial.
In this section, we will try to get an overview of what we are going to cover in this tutorial and what we will be learning.
MongoDB - General Introduction
A database is a system that stores and manages data in a structured way. There are different types of databases, such as relational databases, which use tables with fixed schemas, and non-relational databases, which use other data models, such as key-value pairs, documents, graphs, etc. These non-relational databases are also known as NoSQL databases.
One of the most popular NoSQL databases is MongoDB, which is a document database. MongoDB stores data in collections, which are containers that hold documents. Each document is like a file that contains information about an item, and each item can have different fields and values. Unlike relational databases, documents do not have to follow a fixed structure or format. They can have different fields and values depending on the item.
For example, a collection of contacts might have documents for each person, and each document might have fields for their name, phone number, email, hobbies, etc. Some documents can have additional fields for address, state, zip code, etc.
You can learn more about the differences between SQL and NoSQL databases.
MongoDB 7.0 New Features
MongoDB 7.0 brings many changes and improvements to the database, such as:
- Queryable Encryption General Availability: A new feature of MongoDB that allows organizations to encrypt data while it is being queried and in use, using an approximate method based on the t-digest algorithm. This feature enhances data security and privacy without compromising performance or functionality.
- New Aggregation Operators ($median, $percentile): Two new operators in MongoDB 7.0 that calculate approximate percentile-based metrics for numeric data, using the same method as Queryable Encryption. These operators can help you analyze your data and find outliers, trends, or patterns.
- Time series collections: These are special collections that store time-series data, such as sensor readings, stock prices, or weather data. Time series collections offer better performance, compression, and analysis for this type of data. You can use them to monitor changes over time, forecast future events, or detect anomalies.
- Resumable index builds allow you to resume an interrupted index build operation without starting from scratch. This can save time and resources in case of network failures, power outages, or maintenance windows. You can also pause and resume index builds manually if needed.
- Schema analysis: This new feature in MongoDB Compass allows you to understand the structure and distribution of your data across different fields and documents. You can use schema analysis to identify data quality issues, optimize your queries and indexes, and discover new insights from your data.
Some of the above content about new features has been directly quoted from MongoDB 7.0 release notes.
MongoDB Compass and its features
- MongoDB Compass is a special utility that would allow us to visually interact with the data. Depending on what we want to do, we can do a range of things like -
- π οΈ Design and test aggregation pipelines!
- π»Β Generate and export query pipelines to code!
- π₯Β Import and export data from various sources and formats
- π₯οΈΒ Monitor and troubleshoot your MongoDB server
- π Connect to different types of MongoDB deployments, such as Atlas, replica sets, and sharded clusters
- Other features include
- Secure your data with authentication and encryption.
- Explore data schema and find anomalies
- Create and run complex queries without writing code, just queries!
- Optimize your indexes and improve performance!
Installation and set-up (tutorial starts here)
- We will need to install MongoDB and MongoDB compass.
- To avoid the complexity involved in installation and configuration we will use the official MongoDB 7.0 docker image and install the MongoDB compass as an application.
- We will be using a custom dataset that has the following schemas
Data
- While using datasets on Kaggle or elsewhere can be easy and helpful, weβve decided to make our very own dataset to do better. Here is a brief about our schema which will help us understand things from a more practical perspective.
- We are creating a sample inventory data set for a manufacturer. It should have the following collections with sample data. Note, schema might change in course of developing this tutorial but this is roughly going to remain same.
Suppliers
TheTechCruise.com Pyodide Terminal
{
"id": "f5c949ac-a31c-4e53-95fc-a3310edf96da",
"name": "Le Group",
"description": "Prove study protect interview ball safe difference.",
"contactName": "Erik Hernandez",
"contactEmail": "[email protected]",
"contactPhone": "(895)377-9806x4330",
"address": "9673 Judy Manors Apt. 130\nJanicemouth, AR 11214"
}
Products
TheTechCruise.com Pyodide Terminal
{
"id": "55fd2cd8-5c47-42bf-ad3f-415ea8e5656b",
"name": "Ram 2500 Regular Cab",
"description": "1994 Mitsubishi Mighty Max Macro Cab",
"createdDatetime": "1997-06-30T20:44:21",
"lastUpdatedDatetime": "1991-04-26T19:25:22",
"createdBy": "[email protected]",
"subproducts": [],
"history": []
}
Shipments
Shipments are made with Idβs of orders, suppliers and products
TheTechCruise.com Pyodide Terminal
{
"id": "d2745b23-a687-411e-aaa6-1d49b59e3dcb",
"name": "Doosan S500LCV",
"description": "2017 New Holland TT45A (Utility Tractor)",
"createdDatetime": "2018-07-11T04:02:04",
"completedDatetime": "1993-01-11T21:28:44",
"lastUpdated": "2003-04-18T10:14:55",
"status": "pending",
"supplierId": "eaacc442-65c4-421b-bc12-0abcc2f0cc27",
"productId": "6707c348-8280-456d-a526-6c2be44c7362",
"units": 46,
"priority": 2,
"history": []
"createdBy": "[email protected]",
"location": "9673 Judy Manors Apt. 130\nJanicemouth, AR 11214"
}
Orders
Orders are made shipmentIds, productIds and supplierIds
TheTechCruise.com Pyodide Terminal
{
"id": "5b21aaed-8c8b-4366-9d28-65a4d8129f04",
"name": "Realigned methodical synergy",
"description": "Five night environmental realize million cover.",
"createdDatetime": "1991-03-22T00:05:42",
"completedDatetime": "2011-01-01T15:08:33",
"lastUpdated": "2015-11-07T06:35:08",
"status": "cancelled",
"history": [],
"shipments": [
"3c42bbf1-4b04-46ec-b7f4-5fbe716d05d1",
"156e747b-ab84-4159-b9cc-d108d2588507",
"4c2c43aa-9bd0-4120-b5a5-55cc8f431154",
"70512e97-1cf1-48d3-bef9-f0dee953f94b",
"6f407c75-b8aa-4e8a-9124-d4432d1a42d8",
"fb984f9c-d64f-4d10-bdd1-9e8c390d360d",
"14efbcc0-dbf1-464c-99a4-a944b2f1622c",
"4c347e02-d61e-47da-9b93-802a4bd650f6",
"efb75f35-7003-456e-80de-4b575fb2fcbf",
"e3a37da0-7b84-461c-93be-6b64edcb7e8a"
],
"priority": 8,
"createdBy": "[email protected]"
}
Inventory Items
TheTechCruise.com Pyodide Terminal
{
"_id": "23d14772-83f9-4279-93f9-5bee283d9fbd",
"name": "some",
"description": "Especially along writer try in people else ask.",
"product_id": "14d085fc-17d1-4f3f-8a96-3d2df0b15149",
"units_current": 85,
"units_required": 21,
"units_safe": 58,
"updated_date": "1974-01-04T22:36:06",
"created_date": "2014-08-17T03:32:58",
"serial_number": "fafd72b9-5f45-4ef1-9196-baa86319a63a",
"shipment_id": "370ed85e-19c9-4342-b209-d3e1c204c5a9",
"order_id": "325aed92-8964-4661-a83d-ba5fa9349a79",
"bar_code": "6927003756540",
"status": "available",
"lot_number": "00eb29b3-0bba-4063-82e1-589a3c285364",
"shelf_numbers": [
811
]
}
Schema Design
- More details about this dataset are here.
Operations
In this section, we will cover
- Creating a MongoDB database and MongoDB database collectionβ
- Using
mongosh
β
- Data import using Compassβ
- Basic CRUD operations on MongoDBβ
- Simple Filteringβ
- Saving queries on MongoDB Compass
- Exporting queries to the desired language
- Exporting query results
- Export saved connections.
- Monitoring performance.
A more advanced section will cover -
- Query on Embedded documents
- Aggregations(40!)
β Β - indicates completed blogs.
Links of this tutorial -
Part 1 - https://thetechcruise.com/exploring-mongodb-7-0-with-mongodb-compass-a-comprehensive-guide-part-1-overview
Part 2 - https://thetechcruise.com/exploring-mongodb-7-0-with-mongodb-compass-a-comprehensive-guide-part-2-installation
Part 3 - https://thetechcruise.com/exploring-mongodb-7-0-with-mongodb-compass-a-comprehensive-guide-part-3-mongodb-queries
Part 4 - https://thetechcruise.com/exploring-mongodb-7-0-with-mongodb-compass-a-comprehensive-guide-part-4-filtering-data-in-mongodb
Β
More parts will be added breifly.
About Authors
Sai Manasa Ivaturi
I'm a Software Development Engineer based in Atlanta, Georgia with 5+ years of experience in the software industry. My focus area has been Backend development and full-stack development.
View my Resume here.
Masters Degree in Computer Science Indiana University, Bloomington
Jan 22 - May 23
Bachelors Degree in Computer Science Pragati Engineering College, India
Aug 14 - April 18
Certifications and badges
Srinivas vaddi
Hi! Iβm a recent masterβs graduate from Indiana University Bloomington (IUB) π and a Software Development Engineer with 4+ years of experience. Looking for #jobs!
My areas of expertise are Software Development, DevOps, Testing, Integration, Data Engineering and Data Analytics. Mostly worked on Python, Django/Flask, Apache Airflow, Apache Spark, AWS, and DevOps. I have a versatile background & a βcan doβ attitude π€.
I like blogging and sharing knowledge. Iβve built a server at home from scratch! I used it to learn various technologies and to contribute to the open-source. I love tech, philosophy, literature, and history. My favorite books π of all time are βThe Alchemistβ and βChanakya Neetiβ π.
Masters Degree in Computer Science Indiana University, Bloomington Aug 23, 2021 β Dec 17, 2022
Bachelors Degree in Computer Science Gitam University (Deemed to be) Jun 1, 2014 β Apr 1, 2018