Information Management IBM InfoSphere Master Data Management, Version 11.3

Creating item relationships

You can create item relationships so that users are able to establish a relationship between two attributes from two catalogs. For example, you can establish a relationship between product id and item code from two catalogs. One of the attributes must be a relationship type attribute.

Before you begin

Ensure that your relationship attributes are editable in the view of your catalog.

Procedure

Create the item relationship by using the user interface. You need to create a two items with one attribute which is a primary key and the other attribute of type relationship. You can create a relationship between two items by selecting the primary key attribute of the first item with the relationship attribute of the second item.
Option Description
User interface
  1. In the left pane, click on the Default Organization folder under Catalog module.
  2. In the left pane, click on the first catalog.
  3. In the right pane, from the catalog drop-down list, select the second catalog. You will create a relationship from the attribute of the first catalog to the attribute of the second catalog.
  4. Click on the ? mark icon next to the relationship attribute. A window opens.
  5. Browse and select the item that you want to relate to.
  6. Click Save.
Scripting API The following sample code creates a relationship between two items.
// Sample code to set the Relationship between item 1 and item 2
var MY_CATALOG = "My Catalog";
var MY_PRIMARY_KEY1 = "item1";
var MY_PRIMARY_KEY2 = "item2";
var MY_REL_ATTR_PATH = "My Catalog Spec/rel8"; //the Relationship-typed node

var ctg = getCtgByName(MY_CATALOG);
//set item1 to have relationship with 
//item2
var item1 = ctg.getEntryByPrimaryKey(MY_PRIMARY_KEY1);
item1.setCtgItemRelationshipAttrib(MY_REL_ATTR_PATH,ctg,MY_PRIMARY_KEY2);
errs = item1.saveCtgItem();
out.println("errs: " + checkString(errs,""));

//verify item1 is set correctly to item2

var retId = item1.getEntryAttrib(MY_REL_ATTR_PATH);
var expId = ctg.getEntryByPrimaryKey(MY_PRIMARY_KEY2).getEntryId();
assertEquals.invoke(toInteger(retId),toInteger(expId));
Java™ API The following sample code creates a relationship between two items.
CatalogManager mgr = m_ctx.getCatalogManager();
Catalog ctg1 = mgr.getCatalog("Catalog1");
Catalog ctg2 = mgr.getCatalog("Catalog2");

Item item1 = ctg1.getItemByPrimaryKey("pk1");
Item item2 = ctg2.getItemByPrimaryKey("pk2");

AttributeInstance attrInst = item1.getAttributeInstance(PS1_RELATIONSHIP2);
attrInst.setValue(item2);

item1.save();
The relationship is created between two items.


Last updated: 8 Mar 2016