在 MongoDB 中对锦标赛分组进行建模

发布于 2024-08-20 02:40:23 字数 140 浏览 5 评论 0原文

我一直在尝试使用 MongoDB,以便将应用程序的某些部分移至其中。我认为像 mongodb 这样基于文档的数据库非常适合锦标赛括号,但我很难找到合适的模型。 (仍在尝试摆脱 RDBMS 教条)

有人对单淘汰赛和双淘汰赛括号建模的好方法有任何想法吗?

I've been experimenting with MongoDB in order to move some parts of an app to it. I'm thinking a document-based db like mongodb would be a nice fit for tournament brackets but I'm having sort of a hard time coming up with a suitable model. (still trying to break free from RDBMS dogma)

Anyone have any ideas for a good way to model Single AND Double-elimination tournament brackets?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

疯到世界奔溃 2024-08-27 02:40:23

两种锦标赛的变化基本上都取决于每场比赛,要么导致以下选项之一:

  • 玩家获胜并晋级下一轮
  • 玩家获胜并赢得锦标赛
  • 玩家失败并退出锦标赛
  • 玩家失败并晋级到失败者组

因此,如果您这样建模您有一个具有如下模式的比赛集合:

{
_id :.., <- match id
players:[playerId1, playerId2],
resultForWinner: <either "WINS_TOURNAMENT" or match id of next match>
resultForLoser: <either "EXIT_TOURNAMENT" or match id of loser bracket match
}

您可以使用此模式组成两种类型的锦标赛括号,并重用您的锦标赛逻辑,而无需区分除括号设置之外的两者。

Both tournament variation basically come down to each match either resulting in one of these options :

  • Player wins and advances to next round
  • Player wins and wins the tournament
  • Player loses and exits the tournament
  • Player loses and advances to loser bracket

So, if you model it so that you have a collection of matches with a schema like :

{
_id :.., <- match id
players:[playerId1, playerId2],
resultForWinner: <either "WINS_TOURNAMENT" or match id of next match>
resultForLoser: <either "EXIT_TOURNAMENT" or match id of loser bracket match
}

You can compose both types of tournament brackets with this schema and reuse your tournament logic without making a distinction between the two other than bracket setup.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文