I'm very new to the core data programming. I understand that the entities are tables, and I'd like to do the following:
One table, "Record" has an attribute "recordID" in another table ("Event") I have a series of events associated with this record, they all also have an attribute "recordID". There's a one entry in the "Record" table to many "Events" relationship between these tables, linked by "recordID".
I would like to know how to use the GUI "Fetched Properties" in the Data Model Editor to retrieve an array of "event" for the record's current recordID.
I checked the predicate programming guide, and it mentions that I can do something like this:
[NSPredicate predicateWithFormat:@"anAttribute == %@", [NSNumber numberWithBool:aBool]];
So in the GUI, I was thinking of using
recordID == recordID
How do I differentiate between different tables ? do I say self.recordID = recordID or something?
Edit: Unless I completely misunderstand what the relationships are for. Do relationships automatically link tables for me?
First, Core Data is not a database. Core Data is an object graph that can persist to a sqlite file.
Second, Core Data handles the relationships for you. Just create a relationship between the two entities, set the Record
instances as the "parent" to the Event
instance and the relationship will be created for you.
You do not need to create foreign keys yourself. Core Data will manage them and keep the referential integrity for you.