Vztahový model¶
A relationship represents a link between two entities in the Tracker-model. A relationship is considered data in DHIS2 and is based on a Relationship Type, similar to how a Tracked Entity is based on a Tracked Entity Type.
Relationships always connect two entities, and these entities can include Tracked Entities, Enrollments and Events, and any combination of these. Note that all of these combinations are not currently available through the User Interface.
Relationships between entities can be classified as either unidirectional or bidirectional, with each type requiring different levels of access for creation.
- Unidirectional relationships require the user to have:
- Write access to the "from" entity
- Read access to the "to" entity
- Bidirectional relationships require write access to both the "from" and "to" entities.
When retrieving relationships from a tracker exporter endpoint, only those originating from the requested entity are shown. This means that the entity is either part of a bidirectional relationship or the "from" entity in a unidirectional relationship.
Typ vztahu¶
Typ relace je definice vlastností, které vztah má. Vztahy se vždy skládají ze dvou stran, označovaných jako „od“ a „do“, a to, jaké entity mohou být obsaženy pro každou stranu, určuje typ vztahu. Vlastnosti, které určují, co každý může obsahovat, se nazývají omezení, odConstraint respektive toConstraint. Tato omezení jsou významná při pozdější práci s daty, aby bylo možné pochopit, co vztah může a co nemůže obsahovat.
Každá z omezení definovaných v typu Vztahu se skládá z několika vlastností. Primární vlastnost je vztah entity, který rozhoduje o tom, jaký druh entit může vztah obsahovat. Entity mohou být pro každé omezení jednou z následujících:
- Tracked Entity
- Zápis
- událost
V závislosti na druhu vztahu entity, kterou vyberete, můžete zvolit další omezení pro každé omezení. Následující tabulka vysvětluje různé kombinace, které můžete konfigurovat:
| Instance trasované entity | Zápis | událost | |
|---|---|---|---|
| Typ trasované entity | Požadované | Volitelný | - |
| Program | - | Požadované | - |
| Fáze programu | - | Požadované | Volitelný |
These additional limitations, will require the entity to match the limitation set before it can be created. For example, if your relationship is between a mother and a child, both constraints would have their required Tracked Entity Type set to Person and could optionally set the Enrollment to Maternal Health Program and Child Program respectively. This way, only Tracked Entities who are of type Person and who is enrolled in the required program is allowed to be included in these relationships.
In addition to the constraints defined by a Relationship Type, each relationship can be configured as bidirectional, true or false.
- If the property is set to false, the relationship is unidirectional.
- If set to true, the relationship is bidirectional. As mentioned earlier in here, this setting impacts the required access levels for creating the relationship, and the relationships displayed when exporting an entity that is part of the relationship.
Jedna důležitá věc, kterou je třeba si všimnout u obousměrných vztahů, je, že strany „od“ a „do“ jsou v databázi stále významné, což znamená, že každá entita musí odpovídat omezení pro tuto stranu. Z pohledu uživatele je však každá strana každé entity uložena jako nevýznamná.
Example¶

- Bidirectional relationship relA connects teA to teB and connects teB to teA.
- Unidirectional relationship relB connects teA to teC but DOES NOT connect teC to teA.
- teA originates relationships relA and relB.
- teB originates relationships relA.
- teC originates no relationships.
- relA originates from teA and from teB, and points to teA and to teB.
- relB originates from teA and points to teC.