レーティング計算システム
イロレーティングをWeb上で計算するシステムを設計中。
まずはDBのテーブルから。
型とかは作りながら考えます。
試合結果をgame_groupsとgame_resultsに記録して、計算結果をplayersに保存する感じです。
accounts
  id (PK)
  name
  password
  description
players
  id (PK)
  account_id (FK)
  name
  default_rate
  rate
  wins
  loses
  draws
game_groups
  id (PK)
  account_id (FK)
  game_date
game_results
  id (PK)
  game_group_id (FK)
  player_id (FK)
  result -- 1 or 0 or 0.5
試合結果は1レコードにまとめようかとも思いましたが、1対1以外のケースにも対応できるように分けてみました。
player1がplayer2に勝った場合のgame_resultsは以下のようになります。
| id | game_group_id | player_id | result | 
|---|---|---|---|
| 1 | 1 | 1 | 1 | 
| 2 | 1 | 2 | 0 | 

