IBM Support

How to create a single or multiple cardinality relationship between a parent business object and a child business object.

Troubleshooting


Problem

How do you create a single or multiple cardinality relationship between a parent business object and a child business object, when using IBM WebSphere Adapter For JDBC?

Symptom

I have no idea as to how to build a relationship between a parent business object and a child business object.

Cause

Poor information on how to correctly build a relationship between a parent business object and a child business object.

Resolving The Problem


The database has three tables as shown in the figure below:
The CUSTOMER table contains multiple records corresponding to the ADDRESS table, and the CUSTINFO table contains multiple records corresponding to the CUSTOMER table.


For more information on creating these tables using the SQL script, see the scripts.sql file.
scripts.sql scripts.sql

Use these three tables to build a single or multiple cardinality relationship between a parent business object and a child business object.

1. Create a multiple cardinality relationship between the parent business object (CUSTOMER) and the child business object (ADDRESS), by doing the following:

a). Run the external service discovery to generate the multiple cardinality relationship, by doing the following:

<i>. In the New External Service window, select the Prompt for additional configuration settings when adding business object check box.


<ii>. Add the CUSTOMER table to the Selected objects area, as the parent business object, as shown in the figure below.


<iii>. When you add ADDRESS to the selected objects list, the configuration properties panel pops up. From the configuration properties panel, select CUSTOMER as the parent table of ADDRESS, and select the PKEY column from the CUSTOMER table as the corresponding column of CUSTID column from ADDRESS table. Clear the Single cardinality check box.


b). Generated artifacts - The diagram below shows the multiple cardinality relationship between YuanjsCustomer and YuanjsAddress business objects.


In the "ccode" attribute of "YuanjsCustomer" business object, the xsd definition is as follows:
<jdbcasi:ColumnName>PKEY</jdbcasi:ColumnName>
<jdbcasi:PrimaryKey>true</jdbcasi:PrimaryKey>

In the "ccode" attribute of "YuanjsAddress" business object, the xsd definition is as follows:
<jdbcasi:ColumnName>CUSTID</jdbcasi:ColumnName>
<jdbcasi:PrimaryKey>false</jdbcasi:PrimaryKey>
<jdbcasi:ForeignKey>pkey</jdbcasi:ForeignKey>

NOTE:
If it is a single cardinality relationship, the <jdbcasi:ForeignKey> annotation message will be stored in the parent business object.

2. Create a single cardinality relationship between the parent business object (CUSTOMER) and the child business object (CUSTINFO).

a). Run the external service discovery to generate a single cardinality relationship, by doing the following:

<i>. In the New External Service window, select the Prompt for additional configuration settings when adding business object check box.


<ii>. Add the CUSTOMER table to the Selected objects area, as the parent business object, as shown in the figure below.


<iii>. When you add CUSTINFO to the selected objects list, the configuration properties panel pops up. From the configuration properties panel, select CUSTOMER as the parent table of CUSTINFO, and select the CCODE column from the CUSTOMER table to correspond to the CCODE column of the CUSTINFOI table. Select the Single cardinality check box.


b). Generated artifacts - The diagram below shows the single cardinality relationship between YuanjsCustomer and YuanjsCustinfo business objects.


In the "ccode" attribute of "YuanjsCustomer" business object, the xsd definition is as follows:
<jdbcasi:ColumnName>CCODE</jdbcasi:ColumnName>
<jdbcasi:PrimaryKey>false</jdbcasi:PrimaryKey>
<jdbcasi:ForeignKey>custinfoobj/ccode</jdbcasi:ForeignKey>

In the "ccode" attribute of "YuanjsCustinfo" business object, the xsd definition is as follows:
<jdbcasi:ColumnName>CCODE</jdbcasi:ColumnName>
<jdbcasi:PrimaryKey>true</jdbcasi:PrimaryKey>

NOTE:
If it is a single cardinality relationship, the <jdbcasi:ForeignKey> annotation message will be stored in the parent business object.

When building a single or multiple cardinality relationship between the parent business object and a child business object, you must first add all the parent tables to the Selected Objects list, and then configure the Primary Key and Foreign Key relationship of the parent and child table columns.

If the cardinality relationship is "single", the foreign key annotation information is stored in the parent business object. If the cardinality relationship is "multiple", the foreign key annotation information is stored in the child business object.

NOTE: If the location of the foreign key annotation information is incorrect, then the relationship between parent and child business objects will not be built.

[{"Product":{"code":"SSMKUK","label":"WebSphere Adapters Family"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Adapter for JDBC","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"7.0.2;7.0.1;7.0.0.3;7.0.0.2;7.0.0.1;7.0;6.2.0.3;6.2.0.2;6.2.0.1;6.2;6.1;6.0.6;6.0.5;6.0.4;6.0.3;6.0.2.3;6.0.2.2;6.0.2.1;6.0.2","Edition":"WebSphere","Line of Business":{"code":"","label":""}}]

Document Information

Modified date:
15 June 2018

UID

swg21469177