Re: Core Data and ordered relationships
Re: Core Data and ordered relationships
- Subject: Re: Core Data and ordered relationships
- From: Jamie Hardt <email@hidden>
- Date: Mon, 15 Sep 2008 15:13:59 -0700
Hi-
On Sep 15, 2008, at 2:55 PM, Sean McBride wrote:
b) add an attribute named 'index' (value 1 to 6) and code methods
named
employee1, etc. in my NSManagedObject subclass?
Certainly do the second one, unless there's some factor in your
business logic that demands exactly six employees, but I can't imagine
a situation where doing the to-many would be less good. First rule of
database normalization: never have repeating fields, and any time you
have an ordinal in a column name that's exactly what you're doing.
In order for these employees to always appear in the same order, you
display them in a NSTableView bound to an NSArrayController with a
sort descriptor set on your "index" key. Also, take a look at this on
how you can implement drag-and-drop reordring on your array
controllers, as well...
http://hmdt.jp/archives/image/2005_11/DNDCoreData.pdf
This might remove the need for you to have messy -employee[1-6]
methods on your Department object. The only reason I might do your
first suggestion, where you have 6 relations, is if those relations
actually had a business identity or meaning, like 1 was always
"Manager," 2 was always "Shift Supervisor," etc. But even then I'd
avoid locking myself down to a fixed number of roles per department,
since these can change with reorganizations.
Jamie Hardt
The Sound Department
http://www.soundepartment.com/
http://www.imdb.com/name/nm0362504/
_______________________________________________
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