Now that both object types and relation types are ready, it is time to combine them to define relations between object types and determine how objects interact with one another.
Here is the blank template for defining relations between objects:
{
"fromObjectTypeKey": "",
"toObjectTypeKey": "",
"relationTypeKey": ""
},
Since relation types already include a reverse key, you only need to specify one relation per relation type pair. The opposite relation will be created automatically in the database.
| Property | Purpose |
|---|---|
fromObjectTypeKey | Specifies the object type from which the relation starts. |
toObjectTypeKey | Specifies the receiving object type. |
relationTypeKey | Key of the relation type between these two object types. |
Example: Recipe Manager Relations
In our example package, we had already planned both object types and their relations. As a result, the relations asset could have been defined before the creation of object types and relation types themselves.
In our example, the object types and their relations were mapped as follows:
Types of Relations
In Dawiso, relations help define how objects interact. There are three main types of object relations:
- Core-Defined Relations:
- Relations that are predefined in Dawiso’s core packages and often come with default features that cannot be customized elsewhere.
- Example:
core#isParentOfdetermines parent-child relation but also influences hierarchical relationships and determines navigation structure.
- Standard Relations:
- Relations that are used in standard Dawiso packages and follow the same configuration as custom relations.
- The difference is that these relations may have a specific visual representation or categorization.
- Custom Relations:
- Relations that are defined in the
relationTypesasset to meet the specific needs of your application.
- Relations that are defined in the
In the screenshot below, you can see how object relations are visualised in a diagram:
Core-Defined Relations
Parent-child relations, such as hierarchical structures, use the predefined "relationTypeKey": "core#isParentOf". This allows nesting of object types.
For example, here is how we define a parent-child relation between Cuisine and Recipe object types:
{
"fromObjectTypeKey": "cuisine",
"toObjectTypeKey": "recipe",
"relationTypeKey": "core#isParentOf"
},
The same relation type can be used for other hierarchical relations, such as between Ingredient Category and Ingredient object types.
Nesting is simply another relation where an object type is its own parent (e.g., ingredient_category can contain another ingredient_category):
{ "fromObjectTypeKey": "ingredient_category", "toObjectTypeKey": "ingredient_category", "relationTypeKey": "core#isParentOf" },
Relations Between Objects of Different Applications
For example, if you plan to use code lists for labels, you must define relations between the Code Lists application’s object types and your object types. This step is essential for integrating data across applications.
When referencing objects or relations from code lists (or other packages), use the following format package_key#property_key, e.g.:
- Objects:
package_key#object_type - Relations:
package_key#relation_type
{
"fromObjectTypeKey": "ingredient", // Our object type
"toObjectTypeKey": "core_code_lists#label", // Object type called "Label" from the (core) Code Lists application
"relationTypeKey": "core_code_lists#has_label" // The "has label" relation type from the (core) Code Lists application
},
Custom Relations
If you define custom relations, you must also add them to the relationTypes asset.
In our example, the contains and used_in relations are custom and need to be defined as follows:
{
"fromObjectTypeKey": "recipe",
"toObjectTypeKey": "ingredient",
"relationTypeKey": "contains"
},
Custom relations must be defined in the relationTypes asset. Here is an example, but for more information, refer to the 3. Define Smallest Units: Relations and User Relations article.
"relationTypes": [
...
{
"key": "recommends",
"name": "Recommends",
"reverseKey": "recommends"
}
],
...
"objectTypeRelations": [
...
{
"fromObjectTypeKey": "recipe",
"toObjectTypeKey": "recipe",
"relationTypeKey": "recommends"
}
],