👋 Introduction
MongoDB is a popular NoSQL database designed to store and manage data in a flexible, document-based format using JSON-like documents.
Unlike traditional relational databases, MongoDB allows developers to work with unstructured or semi-structured data easily, making it perfect for modern applications in Data Engineering and Data Analysis.
Through this hands-on task, I learned how to:
Install and set up MongoDB (locally or via cloud using MongoDB Atlas)
Import datasets and store records
Perform CRUD operations (Create, Read, Update, Delete)
Export query results for further analysis
This activity helped me understand how real-world data can be stored, queried, and analyzed efficiently using a NoSQL database.
⚙️ Installation Steps
I installed MongoDB using MongoDB Compass, which provides a user-friendly graphical interface for database operations.
After connecting to the local MongoDB server (mongodb://localhost:27017), I created a new database named reviewsDB and a collection called businesses to store my data.
📂 Importing Dataset
Next, I imported my dataset — the Yelp Reviews Dataset downloaded from Kaggle.
Using MongoDB Compass, I selected “Add Data → Import File”, chose the JSON dataset, and imported it into my businesses collection.
All records were successfully displayed in the Compass data viewer.
💻 Performing Queries
1️⃣ Insert at least 10 records manually
db.businesses.insertMany([
{business_id: 1, name: "Cafe Aroma", rating: 4.5, review: "Good coffee and great service!"},
{business_id: 2, name: "Pizza Hub", rating: 4.2, review: "Tasty pizza and good ambience."},
{business_id: 3, name: "Burger Bite", rating: 3.9, review: "Decent burgers, good value."},
{business_id: 4, name: "Sweet Treats", rating: 4.8, review: "Excellent desserts!"},
{business_id: 5, name: "Veggie Delight", rating: 4.0, review: "Healthy food and good taste."},
{business_id: 6, name: "Spice Route", rating: 4.6, review: "Authentic and spicy dishes."},
{business_id: 7, name: "Urban Eatery", rating: 4.3, review: "Modern setup and good food."},
{business_id: 8, name: "Taco Time", rating: 3.8, review: "Average tacos but good service."},
{business_id: 9, name: "Pasta Palace", rating: 4.7, review: "Great pasta and ambience."},
{business_id: 10, name: "Choco Heaven", rating: 4.9, review: "Best chocolates and cakes ever!"}
])
2️⃣ Top 5 businesses with highest average rating
db.businesses.find().sort({rating: -1}).limit(5)
3️⃣ Count reviews containing the word “good”
db.businesses.countDocuments({review: /good/i})
4️⃣ Get all reviews for a specific business ID
db.businesses.find({business_id: 2})
5️⃣ Update a review
db.businesses.updateOne(
{business_id: 3},
{$set: {review: "Delicious burgers with excellent value!"}}
)
6️⃣ Delete a record
db.businesses.deleteOne({business_id: 8})
📤 Exporting Results
After running each query, I used the Export Results feature in MongoDB Compass to save my outputs.
The data was exported in both JSON and CSV formats for further analysis or submission.
🎓 Conclusion
This MongoDB hands-on activity gave me practical experience in managing NoSQL data.
I learned how to:
Create and manage collections
Perform CRUD operations
Query and filter data using expressions and patterns
Export and visualize real-world datasets
MongoDB’s flexible schema and JSON-based structure make it an essential tool for Data Engineers and Analysts, especially when handling large, diverse datasets where relational models are less effective.
It’s a valuable skill for anyone interested in data pipelines, analytics, or backend engineering.










Top comments (0)