04 / 12

What is a collection in NoSQL database?

Difficulty: 3/10
collections, schema design, indexing

A 'collection' is a group of documents that are stored together in a NoSQL database. It is similar to a table in a RDBMS.

In addition to collections, MongoDB supports:
  1. 1

    Read-only Views

  2. 2

    On-Demand Materialized Views

Scenario Questions

0-2 years experience

  1. 1How would you create a new collection for storing user profiles in MongoDB, and what default index does MongoDB add?
  2. 2If you insert a document into a collection that doesn't exist yet, what does MongoDB do behind the scenes?
  3. 3What happens when you query a collection that currently has no documents?

2-5 years experience

  1. 1We need to store time‑series sensor data. Would you use a single large collection or a separate collection per device, and what trade‑offs drive that decision?
  2. 2After adding a new field to the 'orders' collection, queries became slow. How would you debug whether the collection schema or its indexes are the cause?
  3. 3Why might you choose a capped collection for application logs, and what limitations does that impose on the consumer side?

5-8 years experience

  1. 1Our service writes millions of events per minute. How would you design the collection strategy—sharding key, number of collections, TTL indexes—to sustain write throughput while keeping reads fast?
  2. 2We plan to split a monolithic collection that stores multiple entity types into separate collections per entity. What steps ensure data consistency and minimal downtime?
  3. 3If a collection grows to hundreds of gigabytes and you start seeing page faults, what collection‑level tuning options would you explore (e.g., index redesign, compression, storage engine changes)?

8+ years experience

  1. 1You are leading a cross‑team effort to standardize data modeling. How would you decide when to use a single shared collection versus service‑owned collections, considering schema evolution, operational ownership, and backup/restore?
  2. 2Our organization is migrating from on‑prem MongoDB to a managed cloud service. What collection‑level considerations (capped vs. regular, sharding strategy, index policies) affect the migration plan and long‑term cost?
  3. 3Describe how you would establish governance around collection naming conventions, TTL policies, and index usage to prevent technical debt across dozens of microservices.

Follow-up Questions

  • What default index does MongoDB create for every collection and why is it important?
  • How would you verify that a collection was created with the options you intended?
  • If a collection starts growing rapidly, what metrics would you monitor first?
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.