Example one-to-one

The following sections use the following business example.

Suppose the insurer had a regulatory requirement to have a set of activities periodically reviewed by the insurer's legal team. There are several fields needed to track this legal review, but they are applicable to only about 5% of all activities.

To improve database performance, the insurer opts to store this information in an ActivityLegalInfo_Ext entity and define it as a one-to-one with Activity.

  • The Activity entity is the parent. Each activity can be associated with up to one ActivityLegalInfo_Ext.
  • ActivityLegalInfo_Ext is the child. Each instance must be associated with exactly one Activity.

To implement this, the following has been added to the data model:

  • Activity entity
    • ActivityLegalInfo_Ext
      • one-to-one
      • fkentity: ActivityLegalInfo_Ext
      • nullok: true
  • ActivityLegalInfo_Ext entity
    • LegalCaseNumber
      • varchar with size 30
    • LegalReviewDate
      • datetime
    • Activity
      • foreign key
      • fkentity: Activity
      • nullok: false

Note the following:

  • On Activity, the ActivityLegalInfo_Ext field has nullok set to true. This is because some Activity instances will have an associated ActivityLegalInfo_Ext, but most will not.
  • On ActivityLegalInfo_Ext, the Activity field has nullok set to false. This is because every ActivityLegalInfo_Ext must be associated to an Activity.

For a complete list of all code used to build this example, see Complete code sample for one-to-ones.