Skip to main content

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

  1. Holds documents A collection groups documents that are related in meaning, e.g. users, orders, products.
  2. No rigid schema Documents inside the same collection can have different sets of fields, the database allows this.
  3. Organizing data within a database Every collection belongs to a specific database and acts as a logical container.
  4. 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 ready
Premium

A concise answer to help you respond confidently on this topic during an interview.