on 2019 Apr 18 4:17 PM
We have a one to many relation from A2B in our items.xml, question is why is there unique = true used on the source element where cardinality is already one. What is the use of this unique = true and why it should or should not be used? we need to know the significance of it.
Hi - having a unique
modifier for the qualifier with cardinality="one"
creates a unique constraint which does not allow creating a duplicate combination of the records e.g. as per the relation definition given below, you can not insert two records with United Kingdom as Country
and London as Region
combination.
<relation code="Country2RegionRelation" generate="true" localized="false" autocreate="true">
<sourceElement type="Country" qualifier="country" cardinality="one">
<modifiers read="true" write="true" search="true" optional="false" unique="true"/>
</sourceElement>
<targetElement type="Region" qualifier="regions" cardinality="many">
<modifiers read="true" write="true" search="true" partof="true"/>
</targetElement>
</relation>
You can validate this using the following ImpEx which will succeed:
INSERT_UPDATE Country;isocode[unique=true]
;US
INSERT Region;country(isocode);isocode[unique=true]
;US;US-AL
;US;US-AK
Now, if you try to import the following ImpEx, it will fail:
INSERT Region;country(isocode);isocode[unique=true]
;US;US-AL
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
32 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.