What is a collection in MongoDB?
A collection in MongoDB is a group of documents, analogous to a table in a relational database, but with no fixed schema.
The main points
- Holds documents
A collection groups documents that are related in meaning, e.g.
users,orders,products. - No rigid schema Documents inside the same collection can have different sets of fields, the database allows this.
- Organizing data within a database Every collection belongs to a specific database and acts as a logical container.
- Indexes and settings Indexes, validation rules, TTL, and other parameters can be defined on a collection.
Summary: a collection is a logical grouping of documents in MongoDB, analogous to a table, but more flexible and without a fixed structure.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.