我正在尝试开发一个投注系统,这是我的数据库模型的UML图的一部分。
MATCH(match_id, home_team, away_team, time)
FIRST_HALF(match_id, home_team_goals, away_team_goals)
SECOND_HALF(match_id, home_team_goals, away_team_goals)
BETTYPE(bet_type_id, match_id, odd, bet_name)
我对我的MATCH有一些怀疑 - > BETTYPE关系。这是一个很好的做法,或者在MATCH表中为匹配所有的投注类型做得更好,例如:
MATCH(match_id, home_team, away_team, winner, first_half_winner, second_half_winner, home_team_goals, away_team_goals...)
哪种解决方案更好?第一还是第二? 谁可以为我描述这个迷你应用程序的优秀UML图?我想要一个架构,这将使我的工作更容易关注数据库查询。
提前谢谢。
答案 0 :(得分:0)
首先,不要在赔率类型表中输入赔率。每次下注都有不同的赔率,即使他们的赌注类型相同 关于分数的位置,您有2个有效选项:
优点:
缺点:
样本表:
TblMatch
--------
Match_Id (pk)
Match_Date
Match_Time
Match_HomeTeam (fk to team)
Match_AwayTeam (fk to team)
Match_FirstHalfHomeTeam
Match_FirstHalfAwayTeam
Match_SecondHalfAwayTeam
....
优点:
缺点:
样本表:
TblMatch
--------
Match_Id (pk)
Match_Date
Match_Time
Match_HomeTeam (fk to teams)
Match_AwayTeam (fk to teams)
TblScoreType
------------
ScoreType_Id (pk)
ScoreType_Name (unique)
TblMatchScore
-------------
MatchScore_Id (fk to match)
MatchScore_ScoreType (fk to score type)
MatchScore_Team (fk to team)
我可能会选择第二种选择。
至于投注,有一个投注类型表和一个实际投注表:
TblBetType
----------
BetType_Id (pk)
BetType_Name (unique)
-- other relevant columns
TblMatchBet
------
MatchBet_Id (pk)
Bet_BetType (fk to bet type)
Bet_Match (fk to match)
Bet_Odds
TblBet
------
Bet_Id (pk)
Bet_MatchBet_Id (fk to match bet)
Bet_Amount
Bet_User (fk to users)
-- other relevant columns such as date and time and stuff like that)