1
votes

I am confused about how to design a Core Data Model for a particular trio of entities -- specifically, the relationships between them.

"Place" is an entity comprised of a name (String) and an address (String).

"Leg" is an entity comprised of a start (Place) and an end (Place).

"Route" is an entity comprised of an arbitrary number of legs (Leg) in a particular order.

In sum, a Route consists of an ordered list of Legs which themselves simply represent straight lines between two Places.

How would I model the relationship between the Leg and Place entities in the data model? Each Leg has exactly two Places (start and end); and any Place could be associated with an unlimited number of Legs, either as a start or an end.

1

1 Answers

1
votes
  1. In the Leg entity Add two relationships , one for startPlace and another for endPlace , make their type "To One"

  2. In the Place entity add two inverse relationships (legsByStartPlaceInverse and legsByEndPlaceInverse) and make their type "To Many".

  3. Make sure delete rules are not "Cascade".