I have 2 entities: Train and Station
Each train stops at multiple stations, i.e. Train <--->> Station.
The list of stations a train stops at is different from the list of stations some other train stops at.
How do I correctly save and fetch the list of stations for a particular train?
Thanks
Does this:
mean you have a one to many relationship? If so, it doesn’t work, unless only one train can stop at each station. What I would do is create a third entity, call it say “stop” with two relations, a many to one to
Trainand a many to one toStation. It wil look something likeTo find all the stations a particular train stops at, just look at the
stopsproperty of theTrainwhich will be anNSSetofStopobjects each of which has a property which is a station the train stops at.To add new stops, just create a new
Stopobject and set itstrainandstationproperties appropriately.