IBM Content Manager, Version 8.5.0.3             

Foreign key example: Linking between IBM Content Manager attributes

The goal of this example is to create a foreign key between attributes of two IBM® Content Manager item types and to demonstrate that the foreign key constraint is used as expected in the IBM Content Manager clients.

Important: This example provides steps that are essential to accomplish the goal of the example. However, this example does not provide the complete steps for all procedures. For example, steps to save the new attributes and item types are not explicitly documented because they are considered to be understood by knowledgeable IBM Content Manager users.

Creating attributes, item types, and a foreign key

A system administrator who is responsible for the data modeling for the business creates attributes, item types that use these attributes, and a foreign key that links between the attributes to provide referential integrity across items created with the item types. The process flow for these tasks includes the following steps:

Create the attributes: Create two attributes, a FormId attribute to hold the identifier (ID) for a type of form, and a FormName attribute to hold the text description of the form type.

  1. From the IBM Content Manager system administration client navigation tree, expand Data modeling, right-click Attributes, and click New.
  2. Create an attribute with a Name and Display name of FormId. Select Character as the Attribute type with Alphanumeric as the Character type. In the Length field, enter 8.
  3. Create an attribute with a Name and Display name of FormName. Select Variable Character as the Attribute type with Alphanumeric as the Character type. In the Length field, enter 32.

Create the first item type: Create a FormType item type to contain the form types that will be added as items. Add the FormId attribute to the item type to store the IDs of form types. Add the FormName attribute to the item type to store the descriptions of form types. Prepare the FormId attribute to be used as part of the foreign key. Set the FormId to be a required attribute for the FormType item so that each form type has an ID. Set the FormId to be a unique attribute for the FormType so that each ID is unique.

  1. From the system administration client, right-click Item types and click New.
  2. On the Definition page, enter FormType for the Name and Display name fields. In the Item type classification field, select Document.
  3. On the Attributes page, add the FormId attribute to the item type. Select Required and Unique so thata unique ID is required for each form type. Select Represents item so that the FormId attribute is displayed in the client to represent the FormType item.
    Tip: An attribute must be set as required on the item type to be used as a foreign key.
  4. Also on the Attributes page, add the FormName attribute to the item type. Select Required and Unique so that each form type requires a unique description.
  5. On the Document Management page, add the ICMNOTELOG document part so that users can enter comments about the items in this item type. Because this item type is used as a folder to define types of forms and is not used to store documents, this part is the only part needed for the item type.
Create the second item type: Create a Forms item type to contain the individual forms that will be added as items. Add the FormId attribute to the item type so that it is common to both item types so that it can be used as the foreign key constraint between the FormType item type and the Forms item type.
Tip: It is not required to use the same attribute as the source and target attribute of the foreign key. The same attribute is used in this example for illustrative purposes.
  1. From the system administration client, right-click Item types and click New.
  2. On the Definition page, enter Forms for the Name and Display name fields. In the Item type classification field, select Document.
  3. On the Attributes page, add the FormId attribute to the item type. Select Required to indicate that this is a required attribute for all Forms items.
  4. Also on the Attributes page, add other attributes that are commonly needed for a document item type, for example, a timestamp or owner name.
  5. On the Document Management page, add document parts that are commonly needed for a document item type, for example, ICMANNOTATION, ICMBASE, and ICMBASETEXT.

Create the foreign key on the second item type: As part of the creation of the Forms item type, create a foreign key constraint with the Forms item type as the source item type and the FormType item type as the target item type. Set the FormId attribute as the source attribute and target attribute. In the foreign key relationship, the source is constrained by the target. Therefore, the values available to the FormId attribute in the Forms item type are limited by the values available in the FormId attribute in the FormType item type.

  1. On the Foreign Keys page of the Forms item type definition, click Add.
  2. In the Constraint name field of the Define Foreign Key window, enter FormIdConstraint.
  3. Select Restrict for the Update rule and select Restrict for the Delete rule.
  4. Choose the source and target item types for the foreign key. For Select source component, select the Forms item type. For Select target Item Type or table, select Use Content Manager Item Type to use an IBM Content Manager item type as the constraint. For Select target Item Type, select the FormType item type.
  5. Select the attributes on the source and target that reference each other. For Source attributes, select FormId. For Target attributes, select FormId. Select Show target as dropdown in client to enable the target attribute from the FormType item type to show as a drop-down field in the clients.

Creating items in the FormType item type

A business analyst who is responsible for creating the objects for the business creates the form types in the FormType item type. This action includes assigning IDs to the form types by using the FormId attribute. The business analyst creates two new form items with the FormFolder item type, a medical insurance application with the form ID 1A100001 and a medical claim form with the form ID 1A100002. The process flow for these tasks includes the following steps:

  1. In your web client, create a folder.
  2. For the item type, specify FormType. For the form ID, specify 1A100001. For the form name, specify Medical Insurance Application.
  3. For the item type, specify FormType. For the form ID, specify 1A100002. For the form name, specify Medical Claim Form.

Importing an item to IBM Content Manager

Users who are responsible for importing the forms into the content management system work with forms according to the normal business process, such as importing scanned documents. When a user imports a form, the user assigns an ID that defines the type of form that is imported. The client that is used to import the document limits the values for the ID by using the foreign key constraint. The client might limit the values directly in the interface by using the acceptable values in a drop-down menu, or the client might limit the values indirectly by verifying the supplied value on the library server.

For example, a user imports a form with their web client. The web client can display the IBM Content Manager foreign key item types and attributes in the interface. Therefore, the user can select Forms from the Item type field and select an ID from a FormId drop-down list. The FormId list contains only the IDs entered by the business analyst as the FormId values for the FormType item type.

Other client applications might not display the foreign key values for selection. For example, the Client for Windows does not display the values from foreign keys by default. In addition, a custom client application might not be designed to show these values. However, regardless of the client that is used, the foreign key referential integrity is enforced by the library server.

For example, a user imports a form with the Client for Windows, using the Forms item type. Because a FormId drop-down list does not display in the Client for Windows, the user enters an ID value manually. The ID contains a typographical error, such as 1AA00001 when the valid IDs are 1A100001 and 1A100002. The resulting entry is not defined as a FormId in the FormType item type. When the user imports the form, the following error message is shown: The system could not create a document object. The error details contain IBM Content Manager and SQL error codes to help the user work with the system administrator. The error codes show that the value for the dependent table (the FormId attribute of the Forms item type) does not match any value of the parent key in the parent table (the FormId attribute of the FormType item type).

Result

In this example, attributes and item types were created in IBM Content Manager. A foreign key relationship was created between two item types. An attribute that was used in both item types was configured as a foreign key to constrain the values of the attribute from one item type to another. The values were displayed in the web client interface to limit the values that users could select when creating items. In addition, other client applications that could not display the values still used the foreign key to enforce referential integrity between the two item types.



Last updated: June 2015
mdd30050.htm

© Copyright IBM Corporation 2015.