• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Multiple Self-joins
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multiple Self-joins


  • Subject: Re: Multiple Self-joins
  • From: Chuck Hill <email@hidden>
  • Date: Wed, 12 Jan 2005 12:21:44 -0800

On Jan 12, 2005, at 12:12 PM, David Holt wrote:

Thanks Chuck,

I wasn't thinking clearly about the FKs. I was joining on imageID>imageID in both cases. That make no sense whatsoever.

I suspected so. Sometimes doodling is an effective tool.

So now I have the to-one relationships cleared up. How do I implement the to-many self join? I have made a to-one between parentFK>imagePK. Where does the to-many relationship sit? Is there a link table?

imagePK->>parentFK is the to-many. All the children will have the parent's PK in their parentFK column.


I do not understand your suggestion for reordering the images. They are process flows, so I could see having to reorder them in the future. In fact it is guaranteed. Is there a resource that I could read to help me understand what you are talking about?

Just imagine that each image has an order, 1..N. This is its intended order in its _parent's_ children. An image will need a method orderedChildImages() that returns childImages() sorted on order() (see EOSortOrdering). Thus, to reorder images you only need to alter the numbers stored in order() and not adjust a bunch of previousImage and nextImage relationships.

As an example, to get the previous image:
public Image previousImage() {
    NSArray sortedImages = parent().orderedChildImages();
    int ourIndex = sortedImages.indexOfObject(this);
    if (ourIndex == 0) {
        // We are first, there is no previous, return null
       return null;
    }

    return sortedImages.objectAtIndex(ourIndex - 1);
}

Chuck


On 12 Jan 2005, at 11:55 AM, Chuck Hill wrote:

On Jan 12, 2005, at 11:49 AM, David Holt wrote:

Hi Chuck,

I can create a to-one relationship (named parentImage) and a to-many relationship (named childrenImages) linked on the primary key of the image table.
Linked to what?

When I go to create an additional to-one relationship (nextImage or previousImage),
Linking what to what?

the inspector in EOModeler shows the entities as already being connected by their primary keys and the button is labelled "disconnect". There is no way to create additional relationships using the same primary keys without disconnecting the previous relationship as far as I can tell.

Of course not. The same thing can't be different things at the same time. Draw it out on a piece of paper. You need

pk
parentFK (PK value, but a FK in use)  -> for parentImage, childImages
previousFK -> for previousImage
nextFK -> for nextImage

You might want to forget about the previousFK and nextFK and just use an order column and make previous and next image methods on the parent. It will be a lot easier to reorder like that.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
village.net


This email sent to email@hidden

--
Practical WebObjects - a book for intermediate WebObjects developers who want to increase their overall knowledge of WebObjects, or those who are trying to solve specific application development problems.
http://www.global-village.net/products/practical_webobjects




_______________________________________________
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


References: 
 >Re: Multiple Self-joins (From: Chuck Hill <email@hidden>)
 >Re: Multiple Self-joins (From: David Holt <email@hidden>)
 >Re: Multiple Self-joins (From: Chuck Hill <email@hidden>)
 >Re: Multiple Self-joins (From: David Holt <email@hidden>)

  • Prev by Date: Re: Multiple Self-joins
  • Next by Date: Learning Curve
  • Previous by thread: Re: Multiple Self-joins
  • Next by thread: Multiple Self - joins
  • Index(es):
    • Date
    • Thread