步骤
-
在 Data Model Entities (数据模型实体) 面板中,右键单击要设置为外键的元素,然后从上下文菜单中选择 Set the Foreign Key (设定外键)。
在本示例中,从 Movie (影片) 实体右键单击 Director (导演) 特性。
Set the Foreign Key (设定外键) 对话框即会弹出。
-
单击 [...] 按钮打开 Select Xpath (选择 Xpath) 对话框。
-
浏览到 Director (导演) 特性 Id,然后单击对话框底部的 Add (添加)。
外键的 Xpath 显示在 Set the Foreign Key (设定外键) 对话框中。
-
单击 OK (确定) 完成外键设置。
外键在 Movie (影片) 实体中 Director (导演) 特性的 Annotations (注释) 节点下设定为 Director/Id。
-
按照同样的步骤将 Customer (客户) 实体中的 Movie (影片) 特性设定为指向 Movie (影片) 实体的外键。
结果
在 Movie 数据模型中,添加外键以连接数据模型中的实体。您还可以单击 Design (设计) 选项卡查看图形设计器中数据模型中实体之间的关系。有关更多信息,请参阅《Talend Studio 用户指南》。