> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

# Data Modeling in MongoDB Compass

MongoDB Compass Readonly Edition will be deprecated in a future release. To replicate the read-only behavior in a standard Compass edition, assign users [`read`](https://www.mongodb.com/docs/manual/reference/built-in-roles.md#mongodb-authrole-read) access at the database level and enable the [readOnly](https://www.mongodb.com/docs/compass/settings/read-only.md#std-label-compass-read-only) option in Compass.

Use Compass to create an entity-relationship diagram that visualizes the collections, fields, data types, and relationships in a single database.

## Diagram Quickstart

Use the following procedure to create your first entity-relationship diagram in Compass.

1. Open the Data Modeling tab

   In the left sidebar, click  Data Modeling.

2. Click Generate diagram

   In the New diagram setup modal, select the connection and database to use. You can create a name for your diagram or use the default name that Compass creates.

3. Select collections

   Select the collections to include in your diagram. If you want Compass to analyze relationships within your collection, make sure the Automatically infer relationships setting is on.

4. Click Generate

   Compass generates an entity-relationship diagram with the selected collections and displays the diagram in the current tab.

For detailed instructions and configuration options, see [Generate an Entity-Relationship Diagram in Compass.](https://www.mongodb.com/docs/compass/data-modeling/generate-diagram.md#std-label-compass-create-data-model-diagram)

## Use Cases

Consider the data modeling experience in Compass for the following scenarios:

- **Data visualization**: Generate an entity-relationship diagram of your current data model. Visualizing your data model can help you identify impacts of potential schema changes across related collections.

- **Data model planning**: Track and plan changes to your data structure as your application grows. Model new collections and relationships before you implement them to validate design decisions early.

- **Cross-team collaboration**: Share visual representations of your data model with data engineers, product managers, and other stakeholders to ensure everyone understands the current state of your database structure. You can share your data model as an image, JSON file, or `.mdm` file that can be opened directly in Compass.

- **Application development**: Identify inconsistencies, missing relationships, or optimization opportunities in your data model during the development process.

- **Team member onboarding**: Quickly understand existing data models when onboarding onto a new project or working with collections created by other teams.

## Considerations

### Annotations

You can add comments to your diagram's collections, fields, and relationships to document definitions or data modeling decisions.

### Relationships

You can define relationships between fields in different collections in your entity-relationship diagram. When you [create an entity-relationship diagram](https://www.mongodb.com/docs/compass/data-modeling/generate-diagram.md#std-label-compass-create-data-model-diagram), you can opt for Compass to automatically infer relationships. You can also [manually add relationships.](https://www.mongodb.com/docs/compass/data-modeling/relationships.md#std-label-compass-data-modeling-relationships)

**Note:**

Relationships are for annotation purposes only. Compass does not store relationship information in your MongoDB database.

### Sharing Diagrams

You can [export](https://www.mongodb.com/docs/compass/data-modeling/export-diagram.md#std-label-compass-data-modeling-export) your Compass entity-relationship diagram. By sharing your diagram, you can collaborate with various teams, receive feedback, and align on final schema design decisions.

You can export your diagram as a:

- `.mdm` Diagram File.

- PNG image.

- JSON file.

You can also [import](https://www.mongodb.com/docs/compass/data-modeling/import-diagram.md#std-label-compass-data-modeling-import) Compass an entity-relationship diagram that was exported as a `.mdm` file. By importing an entity-relationship diagram, you can view or edit a diagram shared by a collaborator.

### Side Panel

You can view the following general information about your diagram in the Data Model Overview side panel:

- The database you used to generate your diagram

- When you first generated the diagram

- When you last updated your diagram

If you click a collection, the side panel displays information about the collection, including its name, relationships, and custom notes.

If you click a field, the side panel displays information about the field, including its name, data type, and relationships.

**Note:**

To go back to the Data Model Overview from the collection or field view, deselect the collection or field by clicking the empty space in your diagram.

To open the side panel, click the  icon.

## Next Steps

- [Modify collections](https://www.mongodb.com/docs/compass/data-modeling/modify-collections.md#std-label-compass-modify-data-model-collections)

- [Modify fields](https://www.mongodb.com/docs/compass/data-modeling/modify-fields.md#std-label-compass-modify-data-model-fields)

- [Manage relationships](https://www.mongodb.com/docs/compass/data-modeling/relationships.md#std-label-compass-data-modeling-relationships)

- [Export and share your diagram](https://www.mongodb.com/docs/compass/data-modeling/export-diagram.md#std-label-compass-data-modeling-export)

## Learn More

- [Data Modeling in MongoDB](https://www.mongodb.com/docs/manual/data-modeling.md#std-label-manual-data-modeling-intro)
