Re: Core Data: unidirectional relationships
Re: Core Data: unidirectional relationships
- Subject: Re: Core Data: unidirectional relationships
- From: Adam P Jenkins <email@hidden>
- Date: Wed, 13 Feb 2008 13:32:42 -0500
This was my first idea also on seeing the original post. I didn't
post it though because the problem is fetched properties are modeled
as to-many relationships. That is, when you access the fetched
property you get back a set or array, not a single object. It seems
kind of messy that when you access a Department's headOfDepartment
attribute, you'd get back an NSSet containing the department head
rather than getting an Employee object. If you ignore that flaw
though, then it would work nicely. You could always hide this
messiness with some additional wrapper properties which pull the
object out of the set.
On Feb 13, 2008, at 12:52 PM, William Turner wrote:
Hi Ruotger,
Another alternative that might work for you is to add a
"title" (string) attribute to Employee and fetched properties to the
Department for each of headOfDepartment, viceHeadOfDepartment,
pointyHairedBoss, and dilbert, with their predicates being
title=="Head", title=="ViceHead", etc.
You can read more about using fetched properties to represent one-
way relationships near the end of http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdRelationships.html
Wil
On Feb 13, 2008, at 9:29 AM, Brian Williams wrote:
I have had to deal with this also. I think that the best solution
is to just
have those empty back links and accept the clutter. You could also
have
subclasses of employee, but i am sure that would cause other
problems.
On 2/13/08, Ruotger Skupin <email@hidden> wrote:
Hi,
consider the following example (that what I would like to model):
Entity: Department
Attributes: ...whatever...
Relationships:
headOfDepartment --> Employee
viceHeadOfDepartment --> Employee
pointyHairedBoss -->
dilbert -->
other Employees -->>
Entity: Employee
Attributes: ...whatever...
Relationships:
department --> Department
Every Employee is only in one Department. The Department has (and
needs) four special Employees (head, vice head, pointy haired boss,
dilbert). Turns out that it is impossible to model this with
bidirectional relationships if you don't want to model it like that:
Entity: Employee
Attributes: ...whatever...
Relationships:
departmentImHeadOf --> Department
departmentImViceHeadOf --> Department
departmentImPointyHairedBossOf --> Department
departmentImDilbertOf --> Department
departmentOtherEmployeeOf --> Department
The other alternative is to model it with unidirectional
relationship,
which is discouraged.
Can anyone gime some advice on this?
Ruotger
_______________________________________________
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
_______________________________________________
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)l
_______________________________________________
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