You can modify your existing entity-relationship diagram in Compass to plan changes to your data model without affecting your actual data.您可以在Compass中修改现有的实体关系图,以计划对数据模型的更改,而不会影响实际数据。
About this Task关于此任务
In the Data Modeling tab, you can:在“数据建模”选项卡中,您可以:
Add or remove fields添加或删除字段Change field data types更改字段数据类型Rename fields重命名字段
Note
Any changes you make to your entity-relationship diagram won't affect your actual database.您对实体关系图所做的任何更改都不会影响实际数据库。
Before You Begin开始之前
You must have an existing diagram in Compass to modify the fields. To create a new diagram, see Generate an Entity-Relationship Diagram in Compass.您必须在Compass中已有图表才能修改字段。要创建新关系图,请参阅Compass中的生成实体关系图。
Steps步骤
Add a New Field添加新字段
To add a new field to a collection in your entity-relationship diagram:要向实体关系图中的集合添加新字段,请执行以下操作:
Open your entity-relationship diagram打开实体关系图
From the Data Modeling tab, open your diagram.从“数据建模”选项卡中,打开图表。
Rename a Field重命名字段
To rename a field in your entity-relationship diagram:要重命名实体关系图中的字段,请执行以下操作:
Change a Field's Data Type更改字段的数据类型
To change the data type of a field in your entity-relationship diagram:要更改实体关系图中字段的数据类型,请执行以下操作:
Open your entity-relationship diagram打开实体关系图
From the Data Modeling tab, open your diagram.从“数据建模”选项卡中,打开图表。
Open the Field Properties side panel打开“字段属性”侧面板
Click one of your fields in the diagram. The field side panel opens on the right side of the screen.单击图表中的一个字段。现场侧面板在屏幕右侧打开。
Select a new data type选择新数据类型
In the Datatype drop-down menu, select the datatypes that you want to assign to the field. Because data in MongoDB has a flexible schema model, you can specify multiple data types for a field. If a field contains multiple data types, Compass labels the field as (mixed) in the diagram.在Datatype下拉菜单中,选择要分配给字段的数据类型。因为MongoDB中的数据具有灵活的模式模型,所以可以为字段指定多种数据类型。如果一个字段包含多种数据类型,Compass会在图表中将该字段标记为(混合)。
Remove a Field删除字段
To delete a field from your diagram:要从图表中删除字段,请执行以下操作: