I'm trying to make a sports stats app in Java/Android + Realm.
I have the following classes:
Season
Player
Matches
I would like the Season to contain a "list" of all the players that played that season and Players to have a "list" of matches.
I currently have actual lists as attributes to each class. For example the Player class:
public class Player{
String name;
Int wins;
Int losses;
List <Matches> matches;
}
Where I would just use the .add function to add to new matches to the player. Also I did take off some syntax related to Realm for simplicity, but this would be a RealmObject.
Is there a better way to do this? I noticed issues with this implementation, like if I wanted to get all the Matches associated with the season. I would have to go through each player, and account for duplicates. Similarly if I wanted to view all players regardless of Season.
What would the better way be?
Edit: to clarify this is with combat sports, and I'm looking for ways to associate objects with other objects. The real purpose of the app is on a small level, for coaches to keep track of their players. A player is a team essentially. The user is pretty much focused on player stats. Here's the layout with UFC as example.
The app would open to a list of years. From the list let's say I select 2019. It would then open up a list of all players in 2019 that had matches. I select Khabib. It would then show me his stats and matches for that year (with the option to change date so I can change to view for past 3 years or life time if needed). And then I can select a specific match and view it's details.
The issue with my current implementation is modifying ranges. For example, if the user wants to view all players regardless of season, change the range in which matches would be view etc.