Database Schema Overview
The Tournament Platform database is designed around multi-tenant operator isolation with comprehensive tournament lifecycle management, supporting both scheduled and hop-on/off tournament formats.Schema Architecture
The database schema is organized into logical groups that support the complete tournament ecosystem:Operator Management
Multi-tenant operator isolation, API keys, roles, and settings management.
Tournament Core
Tournament types, status tracking, and configuration management.
Player Management
Player records, registrations, and multi-entry rebuy support.
Tournament Structure
Rounds, groups, and elimination tournament support.
Key Design Principles
Multi-Tenant Architecture
- Operator Isolation: All data scoped to operators with foreign keys
- Unique Constraints: External IDs unique per operator, not globally
- Role-Based Access: Fine-grained permissions via operator roles
- Independent Configuration: Separate settings per operator
Flexible Tournament Support
- Tournament Types: Points-based and elimination tournaments
- Status Tracking: Comprehensive status management for all entities
- Time Management: Scheduled start times with registration windows
- Multi-Entry System: Player rebuys and entry count tracking
Performance & Scalability
- Strategic Indexes: Optimized for common query patterns
- JSON Storage: Flexible configuration and result storage
- Slug-based PKs: Status lookups use meaningful slugs
- Cascade Handling: Explicit deletion order management
Core Table Groups
1. Operator Management Tables
Key Features:- Operator Statuses: Active, inactive, suspended states
- API Key Management: Expiration tracking and usage monitoring
- Webhook Configuration: Per-operator webhook URLs and secrets
- Role-Based Permissions: Granular access control
2. Tournament Core Tables
Key Features:- Flexible Configuration: JSON config field for tournament-specific settings
- Time Management: Separate scheduled start and registration windows
- Prize Pool Structure: JSON field supporting multiple prize distribution models
- External ID Mapping: Links to Casino System tournament identifiers
3. Player Management Tables
Key Features:- Multi-Entry Support: Track multiple entries per player via rebuys
- Session Management: Internal player IDs for tournament sessions
- Progress Tracking: Points accumulation and position tracking
- Payment Tracking: Total amount paid including rebuys
Data Types & Constraints
Primary Keys
- Auto-incrementing IDs: Standard bigint primary keys for main entities
- Slug-based PKs: String primary keys for status and type lookup tables
- Composite Unique Keys: Operator+external_id combinations
Foreign Key Constraints
JSON Configuration Fields
- Tournament Config
- Prize Pool Config
- Operator Settings
Indexing Strategy
Performance-Critical Indexes
Query Optimization Examples
- Active Tournaments
- Player Tournament History
Data Integrity & Validation
Referential Integrity
- Cascade Deletes: Operator deletion cascades to all related data
- Restrict Deletes: Prevent deletion of referenced status values
- Null Constraints: Required fields enforced at database level
Business Logic Constraints
Data Validation Rules
Migration Strategy
Schema Evolution
- Versioned Migrations: All schema changes tracked in Laravel migrations
- Backward Compatibility: New columns added as nullable with defaults
- Data Transformation: Complex schema changes handled with data migrations
- Rollback Support: All migrations include down() methods for rollbacks
Example Migration
Monitoring & Analytics
Database Metrics
- Query Performance: Slow query logging and analysis
- Index Usage: Monitor index effectiveness and optimization
- Connection Pooling: Optimize database connection management
- Storage Growth: Track table growth and partition strategies
Business Metrics
- Tournament Activity: Tournaments created, completed, cancelled per operator
- Player Engagement: Registration rates, rebuy patterns, retention
- Revenue Tracking: Entry fees, prize pool distributions, operator commissions
- System Health: Error rates, response times, availability

