game_sides

Per-game side records linking players/labels to armies
SQL Gameplay Runtime Structure
game_sides

Purpose

Stores the side-level records for a game. In practice this table holds the two sides, typically A and B, and links each side to an army list and optional player label.

Role in the system

games
 └── game_sides
      └── game_units

Columns

Column Type Null Notes
idbigint unsignedNoPrimary key
game_idbigint unsignedNoParent game
side_codechar(1)NoTypically A or B
player_namevarchar(120)YesDisplay name for the side/player
army_list_idbigint unsignedYesSelected army list
created_atdatetime(3)NoCreation timestamp
updated_atdatetime(3)NoLast update timestamp

Keys and indexes

  • PRIMARY KEY (id)
  • UNIQUE KEY uq_game_side (game_id, side_code)
  • KEY ix_game_sides_game (game_id)
  • KEY ix_game_sides_army (army_list_id)

Foreign keys

  • fk_game_sides_game: game_sides.game_id → games.id ON DELETE CASCADE
  • fk_game_sides_army: game_sides.army_list_id → army_lists.id ON DELETE SET NULL

Relationships

Relationship Type Notes
game_sides.game_id → games.idMany-to-oneEach side belongs to one game
game_sides.army_list_id → army_lists.idOptional many-to-oneSelected army for the side
game_units.game_side_id → game_sides.idOne-to-manyInstantiated units belong to a side

Used by

  • Game setup and side assignment flows
  • Game start logic when units are instantiated
  • Play-state views and score breakdowns

Design notes

  • The unique constraint ensures only one row per side code per game
  • army_list_id is nullable so incomplete setup states are supported
  • This is a lightweight structural table; most gameplay state lives deeper in game_units and game_events

Risks

  • Side code semantics are application-controlled rather than enum-constrained
  • Null army assignments must be handled cleanly by setup/play logic

Recommended future improvements

  • Document allowed side codes explicitly
  • Consider a DB check constraint if side values should remain fixed