I know that 'one to many' is done through an AttributeLinkedSet (class 1) and AttributeExternalKey (class 2); 'many to many' is done through an AttributeLinkedSetIndirect (class 1, class 2) and a link class.
But how is 1:1 best handled?
The way I think of, is to do it using PHP code; which could then also validate first whether on the target object there isn't already a value. But is there a native approach instead?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Maybe one day, iTop will propose it out of the box as part of the standard datamodel.
For now those who have implemented it, have used 2 external keys, with some PHP code to handle the synchronization.
You can imagine different scenarii and this is probably why it's not yet a standard.
1. You cannot set on object A1 the key of object B1, if the B1 object is already linked to an A2
2. You can set on object A1 the key of object B1, and in that case you reset automatically A2 extkey which was pointing to B1 to 0 (this scenario assume that the 1:1 relation is not mandatory on class A side).
You can decide to allow both extkey to be editable, but that might lead to infinite loop, it's easier to edit the relation by one end only and have the other one read-only, computed automatically.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I know that 'one to many' is done through an AttributeLinkedSet (class 1) and AttributeExternalKey (class 2); 'many to many' is done through an AttributeLinkedSetIndirect (class 1, class 2) and a link class.
But how is 1:1 best handled?
The way I think of, is to do it using PHP code; which could then also validate first whether on the target object there isn't already a value. But is there a native approach instead?
Maybe one day, iTop will propose it out of the box as part of the standard datamodel.
For now those who have implemented it, have used 2 external keys, with some PHP code to handle the synchronization.
You can imagine different scenarii and this is probably why it's not yet a standard.
1. You cannot set on object A1 the key of object B1, if the B1 object is already linked to an A2
2. You can set on object A1 the key of object B1, and in that case you reset automatically A2 extkey which was pointing to B1 to 0 (this scenario assume that the 1:1 relation is not mandatory on class A side).
You can decide to allow both extkey to be editable, but that might lead to infinite loop, it's easier to edit the relation by one end only and have the other one read-only, computed automatically.