Docs Home / Compass / Data Modeling

Modify Fields in Your Compass Entity-Relationship Diagram修改Compass实体关系图中的字段

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:要向实体关系图中的集合添加新字段,请执行以下操作:

1

Open the Data Modeling tab打开“数据建模”选项卡

In the left sidebar, click Data Modeling.在左侧边栏中,单击“数据建模”。

2

Open your entity-relationship diagram打开实体关系图

From the Data Modeling tab, open your diagram.从“数据建模”选项卡中,打开图表。

3

Add a new field添加新字段

To add a new field, click the icon in the upper-right corner of one of your collection nodes. A new field appears in the collection node.要添加新字段,请单击其中一个集合节点右上角的图标。集合节点中会出现一个新字段。

Once you add a field, you can edit the field's properties, including:添加字段后,您可以编辑字段的属性,包括:

Rename a Field重命名字段

To rename a field in your entity-relationship diagram:要重命名实体关系图中的字段,请执行以下操作:

1

Open the Data Modeling tab打开“数据建模”选项卡

In the left sidebar, click Data Modeling.在左侧边栏中,单击“数据建模”。

2

Open your entity-relationship diagram打开实体关系图

From the Data Modeling tab, open your diagram.从“数据建模”选项卡中,打开图表。

3

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.单击图表中的一个字段。现场侧面板在屏幕右侧打开。

Change a Field's Data Type更改字段的数据类型

To change the data type of a field in your entity-relationship diagram:要更改实体关系图中字段的数据类型,请执行以下操作:

1

Open the Data Modeling tab打开“数据建模”选项卡

In the left sidebar, click Data Modeling.在左侧边栏中,单击“数据建模”。

2

Open your entity-relationship diagram打开实体关系图

From the Data Modeling tab, open your diagram.从“数据建模”选项卡中,打开图表。

3

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.单击图表中的一个字段。现场侧面板在屏幕右侧打开。

4

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:要从图表中删除字段,请执行以下操作:

1

Open the Data Modeling tab打开“数据建模”选项卡

In the left sidebar, click Data Modeling.在左侧边栏中,单击“数据建模”。

2

Open your entity-relationship diagram打开实体关系图

From the Data Modeling tab, open your diagram.从“数据建模”选项卡中,打开图表。

3

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.单击图表中的一个字段。现场侧面板在屏幕右侧打开。

4

Delete the field删除该字段

In the side panel, click the icon.在侧面板中,单击图标。

Next Steps后续步骤

Learn More了解更多