Overview
The database uses PostgreSQL with Entity Framework Core as the ORM. All models are defined in Database/Models.cs:85 and inherit from a centralModels class container.
The schema is designed around two primary match types:
- Elimination Matches: Head-to-head battles with pick/ban phases
- Qualifier Lobbies: Multi-player linear mappool progression
Entity Relationship Diagram
The system implements the following database structure:The original source code includes a detailed GraphViz DOT diagram at Database/Models.cs:11-83 with color-coded relationships.
Core Entities
MatchRoom
Table:match_roomsPurpose: Represents a scheduled elimination match between two teams
Unique match identifier (e.g., “A1”, “C2”)
Foreign key to the Round that defines rules and mappool
Foreign key to User representing Team Red
Foreign key to User representing Team Blue
Optional foreign key to assigned RefereeInfo
Scheduled match start time (UTC)
Actual match completion time (UTC)
JSON-stored list of maps banned during pick/ban phase
JSON-stored list of maps picked during the match
Bancho match history ID (e.g., https://osu.ppy.sh/community/matches/{MpLinkId})
Relationships
Example Data
Example Data
QualifierRoom
Table:qualifier_roomsPurpose: Represents a qualifier lobby where multiple players compete through a fixed mappool
Unique lobby identifier
Foreign key to Round defining the qualifier mappool
Scheduled lobby start time (UTC)
Optional assigned referee
User who requested this specific time slot
Whether the lobby request has been approved by staff
Bancho match history ID
Relationships
Round
Table:roundsPurpose: Defines tournament stage rules, mappool, and match format
Unique round identifier
Human-readable name (e.g., “Round of 16”, “Qualifiers”)
Number of bans allowed per team (0 for qualifiers)
Ban strategy:
SpanishShowdown or OtherMaximum number of maps (e.g., 7 for Bo7, 13 for Bo13)
JSON-stored list of beatmaps with slots (e.g., NM1, HD2, DT3)
Mappool Structure
Example Round Configuration
Example Round Configuration
User
Table:usersPurpose: Links osu! identity to Discord account and serves as base for players/teams
Auto-incrementing primary key
osu! user ID (unique)
Discord user snowflake ID
Virtual Properties
The
DisplayName property is computed from the related OsuUser and not stored in the database.OsuUser
Table:osu_userPurpose: Stores cached osu! profile data
osu! user ID (matches User.OsuID)
Current osu! username
Global performance ranking
Country-specific ranking
Player
Table:playersPurpose: Extends User with tournament registration data
Auto-incrementing primary key
Foreign key to User
Registration timestamp
Serialized availability schedule (format varies)
Optional foreign key to assigned QualifierRoom
Relationships
RefereeInfo
Table:refereesPurpose: Stores referee authentication credentials and identity
Auto-incrementing primary key
osu! username used for IRC authentication
Discord user snowflake ID
osu! user ID
IRC password for Bancho authentication
ScoreResults
Table:score_results (inferred, no explicit [Table] attribute)Purpose: Individual score entries from completed maps
Auto-incrementing primary key
Foreign key to Round
Foreign key to User (player/team)
Map slot identifier (e.g., “NM1”, “HD2”)
Final score value
Accuracy percentage (0-100)
Highest combo achieved
Performance grade (SS, S, A, B, C, D)
Relationships
Enumerations
TeamColor
Location: Database/Models.cs:92Purpose: Indicates team/action ownership in elimination matches
BansType
Location: Database/Models.cs:103Purpose: Defines ban phase strategy
MatchType
Location: Database/Models.cs:113Purpose: Differentiates between tournament modes
Supporting Data Structures
RoundChoice
Purpose: Records pick/ban decisions with ownership and outcomesMatchRoom.BannedMapsMatchRoom.PickedMaps
JSON Column Storage
Entity Framework Core automatically serializes these properties to JSON:Database Context
The application usesModelsContext (Database/ModelsContext.cs) to interact with the database. Example usage from the codebase:
The
await using pattern ensures proper disposal and connection pooling for PostgreSQL connections.Related Documentation
Architecture
See how these entities fit into the overall system design
Automation Overview
Learn how AutoRef interacts with match data