Adding a foreign key: linking entities together - Cloud - 8.0

Talend Data Fabric Studio User Guide

Version
Cloud
8.0
Language
English (United States)
EnrichDitaval
Data Fabric
Product
Talend Data Fabric
Module
Talend Studio
Content
Design and Development

Talend Studio enables you to set relationship between different entities using Foreign Keys.

Before you begin

You have already created data models, business entities and attributes in the data model. For further information, see Creating a data model, Creating business entities in a data model and Adding attributes to the business entity.

About this task

Consider as an example that your data model hold the following entities: Agency, Agent and Region. You want to link the two entities Agency and Region together in order to represent that an Agency belongs to a Region. Consequently, Agency will have a new attribute that points to a Region.

To set a foreign key, do the following:

Procedure

  1. Add a new Region attribute to the Agency entity as outlined in Adding attributes to the business entity.
    Warning: When using MS SQL Server, if more than one entities link to the same entity, avoid using the same name for the foreign key attributes. Otherwise, you need to recreate tables when redeploying the data model after deleting any of those foreign key attributes.
  2. Right-click Region and select Set the Foreign Key from the list.
    Set the Foreign Key dialog box pops up.
  3. Click the three-dot button to open the Select Xpath dialog box.
  4. Browse to the Region primary key Id and then click Add in the bottom of the dialog box to proceed to the next step.
    The Xpath to the foreign key displays in the Set the Foreign Key dialog box.
  5. If you want to render the Foreign Key in the main tab, select the Render Foreign Key in the main tab? check box. By default, Talend MDM Web UI renders the Foreign Key in a separate tab.
  6. Click OK to close the dialog box.
    The foreign key is set to Region/Id under the Annotations node of the Region attribute in the data model editor.
    Entities which are linked by a foreign key are identified by a key icon with a green arrow . To jump directly to the related entity, right-click the entity in the data model editor and click Jump to Foreign Key Entity.