Hi all,
I have a Rails background and am trying to muck through Core Data. How does Core Data handle complex :has_and_belongs_to_many =>, :through =>
relationships?
As an example, suppose you were modeling open source project contributions. You might set up a table structure such as:
Contributor Contribution Project
---------------- ------------------ ------------------
name typeOfContribution name
address amountOfContribution urlForSourceCode
... startedOnDate ...
... endedOnDate ...
contributor
project
In this case you would say that both Contributor and Project :has_and_belong_to_many
of each other, and that both relationships are :through
the Contribution join table. This lets you store information about the relationship within the relationship itself (the Contribution table).
The Rails convenience methods are also really handy to have, so you can navigate through the relationships simply. For example:
contributor.projects // this would return an array of project objects associated with the contributor
project.contributors // this would return an array of contributors associated with a project
So my question boils do to this:
- Is it possible to model in a similar way using Core Data? and
- If so, can the relationships be traversed as easily as the code above (sample code would be great)?