-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
31 lines (27 loc) · 1.33 KB
/
Copy pathschema.sql
File metadata and controls
31 lines (27 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
-- Position Evaluator — MySQL schema
-- Run: mysql -u root -p < schema.sql
CREATE DATABASE IF NOT EXISTS position_evaluator
CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE position_evaluator;
CREATE TABLE IF NOT EXISTS entries (
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
user_id VARCHAR(50) NOT NULL DEFAULT 'default_user',
situation_text TEXT NOT NULL,
entry_date DATE NOT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
situation_hash CHAR(64) GENERATED ALWAYS AS (SHA2(situation_text, 256)) STORED,
UNIQUE KEY uq_user_date_hash (user_id, entry_date, situation_hash),
INDEX idx_user_date (user_id, entry_date)
) ENGINE=InnoDB;
CREATE TABLE IF NOT EXISTS diagnoses (
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
entry_id BIGINT UNSIGNED NOT NULL,
classification ENUM('zugzwang','fork','zwischenzug','prophylaxis',
'gambit','overextension','tempo_loss') NOT NULL,
confidence_bucket ENUM('low','medium','high') NOT NULL,
reasoning VARCHAR(800) NOT NULL,
model_version VARCHAR(50) NOT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (entry_id) REFERENCES entries(id) ON DELETE CASCADE,
INDEX idx_classification (classification)
) ENGINE=InnoDB;