193 lines
2.5 KiB
Markdown
193 lines
2.5 KiB
Markdown
# Relational Schema
|
|
|
|
## Rules
|
|
|
|
- UUID primary keys
|
|
- `timestamptz` for all timestamps
|
|
- No JSONB columns
|
|
- Child tables for attributes and event payloads
|
|
- Foreign keys wherever possible
|
|
|
|
## Core Tables
|
|
|
|
### users
|
|
|
|
- `id`
|
|
- `external_ref`
|
|
- `created_at`
|
|
- `preferred_language`
|
|
- `device_platform`
|
|
|
|
### sessions
|
|
|
|
- `id`
|
|
- `user_id`
|
|
- `started_at`
|
|
- `ended_at`
|
|
- `experiment_variant`
|
|
- `app_version`
|
|
- `device_model`
|
|
- `os_version`
|
|
- `locale_code`
|
|
|
|
### events
|
|
|
|
- `id`
|
|
- `sport_type`
|
|
- `source_ref`
|
|
- `title_en`
|
|
- `title_sv`
|
|
- `status`
|
|
- `preview_start_ms`
|
|
- `preview_end_ms`
|
|
- `reveal_start_ms`
|
|
- `reveal_end_ms`
|
|
- `lock_at`
|
|
- `settle_at`
|
|
|
|
### event_media
|
|
|
|
- `id`
|
|
- `event_id`
|
|
- `media_type`
|
|
- `hls_master_url`
|
|
- `poster_url`
|
|
- `duration_ms`
|
|
- `preview_start_ms`
|
|
- `preview_end_ms`
|
|
- `reveal_start_ms`
|
|
- `reveal_end_ms`
|
|
|
|
### markets
|
|
|
|
- `id`
|
|
- `event_id`
|
|
- `question_key`
|
|
- `market_type`
|
|
- `status`
|
|
- `lock_at`
|
|
- `settlement_rule_key`
|
|
|
|
### outcomes
|
|
|
|
- `id`
|
|
- `market_id`
|
|
- `outcome_code`
|
|
- `label_key`
|
|
- `sort_order`
|
|
|
|
### odds_versions
|
|
|
|
- `id`
|
|
- `market_id`
|
|
- `version_no`
|
|
- `created_at`
|
|
- `is_current`
|
|
|
|
### outcome_odds
|
|
|
|
- `id`
|
|
- `odds_version_id`
|
|
- `outcome_id`
|
|
- `decimal_odds`
|
|
- `fractional_num`
|
|
- `fractional_den`
|
|
|
|
### bet_intents
|
|
|
|
- `id`
|
|
- `user_id`
|
|
- `session_id`
|
|
- `event_id`
|
|
- `market_id`
|
|
- `outcome_id`
|
|
- `idempotency_key`
|
|
- `client_sent_at`
|
|
- `server_received_at`
|
|
- `accepted`
|
|
- `acceptance_code`
|
|
- `accepted_odds_version_id`
|
|
|
|
### settlements
|
|
|
|
- `id`
|
|
- `market_id`
|
|
- `settled_at`
|
|
- `winning_outcome_id`
|
|
|
|
### experiment_assignments
|
|
|
|
- `id`
|
|
- `user_id`
|
|
- `session_id`
|
|
- `variant`
|
|
- `assigned_at`
|
|
|
|
### localization_keys
|
|
|
|
- `id`
|
|
- `key_name`
|
|
- `description`
|
|
|
|
### localization_values
|
|
|
|
- `id`
|
|
- `localization_key_id`
|
|
- `locale_code`
|
|
- `text_value`
|
|
|
|
### analytics_event_types
|
|
|
|
- `id`
|
|
- `event_name`
|
|
- `description`
|
|
|
|
### analytics_events
|
|
|
|
- `id`
|
|
- `analytics_event_type_id`
|
|
- `session_id`
|
|
- `user_id`
|
|
- `occurred_at`
|
|
|
|
### analytics_event_attributes
|
|
|
|
- `id`
|
|
- `analytics_event_id`
|
|
- `attribute_key`
|
|
- `attribute_value`
|
|
|
|
### audit_logs
|
|
|
|
- `id`
|
|
- `created_at`
|
|
- `actor_type`
|
|
- `actor_id`
|
|
- `action_name`
|
|
- `target_type`
|
|
- `target_id`
|
|
- `trace_id`
|
|
- `note`
|
|
|
|
### audit_log_attributes
|
|
|
|
- `id`
|
|
- `audit_log_id`
|
|
- `attribute_key`
|
|
- `attribute_value`
|
|
|
|
## Indexes
|
|
|
|
- `sessions.user_id`
|
|
- `sessions.started_at`
|
|
- `events.status`
|
|
- `markets.event_id`
|
|
- `markets.lock_at`
|
|
- `bet_intents.session_id`
|
|
- `bet_intents.market_id`
|
|
- `bet_intents.idempotency_key`
|
|
- `analytics_events.session_id`
|
|
- `analytics_events.user_id`
|
|
- `analytics_events.analytics_event_type_id`
|
|
- `audit_logs.created_at`
|