Reputation: 35
I have a question with relationships in my CoreData model.
I have two Entities for now. 1. Flight, 2 Airport I have attached the screenshots of the model to this post.
The question I have is how do I related the flight to the airport. In my SQL Databased schema I have foreign keys for each but in CoreData how can I set up this relationship correctly.
Essentially the Flight has an Origin and a Destination.
Any help would be appreciated.
AV
Upvotes: 1
Views: 60
Reputation: 21536
You can create two separate relationships between the two entities:
Life gets more complicated if your flights have multiple stops. In that case I would model each Flight as having several Legs, and each Leg an origin Airport and a destination Airport. But the details will depend on the SQL database you are emulating.
Upvotes: 1