使用MySQL管理排名列表

Seb*_*ian 1 php mysql

对于我所在的体育俱乐部,我想在网站上管理MySQL的排名列表.

我们有一个锦标赛系统,玩家可以每周参加一次(或不参加)并获得积分.这些点以某种方式处理,并且应该在网站上创建排名列表.

我对MySQL不太熟悉,所以我想知道我认为的系统是好还是其他方法会更好.

我想过有两张桌子:

players
-------
ID (unique primary key)
Name
Surname
+other arbitrary stuff

tournaments
-----------
ID (unique primary key)
Date
player (secondary key,  points to player ID)
+ columns for results of that player in this particular tournament
Run Code Online (Sandbox Code Playgroud)

然后我会在网站上查询锦标赛表,排序ID和玩家并处理结果以计算排名列表.

这是一个好方法还是有更好,更方便的方法来做到这一点?

小智 6

稍后您可能会发现再增加一个表会更方便.

我会将你的锦标赛桌改为更像:

tournaments
-----------
ID (unique primary key)
Date
~Location
~+Other stuff about the tournament as a whole
Run Code Online (Sandbox Code Playgroud)

然后添加一个表:

results
-----------
player_id (points to player ID)
tournament_id (points to tournament ID)
+results
Run Code Online (Sandbox Code Playgroud)

推理是因为它可以更容易地在单个锦标赛上进行过滤,并且许多玩家可以共享相同的锦标赛信息而不会在每个玩家上重复结果.