Docs Home → Develop Applications → MongoDB Manual
Databases and Collections in MongoDB
On this page
Overview
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.
Databases
In MongoDB, databases hold one or more collections of documents.
Create a Database
Collections
MongoDB stores documents in collections. Collections are analogous to tables in relational databases.
Create a Collection
If a collection does not exist, MongoDB creates the collection when you first store data for that collection.
Explicit Creation
Document Validation
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.
Modifying Document Structure
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.
Unique Identifiers
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.