Faction Units

Canonical unit definitions per faction
SQL Core Data Critical Reference
units

The physical table name is units, but in BattleScore’s logical model this is the faction-units layer: the canonical unit library attached to factions.

Purpose

Stores the canonical unit definitions used by army building, imports, master-unit linking, and downstream gameplay interpretation.

Hierarchy position

race
 └── factions
      └── units
           └── army_units.master_unit_id

Columns

Column Type Null Notes
idint unsignedNoPrimary key
faction_idint unsignedNoOwning faction
namevarchar(200)NoCanonical unit name
unit_typeenumNoHero/Core/Special/Rare/Ally/Mercenary/Other
created_atdatetimeNoCreation timestamp
updated_atdatetimeNoLast update timestamp
deleted_atdatetimeYesSoft delete marker

Allowed unit types

Hero
Core
Special
Rare
Ally
Mercenary
Other

Keys and indexes

  • PRIMARY KEY (id)
  • idx_units_faction_id (faction_id)
  • idx_units_deleted_at (deleted_at)
  • idx_units_faction_type (faction_id, unit_type)

Foreign keys

  • fk_units_factions: units.faction_id → factions.id

Relationships

Relationship Type Notes
units.faction_id → factions.id Many-to-one Each canonical unit belongs to one faction
army_units.master_unit_id → units.id One-to-many User army units can link back to canonical units
unit_aliases.unit_id → units.id One-to-many Alias layer used to stabilise import matching

Used by

  • Manual army construction
  • Import matching for OWB / NR / SIC
  • Unit usage reporting
  • TO entrant army workflows

Design notes

  • This is one of the most important reference tables in the system
  • Soft delete is supported
  • There is no points column in the canonical unit table
  • Army-specific points and flags are stored on army_units, not here

Critical system note

Import accuracy depends heavily on the quality and consistency of canonical unit names in this table, together with unit_aliases.

Risks

  • Name changes can break imports or reduce match quality
  • No uniqueness constraint is present for (faction_id, name)
  • Soft-deleted rows require careful filtering in all read paths

Recommended future improvements

  • Add uniqueness constraint such as (faction_id, name) if appropriate
  • Document alias strategy alongside this table
  • Consider adding normalized name support for direct matching