My question is similar to a question on this link : Creating a CoreData entity based on attribute evaluation
In have just started coding my first project which uses Core Data, in which I have 5 entities, namely Companies,Meetings,Agendas,SubAgendas and Minutes. Companies are to be related to Meetings and each Meeting should have a relationship with its 'Agendas' and 'Minutes'... Subsequently each Agendas of a meeting should be related to its 'SubAgendas'
Following represent basic data model of my project:
Companies{ title:string }
Meetings{ title:string date:date }
Agendas{ name:string }
SubAgendas{ name:string }
Minutes{ name:string }
I need to code in such a way that if any info about the attributes in any of these entities is changed, it has to be synced.It involves creating new attribute values for each entity or updating the existing attribute values.For this I am planning to have an attribute named ID or tag for each entity, so that once I have set the relationship between each entity, I can update all the other attribute values of an entity with reference to that unique tag value.
Pardon me if my question is confusing.If you can understand, please tell me if what I am planning to do is the right way. I have absolutely no idea about the coding part but I think I can manage if any one can help me with a samples that has been used for similar requirements.
You are going about this the wrong way. Your "tag value" is really nothing but a so-called foreign key in traditional database programming.
But Core Data is not "a database", its an Object Graph. Thus you do not need to use these foreign keys, you just set up relationships between your entities and everything else happens behind the scenes.
Thus, to change an attribute, just do this:
So no need to update anything via foreign keys. Welcome to the wonderful world of Core Data.
Please read the Core Data Programming Guide to get a grip on these concepts.