views:

140

answers:

1

Hi All,

I'm new to Core Data.

Currently I have following tables on hand:

tbl_teahcer   tbl_student   tbl_course      tbl_student_course_map
-----------   -----------   ----------      ----------------------
teacher_id    student_id    course_id       student_id 
name          name          name            course_id   
                            teahcer_id      

And I'm going to make the xcdatamodel as below:

Course                  Teacher             
------                  -------                         
name                    name                            
teacher  <<---------->  courses   
students <<---|
              |         Student
              |         -------
              |         name   
              |----->>  courses

My questions are as follows:

  1. As I'd like to create TableView for Source Entity, is it a must to create the Inverse Relationship from Teacher to Course, and Student to Course? What is the benefit for having the Inverse Relationship?

  2. I got some pre-defined data on hand, and I'd like to create a SQLite storage for pre-populated source. How can I set up the relationships (both directions) in SQLite?

Thank you for your help!

Regards, Cardinal

A: 

You cannot use Core Data with a pre-populated database. Core Data owns the schema for it's database and should never be touched directly. So step one is to import your data into Core Data. From there the other questions you have resolved themselves.

Marcus S. Zarra