Combining constraints

In Xcode you can setup constraints for a Core Data entity with the Data Model Inspector in the Constraints area. For every constraint added via + it set the example constraint "comma,separated,properties". You can configure more than one such constraint.


In the model file it looks like this:


<entity>

<uniquenessConstraints>

<uniquenessConstraint>

<constraint value="parent"/>

<constraint value="title"/>

<constraint value="birthday"/>

</uniquenessConstraint>

<uniquenessConstraint>

<constraint value="firstName"/>

<constraint value="lastName"/>

</uniquenessConstraint>

</uniquenessConstraints>

</entity>


Question: What it the logic? How to read this? Is it AND or OR inside a constraint? Is it AND or OR between multiple constraints?


While testing i came to this conclusion:

  • Every constraint says: All attributes in this constraint must have the same value for two ManagedObjects to match
  • Only one constraint is required to match in order for two ManagedObjects to match


This means:

  • The attributes (constraint values) must all match per constraint (AND)
  • At least one constraint must match (OR)


Or with an example: Two ManagedObjects would match, if they have (the same parent AND title AND birthday) OR (the same firstName AND lastName).


Is this correct?


In this developer video https://developer.apple.com/videos/play/wwdc2015/220/?time=821

they're importing recipe data from various sources and configure one constraint to avoid duplicates: "source,externlID". This looks like source and externlID must match both (AND) to identify a duplicate. This would support my interpretation for constraints above.

Also wanna know the answer for this

Combining constraints
 
 
Q