I know how to create a relationship in coredata,but i do not know how it works.
Eg.:
Employee: name id
Department: name
I can create a relationship(one to many) between 'Department' and 'Employee',and when i fetch 'Department', i will also get employees automatically.
If no relationship,I will create a field(employeeId) in department, and join 'Employee' table.
I do not know coredata how to get the correct employees by relationship.
Thanks
You can explore what is the entity is from the real sqlite file.
For example I have this relationship
When I add three record,I use SliteBrowser to View the SQLite file It have five tables
The ZDEPARTMENT Table The ZEMPLOYEE Table
Note what I selected in ZEMPLOYEE,it save the id of department
in ZDEPARTMENT,so it is quite clear how core data relationship works.
NOTE:
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments