How should I set up the Associations?

0
I want a Drink to have multiple IngredientsSelect. How should I set up the Associations?     Is it correct to set it up like the picture?
asked
3 answers
1

Hello Jeff Yu,

 

It depends what the scenario is, but I think that some drinks will make use of the same ingrediënts for example, water, sugar, salt and others.

 

So it needs to be at least many-to-many, but because many to many relationships are not that stimulated in mendix because of the extra tables, way of retrieving, performance etc. 

 

https://docs.mendix.com/refguide/community-best-practices-for-app-performance/

 

You can maybe achieve it by creating an inbetween couple entity, like they do in this learning path with registrations:

 

https://academy.mendix.com/link/modules/93/lectures/2794/-5.3-Information-Entities

 

image.png

 

For you this means that you create an RecipeIngredientLine benefit of this is that you can add the measurements on that entity as well, so for example sugar 50 mg salt 5 mg etc.

 

Hope this helps,

 

Good luck!

answered
1

Hi Jeff,

If you have a requirement of 1 Drink have Multiple IngredientsSelect means then the above association which you have mentioned was correct.

answered
0

Hi Jeff!

That's the correct way for sure. In that case a drink can have multiple ingredients. The IngredientesSelect is the owner of the association, so the association is gonna be set through that object. You can check how the ownership works here: here: https://docs.mendix.com/refguide/associations/#ownership

 

Kind regards.

answered