iphone - Core Data modeling of relationships -


i'm modeling app in core data. have object called 'stats' have 'player', 'team', , 'game' associated each object. once these stats objects stored, imagine querying them 1 or more of these attributes (player, team, game). see model below.

core data model

question 1: make sense model these 'relationships' opposed 'attributes'.

question 2: when retrieving form nspredicates using objects , not have keep track of unique ids names each player, team, or game. if store player, team, , game objects (as opposed unique ids or names) each entity, best way retrieve them. following work if wanted retrieve stats objects particular 'team' (someteamobject) or need query objectid?

nspredicate *predicate = [nspredicate predicatewithformat:@"team == %@", someteamobject]; 

thanks

  1. if understand question right, yes, makes sense model these separate objects relationships between them. when fetching various objects; could, example, single player associated given stat, or stats game. leads second question:

  2. instead of using predicate, note relationships have names; instead of building full nsfetchrequest associated nspredicate, call relevant accessor method. request stat objects team, call [team stats] , nsarray of stat objects.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -