Business Intelligence Tutorial

Defining a foreign key

You need to define foreign keys for the relationships between the FACT_TABLE and the other target tables.

In this exercise, you will define a foreign key in the FACT_TABLE (dependent table) based on the primary key of the LOOKUP_MARKET table (parent table).

To define the foreign keys:

  1. Find the FACT_TABLE table in the list of tables for the TUTWHS database. Right-click the table and click Alter.

    The Alter Table notebook opens.

  2. Click the Foreign Keys tab. The Foreign Key page opens.
  3. Click Add. The Add Foreign Key window opens.
  4. In the Table schema field, select IWH.
  5. In the Table name field, specify LOOKUP_MARKET, which is the parent table. The Primary key field displays the primary key for LOOKUP_MARKET. The steps that generate the parent table must be in test or production mode in order for the primary key to be available. A primary key must be defined for the parent table before a foreign key can be defined for the FACT_TABLE.
  6. In the Available columns list, select CITY_ID as the column that you want defined as the foreign key.
  7. Click > to move CITY_ID to the Foreign key list.
    The GEOGRAPHIES SELECT statement on the SQL Statement page.
  8. Click OK to save your definitions.

    Define foreign keys for the FACT_TABLE to the other target tables by repeating steps 3 to 8. Define:


    The GEOGRAPHIES SELECT statement on the SQL Statement page.
  9. Click OK to save the information in the Alter Table window.


[ Top of Page | Previous Page | Next Page | Table of Contents ]