对于我所在的一个体育俱乐部,我想在网站上用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
在网站上,我将查询锦标赛表,排序ID和球员,并处理结果,以计算排名列表。
这是一个好方法,还是有更好、更方便的方法?
以后您可能会发现多一个表会更方便。
我会把你的比赛表改成:
tournaments
-----------
ID (unique primary key)
Date
~Location
~+Other stuff about the tournament as a whole
然后添加一个表:
results
-----------
player_id (points to player ID)
tournament_id (points to tournament ID)
+results
这样做的原因是,这样可以更容易地过滤单个比赛,并且许多玩家可以共享相同的比赛信息,而无需重复每个玩家的结果。