Core Data Model Help

Discussion in 'iPhone/iPad Programming' started by luke3, Sep 12, 2012.

  1. macrumors newbie

    Joined:
    Jun 6, 2012
    #1
    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

    1)Game
    2)Team
    3)Player

    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. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    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