Re: Managed Object wants a per-relationship attribute?
Re: Managed Object wants a per-relationship attribute?
- Subject: Re: Managed Object wants a per-relationship attribute?
- From: Greg Titus <email@hidden>
- Date: Sat, 15 Sep 2007 18:41:32 -0700
The proper way to model it is to add another entity in-between. In
this case, something like "Entry", where an Event has multiple
Entries, a Swimmer has multiple Entries, and each Entry is for a
single Swimmer in a single Event. The position is then part of the
Entry.
Hope this helps,
- Greg
On Sep 15, 2007, at 6:35 PM, Jerry Krinock wrote:
It thought this would be a natural for Core Data, but I've run
myself into a conceptual wall.
Say that I'm modelling a swimming meet. My data model has two
entities: Events and Swimmers. Of course, each Event requires
multiple Swimmers, and each Swimmer can swim in several Events.
My Events should show swimmers ordered by speed: 1st, 2nd, 3rd,
etc. Since CoreData's to-many relationships are not ordered, I add
to Swimmer a 'position' attribute. In the 100-meter freestyle
Event, Suzie's position is 1 and Jane's position is 2. But in some
other event, say the 200-meter butterfly, Jane is faster than
Suzie, so the positions need to be reversed. But I can't do that
since each Swimmer only has one 'position' attribute.
I can easily extend some Apple examples to run into the same wall.
Imagine in CoreRecipes, if you added a Pantry entity which
contained common Ingredients used for different Recipes. The
'displayOrder' attribute would be conflicted among the different
Recipes in which the Ingredient was used. Or, imagine in
DepartmentsAndEmployees, if you added a Projects entity, with
Employees having a different 'function' in each project?
Duh! What's the proper way to model this?
Much thanks,
Jerry Krinock
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden