views:

466

answers:

1

My exact model is complicated to explain, so say that I'm modeling fruits and their seeds in Xcode's Core Data modeler. Here's some "psuedo-coreData-code":

abstractEntity Fruit
attribute sweetness
relationship Seed

abstractEntity Seed
attribute shape

concreteEntity Apple inherits Fruit
concreteEntity Orange inherits Fruit

concreteEntity AppleSeed inherits Seed
concreteEntity OrangeSeed inherits Seed

The reason I modeled in this way is that I want to be able to fetch a mix of fruits and sort them by their seed shapes. Given this model, here's my question:

Is there any direct way in the Xcode modeler (i.e., from the GUI) that will enable me to specify that Apples can only have AppleSeeds and Oranges can only have OrangeSeeds? In the model above, concrete fruits inherit an abstract Seed relationship, which I need in order to fetch and sort mixed fruits/seeds, but I don't see any way to enforce the exact Seed relationship that each concrete fruit must have.

I see lots of different ways to enforce this outside of the modeling GUI, but just want to make sure I'm not missing something. Any suggestions?

Hopefully this example makes sense!

A: 

The only way I can think of is to remove the seed relationship from the superentity and put specific AppleSeed and OrangeSeed relationships in the subentities. You may be able to override the relationship in the subentities without removing it from the superentity but as far as I know there's no way in the model editor to do what you're describing.

Benno