Docs Menu
Docs Home
/ /

Generate an Entity-Relationship Diagram in Compass

Generate a visualization of your data model as an entity-relationship diagram in Compass. Entity-relationship diagrams can help you understand and document the relationships between data in your database and plan changes to your schema.

Compass generates an entity-relationship diagram based on a small sample of documents from each collection you select in your database. Due to this sampling, your diagram might not reflect all fields or relationships in your data.

If you make any changes to your schema after you generate a diagram, Compass does not automatically update the diagram. You must create a new diagram to see your changes.

To generate an entity-relationship diagram in Compass, your database must have at least one collection with data.

1

In the left sidebar, click Data Modeling.

2

If you have existing diagrams saved in the Data Modeling tab, you can create a new diagram by clicking Generate new diagram in the upper-right corner of the screen.

3
4

Use the drop-down menu to select which MongoDB connection to use to generate your diagram. The Active label appears under any currently active connection name.

5

Use the drop-down menu to select which database to use for your data model diagram.

6

Use the checkboxes to select which collections to include in your data model diagram.

7

In the :guilabel:` Select collections` modal, you can choose to Automatically infer relationships between collections. When enabled, Compass analyzes the selected collections and adds relationships based on indexed fields that contain references to other collections.

You can also manually add and edit relationships after you generate your diagram.

Note

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

8

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

After you generate a diagram, Compass displays the existing diagrams in the Data Modeling tab.

  • Data Modeling

  • Data Modeling in MongoDB Compass

Back

Data Modeling

On this page