Core Data and Relationships

Posted by alku83 on Stack Overflow See other posts from Stack Overflow or by alku83
Published on 2010-06-17T23:11:17Z Indexed on 2010/06/18 1:23 UTC
Read the original article Hit count: 288

Filed under:
|

I have two objects, a Trip and a Place. A Trip represents a journey from one Place to another Place, ie. a Trip needs a fromPlace and a toPlace. So, this is a 1-to-2 relationship, but I need to know which is the "from" and which is the "to". I am not sure how to model this in Core Data. I have created two entities (Trip, Place), and now I want to setup the relationship(s) so I have a fromPlace and a toPlace. Do I need to add an extra field on the Place entity called isFrom, or similar?

If this was in a database, I would just have a id column on the Place table, and then two columns in the Trip table - fromPlaceId and toPlaceId. How do I achieve something similar in Core Data?

© Stack Overflow or respective owner

Related posts about iphone-sdk

Related posts about core-data