Skip to content

Create Relationships for entities

A relationship is an indexed link between two entities. There is a consideration when creating entities no matter the method. The left entity and related fields (l_entity, l_key) should always be the ones from the parent entity.

API documentation

To create a relationship for an entity using the API, you would use the endpoint to update the entity structure:

PUT /api/v1/entities/{entity}?version=

{
"object_label": "test",
"object_name": "test",
"datasource": "main",
"audited": true,
"show_on_menu": true,
"use_adapter": false,
"importable": true,
"read_only": false,
"layout": "default",
"layout_properties": [
{}
],
"relationships": [],
"fields": [],
"recursive_queries": []
}

Here is an example of what a relationship being added could look like:

"relationships": [
{
"label": "Relationship between departments and dept_emp",
"relation_name": "RS_dept_emp_departments",
"name": "RS_dept_emp_departments",
"relationship_type": "many-to-one",
"type": "many-to-one",
"layout_properties": [],
"layout": "",
"l_entity": "dept_emp",
"l_key": "emp_no",
"r_entity": "departments",
"r_key": "dept_no",
"join_entity": null,
"join_l_key": null,
"join_r_key": null,
"key": null,
"fields": []
}
],