Re: Inverse to-one relationships
Re: Inverse to-one relationships
- Subject: Re: Inverse to-one relationships
- From: Paul Hoadley <email@hidden>
- Date: Fri, 23 Jul 2010 08:07:23 +0930
On 23/07/2010, at 7:32 AM, Chuck Hill wrote:
> On Jul 22, 2010, at 2:56 PM, Paul Hoadley wrote:
>
>> Sorry, I should have tried to be clearer. Basically, I've got a parent object B (which will always be created first). At some point, B may obtain at most one child A, but it doesn't necessarily. So every B has zero or one child As. Every A has exactly one parent B.
>>
>> Currently I have a mandatory to-one relationship from A to B (so A knows its parent directly). To avoid some fetching, I have added an optional to-one relationship from B to A, so B knows its child if it has one. I assume there's no way to make these relationships inverses from EOF's perspective, and that I will just need to be careful about always setting the B to A relationship on creation of an A.
>
> How did you model this? B hold's the PK of A as a FK? They each need a FK for the other, I think. Your relationships should be
>
> B.FKA == A.PK [1]
> A.FKB == B.PK [2]
>
> I think...
Yeah, that's exactly what I've done. And [1] is optional (because not every B (parent) has an A (child)), and [2] is mandatory (because every A (child) has a B (parent)). But AFAICS, they're not being recognised as inverse relationships. Which is fine, because that's what my archive searching lead me to expect, but I wanted to, uh, go over it one more time.
--
Paul.
http://logicsquad.net/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden