简体   繁体   English

如何使用Laravel设计数据库?

[英]How to design my database with Laravel?

I'm just doing my first steps with Laravel and web development in general. 一般来说,我只是在Laravel和Web开发方面迈出第一步。 For this step of my project I'm designing DB for tournament website. 对于项目的这一步,我正在为锦标赛网站设计数据库。

What I eventually need: Every match has 3 maps. 我最终需要的是:每场比赛都有3张地图。 Every map has own score for each team (score_left_team -Map_name - score right team ). 每个地图对每个团队都有自己的得分(score_left_team -Map_name-得分右团队)。 And every match has general score (left_team_score - right_team_score) Perfect example: https://overwatchleague.com/en-us/match/10223 并且每场比赛都有总得分(left_team_score-right_team_score)完美的例子: https ://overwatchleague.com/zh-cn/match/10223

How can I create the correct relationships and improve my design below? 如何在下面创建正确的关系并改进设计?

Team::
 id
 name

Player:: 
 id
 team_id (belongsTo Team::class)
 name

Map:: 
 id
 name
 photo

Match_Map:: 
 id
 map_id (belongsTo Map::class)
 match_id (belongsTo Match::class)
 score_left
 score_right

 Match:: 
  id
  date
  stage_name
  group_name
  left_team_id (belongsTo Team::class)
  right_team_id (belongsTo Team::class)
  score_left
  score_right
  winner (How to create here relationship?)
  status 

I appreciate any tips! 我感谢任何提示!

Looks fairly correct, if you have the scores for both teams when you are creating the record, you could have a winner_id be a foreign key for a team id. 看起来相当正确,如果在创建记录时同时获得了两支球队的得分,则可以将Winner_id作为球队ID的外键。 This could be both on match_map and on match . 这可能同时在match_mapmatch Besides that looks good. 除此之外看起来还不错。

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

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