NoSQL Basics (MongoDB Overview)
Part of the Data Science Roadmap
In short
Not all data fits neatly into rows and columns. App events, product catalogues and user profiles often live in document databases like MongoDB, and you'll need to pull data from them.
A high-level look at document-based databases like MongoDB — storing flexible, nested JSON-like documents instead of rigid rows and columns, common for semi-structured data like logs or events.

Think of it like this
Student files in the office
The school office keeps one folder per student. One folder has a sports certificate, another has three medical notes, a third has neither. No fixed form, just whatever belongs to that student. MongoDB stores each record as a flexible document like that folder.
Watch it happen
One order document
1/4One document holds a whole order, stored as JSON-like data called BSON.
The big ideas
What you need to know
Documents, not rows
Each record is a JSON-like document in a collection. Fields can nest and vary between documents.
Store together what's read together
Embedding items inside an order makes reads fast, at the cost of some duplication.
Flexible but less strict
No fixed schema means messy data is easy to insert. Expect to clean more when you analyse it.
Many NoSQL types
Document (MongoDB), key-value (Redis), wide-column (Cassandra) and graph (Neo4j) suit different jobs.
See it in code
Walk through the code
1from pymongo import MongoClient2 3db = MongoClient("mongodb://localhost:27017")["shop"]4 5db.orders.insert_one({6 "customer": {"name": "Riya", "city": "pune"},7 "items": [{"sku": "chai-500g", "qty": 2}],8 "status": "delivered",9})10 11pune = db.orders.find({"customer.city": "pune", "status": "delivered"})12print(len(list(pune)))1/3Connect to a local MongoDB server and pick the 'shop' database.
pymongo talks to MongoDB from Python. Documents go in as plain dictionaries, and queries are dictionaries too.
Save yourself the pain
Common mistakes
Oops
Assuming every document has the same fields.
Do this instead
Check with a sample first. Use .get() in Python, and expect missing or differently named fields.
Oops
Picking MongoDB for heavily related data needing many joins.
Do this instead
Relational databases handle many-table joins and strict consistency better. Choose by how data is used.
Your mission
Flatten documents into a table
Quick check
Why might an order document embed its items instead of storing them in a separate collection?
Go deeper
- 1Explore a free MongoDB Atlas sandbox with a sample collection.
- 2Learn the basic CRUD operations (find, insert, update, delete) in MongoDB's query syntax.
- 3Understand when a document database fits better than a relational one.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.