I'm currently working on a university assignment and am trying to create a mock-up model of my project. One of the tasks in the assignment is to create a project which uses a many-to-many and a one-to-many relationship. My idea is that there are a number of basketball leagues. These basketball Leagues have multiple Teams in them, which have multiple Players in them. A Player can be a part of multiple Teams. Now, every Team plays a number of Games, and those Games would have the statistics of all players that played in that game. I want it to be possible to open up a Player's page and see his statistical averages in all teams that he has played in (The averages would be calculated by iterating through all Teams he is playing in, then iterating through that Team's Games and if there are statistics to that player, add them to the averages).
The problem arises when trying to figure out how to get the statistical averages of a Player. Since a Player can play in multiple Teams, I don't suppose he could hold all the statistics himself (since I need to be able to see not only his averages, but his statistics in all of the games he has played in)? That means, I would need an intermediary class, like GamePlayer, which would be created with a reference to the Player, but would only be used in the class Game to retrieve the statistics of that player.
1) Is having the Player class have a list of Teams he is on, and for the Team to have the list of Players that are on it a good practice?
2) Is having that intermediary class GamePlayer a good idea, or is there some other design solution more suitable for what I want to accomplish?
Please let me know if there is information missing in my question and if you could give me some tips on how to better design my project that would be greatly appreciated. Here is a little model I drew up (I'm not good at drawing UML's so please bear with me)
EDIT: I want to specify what the system should be able to do:
1) In the Team page, list all the Players and Games it has played in.
2) In the Player page, list all the Teams he is on and all the Games he has played in with each them (group those Games by League/Team)
3) League page must show each Team's win/loss ratio. Now that I think about it, I'm not sure if Wins/Losses should be computed by getting all the games or should the value in the database change after storing a new row in Game table?
Aucun commentaire:
Enregistrer un commentaire