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中将数据模型可视化为实体关系图。实体关系图可以帮助您理解和记录数据库中数据之间的关系,并计划对模式的更改。
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.Compass基于您在数据库中选择的每个集合中的一小部分文档样本生成实体关系图。由于此采样,图表可能无法反映数据中的所有字段或关系。
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.如果在生成图表后对数据进行了任何更改,Compass不会自动更新图表。您必须创建一个新图表才能查看更改。
Before You Begin开始之前
To generate an entity-relationship diagram in Compass, your database must have at least one collection with data.要在Compass中生成实体关系图,数据库必须至少有一个包含数据的集合。
Steps步骤
Click Generate diagram单击生成图表
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.如果您在“数据建模”选项卡中保存了现有图表,则可以通过单击屏幕右上角的“生成新图表”来创建新图表。
Select your MongoDB connection选择MongoDB连接
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.使用下拉菜单选择要使用哪个MongoDB连接来生成图表。“活动”标签出现在任何当前活动的连接名称下。
Select your database选择数据库
Use the drop-down menu to select which database to use for your data model diagram.使用下拉菜单选择要用于数据模型图的数据库。
Select collections选择集合
Use the checkboxes to select which collections to include in your data model diagram.使用复选框选择要包含在数据模型图中的集合。
(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.启用后,Compass会分析所选集合,并根据包含对其他集合的引用的索引字段添加关系。
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.关系仅用于注释目的。Compass不会将关系信息存储在MongoDB数据库中。