Getting Started Guide > Creating Logical Relationships in TDM > Step 1. Create a Logical Relationship Between Tables
  

Step 1. Create a Logical Relationship Between Tables

Select a column from a table that you identify as the parent table to establish a foreign key relationship in another table. In this lesson, we select the CUST_ID column in the CUSTOMER table.
Perform the following steps to create a foreign key constraint in the CUSTS_WITH_INCOMPLETE_COUPONS table. The foreign key relates the CUST_ID column in this table with the CUST_ID column in the parent table CUSTOMER. Repeat the steps to create a foreign key constraint in the STATEMENT_LINE table.
    1. In the project, click Discover > Tables.
    2. Select the CUSTS_WITH_INCOMPLETE_COUPONS to create a foreign key.
    3. Click Constraints.
    4. Click Create New Constraint.
    5. Enter the name. TDM uses the table name and appends a constraint number to it by default. You can edit this if required. In this exercise, we retain the default name.
    The New Constraint creation workflow contains fields to enter the name and select the type, severity, and parent table.
    6. Select Foreign Key from the constraint type list.
    7. Select the Major severity level from the list.
    8. Click Select and browse to select the CUSTOMER table as the parent table to which the foreign key must relate.
    9. To enable the constraint, select the Enable Constraint check box and click Next.
    10. From the left pane, click the CUST_ID column. From the right panel, click the CUST_ID column in the CUSTOMER table. Click the Link icon to map the child-parent relationship.
    The following image shows mapping between the tables:
    The New Constraint creation workflow contains lists of columns in the child and parent tables and allows you to map required columns.
    11. Click Finish.
You created a foreign key constraint in the CUSTS_WITH_INCOMPLETE_COUPONS table that relates to the CUSTOMER table. You repeated the steps to create a foreign key constraint in the STATEMENT_LINE table that relates to the CUSTOMER table. You can now create an entity with the CUSTOMER table as the driving table.