开发者

Setting up CoreData and inner joins

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜