Docs Menu

Docs HomeDevelop ApplicationsMongoDB Manual

Databases and Collections in MongoDB

On this page

  • Overview
  • Databases
  • Collections

MongoDB stores data records as documents (specifically BSON documents) which are gathered together in collections. A database stores one or more collections of documents.

You can manage databases and collections on the Atlas cluster from the Atlas UI, mongosh, or MongoDB Compass. This page describes how to manage databases and collections on the Atlas cluster from the Atlas UI. For self-managed deployments, you can use mongosh or MongoDB Compass to manage databases and collections.

Select the client that you want to use to manage databases and collections.

In MongoDB, databases hold one or more collections of documents.

MongoDB stores documents in collections. Collections are analogous to tables in relational databases.

A collection of MongoDB documents.
click to enlarge

If a collection does not exist, MongoDB creates the collection when you first store data for that collection.

By default, a collection does not require its documents to have the same schema; i.e. the documents in a single collection do not need to have the same set of fields and the data type for a field can differ across documents within a collection.

Starting in MongoDB 3.2, however, you can enforce document validation rules for a collection during update and insert operations. See Schema Validation for details.

For deployments hosted in MongoDB Atlas, the Performance Advisor and the MongoDB Atlas UI detect common schema design issues and suggest modifications that follow MongoDB best practices. To learn more, see Schema Suggestions.

To change the structure of the documents in a collection, such as add new fields, remove existing fields, or change the field values to a new type, update the documents to the new structure.

Collections are assigned an immutable UUID. The collection UUID remains the same across all members of a replica set and shards in a sharded cluster.

← Getting Started with MongoDB
Views →