Change multiplicity consequence

1
I have two entities (entity A and entity B). The association between them has a multiplicity of 1-to-many and the entities are already in use on the production server. However, I concluded that the multiplicity should be 1-to-1 because there is only one entity B related to entity A.  I'm curious, when I change the association in the Modeler from 1-to-many to 1-to-1, does the current association remains? And what will happen when there are multiple entity B related to entity A, will he pick the first association? Thanks in advance!
asked
4 answers
2

See: https://docs.mendix.com/refguide/attributes-type-migration#3-association-type-changes-on-existing-associations

existing references aren’t cleaned up in the database, since on synchronization Mendix cannot decide which to keep and which to delete.

My advise would be, clean up the data before changing the association type. Or even better add a new 1-1 association, copy the assciation you want to maintain and then delete the 1-* association

answered
0

Having them not cleaned up can also cause unique constraint violations. If you use DB based unique constraint validation (Default on Mendix 7 and higher), you app will not start up if there is such a violation.

answered
0

This is what the modeler does when adding an association between “Entity” and “Entity_2”. It’s adding a constraint.

answered
0

I reproduced it by first having one-many. I added three objects of entity that all had an association to a single object of entity_2.

When now changing the association to one-one, the app is not starting up because of a unique constraint violation.

uniqueness constraint are related to associations.

answered