Core Data Model Help

Discussion in 'iOS Programming' started by luke3, Sep 12, 2012.

  1. luke3 macrumors newbie

    Jun 6, 2012
    I am having some trouble finding the best way to set up my Core Data Model... Let me explain my current situation...

    I have three entities


    The Team is set up as a one to many with Player and Game. (Each team has players and games played)
    The Player is set up as a one to many with Game. (So I can show all the games that player has played in)

    Each Player scores points,and various other stats during a Game. The Team has properties such as "teamGamePoints" that correspond to all that teams players stats combined during the current game. So for example if player 1 scores two points and player 2 scores three points, the teamPoints would be 5.

    My question is How do I set up the model to support all the properties on the Player and Team entity such as playerGamePoints, and teamGamePoints specific to the game that it was played in? So I could look through the database of a Team or Player find all of its games, and that Entities stats during that specific game.

    My Problem now is where do I put the stat properties, teamGamePoints and playerGamePoints?
  2. dejo Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    Sounds like you actually have some many-to-many relationships and those are usually modeled in a separate table (with the two table ids as compound-primary and the other properties as attributes).

Share This Page