简体   繁体   English

PHP Tourney / cup的数据结构

[英]Datastructure of a php tourney/cup

I have started writing a cup tree and this works now. 我已经开始写杯树了,现在可以了。

I now want to ask what is a good database structure for a tourney. 我现在想问一问Tourney好的数据库结构是什么。

I thought this way: 我是这样想的:

table participant
--------------
id of player
id of cup


table round
-----------
id of cup
id of player
number round


table cup matches
-----------------
id match
id of cup
id of playerA
id of playerB
number resultA
number resultB

Is this a good design? 这是一个好的设计吗?

Workflow: 工作流程:

First round: all particpants joined. 第一轮:所有参与者加入。 Matches for round one are generated. 生成第一轮比赛。

PlayerA enters result (he won). 玩家A输入结果(他赢了)。 PlayerB accepts. PlayerB接受。 Becuase match is accepted a entry is made in round. 因为比赛被接受,所以进行一次全面的录入。 PlayerA is now in the next round. PlayerA现在在下一轮。

After the last match is entered the next matches are generated. 输入最后一个匹配项后,将生成下一个匹配项。

Better ideas out there? 有更好的主意吗?

Why not store the round number in the participant table? 为什么不将回合号存储在参与者表中? I see no reason for (a) storing this attribute in a separate table or (b) storing an entry for every round a player participates in. The maximum reached round per player should be enough. 我认为没有理由(a)在单独的表中存储此属性,或(b)在玩家参加的每一轮比赛中都存储一个条目。每个玩家达到的最大回合数应该足够。

Also, depending on your application, you could add the round number to a match. 另外,根据您的应用程序,您可以在比赛中添加轮数。 I know it's redundant, since you can find that out by looking at the reached round number of the loser, but when having lots of requests for this information, the extra query should be spared!? 我知道这是多余的,因为您可以通过查看失败者的达到的轮数来找出答案,但是当有很多关于此信息的请求时,应该省去多余的查询!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM