Reputation: 462
I have 3 tables.
Classes
---------------
classid
name
description
Sessions
---------------
sessionid
name
start
end
Schedule
---------------
scheduleid
name
start
end
classid
sessionid
I know how to set this all up in a relational database, but as far as setting them up as entities.. I am not sure which needs/should be the main object...
Upvotes: 1
Views: 537
Reputation: 6244
What do you mean by "main object"? It's just a graph of entities and objects. In this case you should probably have one entity for each table (in singular: Class, Session, Schedule), with properties for the actual data and relationships for the foreign keys.
You can't manually specify the primary key, CoreData does that (it's an implementation detail).
So you'd probably have something like this:
I can recommend Apple's own documentation on CoreData, especially the sections about the Data modelling tools in Xcode. It's possible to essentially draw your data models using Xcode and have the (optional) class declarations automatically generated for you.
Upvotes: 2
Reputation: 115
The main object would be your Schedule. You have a Schedule that has
-id
-name
-start
-end
-Class (or IList<Class>)
-Session (or Ilist<Session>)
Upvotes: 0