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.
About this Task
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 data after you generate a diagram, Compass does not automatically update the diagram. You must create a new diagram to see your changes.
Before You Begin
To generate an entity-relationship diagram in Compass, your database must have at least one collection with data.
Steps
(Optional) Toggle automatically inferred relationships
In the 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.
Click Generate
Compass generates an entity-relationship diagram with the selected collections and displays it in the current tab. Compass also displays the Data Model Overview side panel where you can rename your diagram and view the following information:
The database you used to generate your diagram
When you first generated the diagram
When you last updated your diagram
After you generate a diagram, Compass displays the existing diagrams in the Data Modeling tab.
Note
If you click a collection or field in your diagram, the side panel displays information about the collection or field. To go back to the Data Model Overview, deselect the collection or field by clicking the empty space in your diagram.