Handle missing Foreign Key in a Relationship

In Edit a Relationship, we've seen that we can configure the BK Behavior for a Relationship:

When a Relationship is defined between a source Model Object A and a target Model Object B, the Foreign Key value in Model Object B may not exist as a Business Key value in Model Object A.

We are talking about missing Foreign Keys in a Relationship.

You can configure four different behaviors to adopt during the load:

  1. None
  2. Set to Unknown
  3. Create an embryo
  4. Log an error and refuse

None

If we set the BK Behavior to None, the Foreign Key of the Model Object B will contain the singleton value for Unknown (which can differ according to the Data Type of the Foreign Key).

Set to Unknown

If we set the BK Behavior to setToUnknown, the Foreign Key of the Model Object B will contain the singleton value for Unknown (which can differ according to the Data Type of the Foreign Key).

Create an embryo

If we set the BK Behavior to createEmbryo, the missing value in Model Object A will be artificially created.

The following graph explains how the embryo behavior works (in a Dimensional modeling example):

blobid1

  • In the Sales Fact table is referenced the Product MTB 3
  • The MTB 3 Product doesn't exist in the product Entity
  • The embryo behavior creates the MTB 3 product in the Product Entity, and the relationship between the Sales Fact and the Product Entity can be done.

Log an error and refuse

If we set the BK Behavior to logErrorAndRefuse, if the value of the Foreign Key on Model Object B doesn't exist in Model Object A, the load will not load this row and log an error.

Demonstration video