NoSQL · Data models beyond tables
How does MongoDB represent and query documents?
Short answer
MongoDB stores BSON documents in collections, each with an _id and a 16 MB limit. You query with a filter document and can update nested fields with dot notation and array operators.
BSON extends JSON with types such as dates, decimals, ObjectId and binary data. Fields are ordered, which matters for some indexes and comparisons. Every document has an _id that is unique within its collection and indexed by default.
db.users.insertOne({
_id: "user_7",
name: "Asha",
createdAt: new Date("2026-10-01"),
addresses: [
{ city: "Bengaluru", primary: true },
{ city: "Pune", primary: false }
]
});
db.users.find(
{ "addresses.city": "Pune" },
{ name: 1, "addresses.$": 1 }
);Limits that shape the model
- A document cannot exceed 16 MB, so unbounded arrays must be split
- Field names are repeated in every document, which costs space at scale
- Updates to nested fields still rewrite the document on disk
- Schema validation is optional but strongly recommended for critical collections
MongoDB is not a free-form file store. Query performance depends on indexes that match your filters and sort order. A find on an unindexed field scans the collection, which may be fine for a tiny collection and disastrous for a large one.
Follow-ups you should expect
Interviewers use these to check whether the first answer was understanding or memorisation.
- 1What is the difference between BSON and JSON?
- 2Why does MongoDB need an _id index?
- 3How do you update an element inside an array?
- 4What do you do when a document approaches 16 MB?
Say it in the interview
MongoDB stores BSON documents in collections, and every document has an indexed _id. I query with a filter document, use dot notation for nested fields and array operators for updates. The 16 MB limit is the main physical constraint, so I split data that can grow without bound. I also add schema validation on important collections, because schemaless does not mean the application has no schema.
Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.
Related questions
Reading is step one
Now say it out loud.
Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live NoSQL mock interview and get scored feedback on depth, clarity and confidence.