Add Relationship To Existing Business Object

You can add a business object relationship to the system by sending the following request. Add relationship will be equivalent to add a business object relationship definition in metadata and update the child attributes reference metadata columns and add a physical constraint on the child business object. Either you want to add a simple relationship or a composite relationship the request will be same. In case of composite relationship the relationship name will be same for more than once instances of the relationship business object.

Following are the conditions which should be met by the request to drop the relationship.

  1. Main request will be for `BUS OBJ RELATIONSHIP' business object.

  2. You must have data to define BUS OBJ RELATIONSHIP.

  3. For simple relationships, relationship name is optional but for composite relationships relationship name is mandatory.

  4. For simple relationships you can provide a relationship name otherwise system will generate the relationship name with the pattern of FK__.

  5. If you want to define a composite relationship and you do not provide the relationship name then the relationship name will be generated automatically by system and this will be considered as a simple relationship.

  6. In relationship definition you must provide child bo name on which you want to add the relationship. It will be the name of an existing business object.

  7. In relationship definition you must provide the child bo attr name which you want it to be involved in the relationship as a foreign key.

  8. In relationship definition the parent bo name will be the name of an existing business object with which you want to relate the child busines object as a child.

  9. Parent business object can also be same as the child business object but in this case both child and parent attributes involved in the relationship must be different.

  10. In relationship definition the parent bo attr name will be the name of the attribute in the parent business object with which you want to relate the child business object attribute.

  11. The data type of the parent bo attr name and the child bo attr name should be same.

  12. If the database is MS SQL Server then the database collation of the parent bo attr name and the child bo attr name should be same.

  13. Parent business object attribute should be defined as primary key or at least unique attribute in its business object definition.

  14. If it is a composite relationship then all the parent business object attributes involved in this relationship definition should be combined unique in the parent business object. In other words there must exist a unique constraint on the parent business object which exactly involves these parent business object attributes in combination.

  15. IS_PRIMARY_KEY_RELATIONSHIP value true or false will automatically be set by the system by looking whether that the provided parent business object attribute is defined as a primary key attribute in parent business object or not.

  16. Parent Business Object must meet the following criteria.

    1. Parent business object should already be defined in the system and metadata should be refreshed.

    2. Parent business object can be same as the child for the recursive relationship (self-join) case. In this case parent business object attribute name and child business object attribute names must be different.

  17. Once a relationship is added on a child attribute then it also updates the child attribute metadata and it adds reference data in the attribute metadata reference columns. Following attributes will be updated for the child attribute metadata in the business object business_object_attr metadata table. This reference metadata is used on the front-end UI to generate the proper combo boxes.

    1. reference_bo_name: It will have the value of parent business object name.

    2. reference_bo_attr_value: It will have the primary key column name of the parent business object.

    3. reference_bo_attr_label: It will have the current parent business object attribute name only in case it is not a primary key relationship. If it is a primary key relationship then it will have the unique column name from the defined unique constraints for the parent business object. If the parent business object does not have a simple unique constraint them it will have a comma separated business object attribute names from the parent business object best found unique constraint.

    4. is_reference_ind: It will be set to true as it is reference column

    5. Control_type: If it is a non-primary key relationship then the control type will be updated to auto complete combo box otherwise it will not be updated and it will remain same as before.

1. Request URL

/{PDM Server domain}[/metadata/write/addRelationships

Method: POST

2. Request headers

Name Value

Content-Type

application/json

3. Response Type

Name Value

responseType

blob

4. Request body

Example 1. Simple relationship with relationship name provided
Add Simple Business Object Relationship Request

{
   "BUS OBJ RELATIONSHIP": {
     "language": "en",
     "timezone": "GMT+08:00",

    "data": [
       {
         "BUS_OBJ_RELATIONSHIP_NAME": "FK_{{boName}}_WELL_TEST_ID", //optional
         "CHILD_BO_NAME": "{{boName}}", // mandatory
         "CHILD_BO_ATTR_NAME": "WELL_TEST_ID", // mandatory
         "PARENT_BO_NAME": "WELL TEST", // mandatory
         "PARENT_BO_ATTR_NAME": "WELL_TEST_ID" // mandatory
       }
     ]
   }
}
Try it myself
Example 2. Simple relationship without relationship name
{
   "BUS OBJ RELATIONSHIP": {
     "language": "en",
     "timezone": "GMT+08:00",

    "data": [
       {
         "CHILD_BO_NAME": "{{boName}}",
         "CHILD_BO_ATTR_NAME": "WELL_TEST_ID",
         "PARENT_BO_NAME": "WELL TEST",
         "PARENT_BO_ATTR_NAME": "WELL_TEST_ID"
       }
     ]
   }
}
Try it myself
Add Composite Business Object Relationship Request
Relationship name must be provided and it should be same for all instances having same relationship

{

  "BUS OBJ RELATIONSHIP": {

    "language": "en",

    "readBack": true,

    "timezone": "GMT+08:00",

    "showSQLStats": true,

    "data": [

      {

        "BUS_OBJ_RELATIONSHIP_NAME": "FK_{{boName}}_UWI_START_TIME",

        "CHILD_BO_NAME": "{{boName}}",

        "CHILD_BO_ATTR_NAME": "UWI",

        "PARENT_BO_NAME": "WELL TEST",

        "PARENT_BO_ATTR_NAME": "UWI"

      },

      {

        "BUS_OBJ_RELATIONSHIP_NAME": "FK_{{boName}}_UWI_START_TIME",

        "CHILD_BO_NAME": "{{boName}}",

        "CHILD_BO_ATTR_NAME": "START_TIME",

        "PARENT_BO_NAME": "WELL TEST",

        "PARENT_BO_ATTR_NAME": "START_TIMe"

      }

    ]

  }

}
Try it myself
Add Simple and Composite both Business Object Relationships in a single Request.

{

  "BUS OBJ RELATIONSHIP": {

    "language": "en",

    "readBack": true,

    "timezone": "GMT+08:00",

    "showSQLStats": true,

    "data": [

      {

        "BUS_OBJ_RELATIONSHIP_NAME": "FK_{{boName}}_UWI_START_TIME",

        "CHILD_BO_NAME": "{{boName}}",

        "CHILD_BO_ATTR_NAME": "UWI",

        "PARENT_BO_NAME": "WELL TEST",

        "PARENT_BO_ATTR_NAME": "UWI"

      },

      {

        "BUS_OBJ_RELATIONSHIP_NAME": "FK_{{boName}}_UWI_START_TIME",

        "CHILD_BO_NAME": "{{boName}}",

        "CHILD_BO_ATTR_NAME": "START_TIME",

        "PARENT_BO_NAME": "WELL TEST",

        "PARENT_BO_ATTR_NAME": "START_TIMe"

      },

      {

        "CHILD_BO_NAME": "{{boName}}",

        "CHILD_BO_ATTR_NAME": "WELL_TEST_ID",

        "PARENT_BO_NAME": "WELL TEST",

        "PARENT_BO_ATTR_NAME": "WELL_TEST_ID"

      }

    ]

  }

}
Try it myself
Add A Simple Recursive Business Object Relationships in a single Request.

{
   "BUS OBJ RELATIONSHIP": {
     "language": "en",
     "readBack": true,
     "timezone": "GMT+08:00",
     "showSQLStats": true,
     "data": [
       {
         "BUS_OBJ_RELATIONSHIP_NAME": "FK_{{boName}}_WELL_TEST_ID_WELL_TEST_CHILD_ID",
         "CHILD_BO_NAME": "{{boName}}",
         "CHILD_BO_ATTR_NAME": "WELL_TEST_ID",
         "PARENT_BO_NAME": "{{boName}}",
         "PARENT_BO_ATTR_NAME": "{{boName}}_ID"
       }
     ]
   }
}
Try it myself

5. Responses

When response.status = 200, It will response a `application/octet-stream' excel file.

Otherwise, it will response json file, Please see Responses