DEV Community

Jeyashrisekar
Jeyashrisekar

Posted on

Exploring MongoDB - Great Start to learn Data Analytics

Hi there,

As a beginner in databases, I recently started exploring MongoDB, a popular NoSQL database. Unlike traditional SQL databases, MongoDB stores data in flexible JSON-like documents, making it a great choice for modern applications that need scalability and flexibility.

1. STARTING
I started my MongoDB journey by installing the MongoDB. Then I created a Database and Collection named Business and review respectively.

2. IMPORTING THE DATASET
Then I imported my "yelp.json" which have 1000 rows.

3. INSERTING THE MANY DATASETS through insertMany()
After importing the dataset, I had inserted 10 dataset using insertMany().

After insertion, i got the output like this

3. Query to find top 5 businesses with highest average rating

Then I found Top 5 businesses with highest average rating after perform aggregate function

db.review.aggregate([
{ $group: { _id: "$business_id", avg_rating: { $avg: "$stars" } } },
{ $sort: { avg_rating: -1 } },
{ $limit: 5 }
])

5. Query to count how many reviews contain the word “good”.

I used countDocuments to cound the reviews contain "good"

db.review.countDocuments({ text: /good/i })

6. Query to get all reviews for a specific business ID.

I get all reviews for a specific business ID using find()

db.review.find({ business_id: "01" })

7. Update a review and delete a record
7.1: Update 1 dataset using updateOne()

db.review.updateOne(
{ review_id: "A02" },
{ $set: { stars: 5, text: "Updated: Excellent food and very friendly staff." } }
)

7.2: Delete 1 dataset using deleteOne()

db.review.deleteOne({ review_id: "E01" })

Conclusion

This exercise gave me a clear understanding of how MongoDB handles real-world data in a flexible way. From inserting and retrieving reviews to performing text searches, aggregations, updates, and deletions — MongoDB makes working with data simple and powerful.

For Data Engineers and Developers, MongoDB is an essential tool to master, as it allows storing large-scale, unstructured, or semi-structured data efficiently. This small project was just the beginning of my #LearningJourney, and I look forward to exploring advanced MongoDB features like indexing, schema validation, and aggregation pipelines in the future.

Top comments (0)