Many-To-Many Predicates

  • I am having trouble creating a predicate that works across multiple
    relationships. There are two entities that are Many-To-Many to each
    other through a third "link" entity. Basically an entity of Clips and
    Albums. A single Clip can be in multiple Albums, likewise, an Album
    has multiple Clips. I need the third
    "link" entity because I need to maintain the sort order in each of
    the albums. The sort is user defined and would be different for each
    album.

    Here is a link to a screen grab of the model.  http://
    www.filmworkers.com/model.jpg

    I need to filter a NSTableView of Clips based on the selected Album.
    Here is my predicate that I am sending to the NSTableView.

    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY
    sourceListLinks.sourceListItems.itemName == %@", sourceListItemName];

    It seems the search gets through to the SourceListLink entity and stops.

    Any ideas on what I am missing?

    Todd Freese
  • Le 26 oct. 06 à 02:17, Todd Freese a écrit :

    > I am having trouble creating a predicate that works across multiple
    > relationships. There are two entities that are Many-To-Many to each
    > other through a third "link" entity. Basically an entity of Clips
    > and Albums. A single Clip can be in multiple Albums, likewise, an
    > Album has multiple Clips. I need the third
    > "link" entity because I need to maintain the sort order in each of
    > the albums. The sort is user defined and would be different for
    > each album.
    >
    > Here is a link to a screen grab of the model.  http://
    > www.filmworkers.com/model.jpg
    >
    > Any ideas on what I am missing?

    What seems curious to me is why the two relationships are many-to-
    many. I have a similar model (with albums and authors) and the
    relationships are :
    albums<-->>role<<-->authors  (it's because an author can have
    different roles in different albums).

    And are you sure sortKey must be a property of the Link entity ? You
    said that each album needs maintain the sort order, why not have a
    clipSortKey in the Album ?

    Fred
previous month october 2006 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today