Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

luke3

macrumors newbie
Original poster
Jun 6, 2012
23
0
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?
 
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).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.