MongoDB & MongooseInterview preparation
Foundation·Concept·2 min read

What are documents, collections, BSON and ObjectId?

Practice this question

Definition:

MongoDB stores records as documents, which group related field values in one JSON-like structure. A collection holds documents, and BSON is the binary encoding that supports values such as dates and ObjectIds. An ObjectId is a common identifier format with a timestamp component, but it is not an authorization mechanism or a strict business ordering guarantee.

Key points:

  • A document is one record; a collection groups records.

  • BSON is the binary format MongoDB uses, with types such as dates and ObjectIds.

  • ObjectId is a common default _id; it is not a secret or proof of access.

  • Documents in one collection can have different fields, but application and database validation can still enforce a deliberate schema.

Interview point:

  • “Flexible schema” means you control schema evolution; it does not mean data structure stops mattering.
Adapted from 04_MONGODB_MONGOOSE.md · “What are documents, collections, BSON and ObjectId?”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.