Referenced objects
Principle
Certain objects (Addresses, Dangerous goods and Products) can be used multiple times in Lobster Data Platform / Orchestration.
For example, here an address is referenced by an address book entry, one company and 2 shipments.
The following requirements should be met when using referenced objects:
Changes of addresses should be avoided to affect the other referencing objects. (e.g. a change of the address shall not influence the address of the company, although both refer to the same address in the beginning).
If the 'Address 1' in 'Shipment 2' is changed, a new 'Address 2' will be created, which will be referenced from 'Shipment 2'. The other referencing objects still refer to 'Address 1'.Duplicates of the same address should be avoided, so that the number of addresses in the database is kept as small as possible.
If for 'Shipment 2', 'Address 2' is entered, which corresponds exactly to 'Address 1', the new 'Address 2' is not created when saving 'Shipment 2', but 'Address 1' is referenced instead.
In order to meet these requirements, the following solution was developed, which is explained using addresses as examples:
►NOTE◄ In Lobster Data Platform / Orchestration, referenced objects cannot be created, changed or deleted without a referencing object.
Each address gets a hash value, which is determined by the data. The same hash value is always created for the same data.
When saving a shipment, the hash values of the addresses contained in the object are determined.
If the hash value of the address in the shipment does not correspond to the hash value of the address referenced in the database, a new address is created if other referencing objects (address book, company, shipment) reference it.
Before the new address is created, it is checked whether there is already an address with this hash value, which can then be referenced.
If there are no other references, no new address is created, but the existing one is changed in the database. In this case, however, it is first checked whether an address with the same hash value already exists, because then it is referenced instead.