I have two tables
Normally, I would set them up as:
Classes
--------------
ClassID int autoinc
开发者_运维技巧ClassName string
Session
--------------
SessionID int autoinc
SessionName string
SessionStart date
SessionEnd date
ClassID int FK
I would then query the sessiontable and join the classes table on classid.
In setting this up using CoreData do I still need the ClassID? I see that I can setup a relationship, but it doesn't seem to link to a specific column... only a table..
Your thinking is a a little database-oriented, which is no bad thing, but a Core Data schema isn't a relational database schema. You need to think in terms of objects, not tables and columns. You have two entities, not two tables.
The framework itself handles generating unique identifiers for each object. This identifier is really just an implementation detail. Create the objects, define the relationships, and Core Data will handle the rest, including creating bridge tables to handle many-to-many relationships.
精彩评论