Docs Menu
Docs Home
/ /

Manage Relationships in Your Compass Entity-Relationship Diagram

You can manually define relationships between fields across different collections in your Compass entity-relationship diagram.

Note

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

You can manually add relationships to your entity-relationship diagram by using one of the following methods:

  • Side Panel: Manually add a relationship by selecting a source collection.

  • Drag and Drop: Create a relationship by clicking and dragging from one collection to another.

In addition to specifying collection and field properties for each relationship, you can also specify cardinality. In data modeling, cardinality refers to the number of records in one collection that can relate to one or more records in another collection. Cardinality can help you decide whether to embed or reference data in your data model. To learn more, see Document Relationships.

To add relationships, ensure you have already generated a diagram.

To learn how to add relationships to your entity-relationship diagram, select the tab corresponding to your preferred method:

1

From the Data Modeling tab, open your entity-relationship diagram.

2

Click one of your collection nodes in the diagram. The collections side panel opens on the right side of the screen.

3

In the side panel's Relationship tab, click Add Relationship.

4

Specify values for the following fields under Relationship Properties:

  • Local collection: The primary collection in the relationship.

  • Local field: The field in the primary collection.

  • Local cardinality: The number of unique values in the local field.

  • Foreign collection: The target collection in the relationship.

  • Foreign field: The field in the target collection.

  • Foreign cardinality: The number of unique values in the foreign field.

Compass automatically saves and updates your changes as you make them.

5

In the side panel's Notes tab, you can add annotations for your relationship. This can be helpful for documenting the purpose and details of the relationship.

1

From the Data Modeling tab, open your entity-relationship diagram.

2

In the upper-left corner of the diagram view, click the icon to enable drag-and-drop relationship creation.

3

When you click a collection and drag it to another, Compass opens the side panel and displays the Relationship Properties tab.

4

Specify values for the following fields under Relationship Properties:

  • Local collection: The primary collection in the relationship.

  • Local field: The field in the primary collection.

  • Local cardinality: The number of unique values in the local field.

  • Foreign collection: The target collection in the relationship.

  • Foreign field: The field in the target collection.

  • Foreign cardinality: The number of unique values in the foreign field.

Compass automatically saves and updates your changes as you make them.

5

In the side panel's Notes tab, you can add annotations for your relationship. This can be helpful for documenting the purpose and details of the relationship.

After you create a relationship, Compass displays each relationship in the Relationships tab.

To delete a relationship from your entity-relationship diagram:

1

Click on the relationship in the diagram. The relationship side panel opens on the right side of the screen.

2

In the Relationship Properties tab, click the Delete button.

Back

Modify Fields

On this page