Relationships - How to implement limits on the number of relationships

Dear Community,

We are currently setting up a test program, and I just started using relationships feature.

Is there a way to implement limits about the number of relations ships from one side with the other as we have 1-n relations in a database for instance.

A basic use cse would be for instance:
A mother can have n children
But each child can only have one or zero mother

Thanks in advance and sorry if this is obvious question.

Regards

1 Like

Hi @gregory

Thank you for your post and for sharing the use case with the community. I tried to do a research and tried to see if it’s possible by testing on play, but it seems that currently there’s not been a feature to restrict the number of relationships in a TEIs.

It appears that this is an idea that could be discussed more with the team. You have already started the discussion here which is very helpful, and I would like to recommend adding this as an idea - here’s the guide on how to create ideas: Vote for DHIS2 features & submit your ideas in our new software roadmap process!

After creating the idea, would you like to share the link here so other community members could vote for that idea if they need it in their implementations? Thanks for sharing your insights!

Hi @gregory

A child can certainly have two mothers, if both of their parents are women. There are other cases with assisted reproductive technologies and surrogacy as well, where a child can have two mothers.

Anyway, I think the point you are trying to make is related to the number of relationships a given tracked entity can have to another. This seems like a reasonable feature to implement, but as @Gassim points out, its not currently implemented.

Best regards,
Jason

1 Like

Dear @jason and @Gassim

Thanks for your comments.

@jason : Oups you are fully right my example was certainly not the best. Really sorry for this to anyone in the community who might have been embarassed by this example, which I picked to quick.

Our real use case is for the management of water points and water distribution points where one water point can provide water to several distribution points, but one distribution point can only be linked to one water point.

This use case is certainly more correct about the strict 1-n relationship.

I will try to find some time by next week to formalize this idea.

Regards

1 Like

Thanks a lot @jason for your response! :folded_hands:

Thanks @gregory for your input. At least it’s good to know that TEIs relationships are not programmatically already restricted, but it’s good to know of the option to cover all use cases.

I think it’s great to get the use case directly from the field so I’m looking forward to your update. :slight_smile: