I was wondering what was the better approach for my database/table design. As show in the picture, i have players who play a match. One player plays multiple matches and one match is played by multiple players, so it is a n:m relation. This could result in thress tables player(id, firstname), player_to_match(playerid, matchid), match(id). In my case, the number of players never changes, it is always two (n=2). Which of the following designs is better?
(1)
player_to_match(matchid, playerid)
Having two rows for each map and one cell redundancy (matchid)
(2)
match(matchid, playerid1, playerid2)
As i said, the number of players per match can never change
Thank you
Lucas
[ERM-Diagram with two Entities: Player(ID, Firstname), Match(ID), n:m Assosiation from Player to Match titled "plays"] http://fs1.directupload.net/images/141210/rmeuutpg.png
I'd stick with option (1). It will make it easier to answer such simple questions as "how many matches has player X played?" With option (2), you'd have to query two columns for the value X to answer that question and that starts to get ugly.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments