I'm designing a league system for a game.
There will be many leagues and a league will include 50 players.
I have two alternatives:
1#
Table player{
playerid number primary key,
leagueid number foreign key,
score number
}
Table league{
leageuid number primary key
}
Whenever a player with leagueid "x" wants to get the current leaderboard.
- The backend will select all players with leagueid "x"
- Sort the data using the player's current score and return.
2#
Table player{
playerid number primary key,
leagueuid number foreign key,
score number
}
Table league{
leagueid number primary key
playersList array of playerid's
}
Whenever a player with leagueid "x" wants to get the current leaderboard.
- The backend will select the league with leagueid "x"
- For each playerid in "playerList", get the current score of "playerid" from the "player" table.
- Sort all the scores and return
Which of the alternatives is better? If there is a more efficient way, please let me know.