Datenbank-Schema

Erstellt: 2025-12-20 | Aktualisiert: 2025-12-31

Tabellenstruktur des KI-Task-Management Systems in der Datenbank ki_dev.

Datenbankki_dev
Tabellen4 (tasks, task_assignments, task_results, task_comments)
EngineInnoDB
Charsetutf8mb4_unicode_ci

tasks

Haupttabelle für alle Tasks.

SpalteTypBeschreibung
idBIGINT UNSIGNEDPrimary Key, Auto-Increment
uuidVARCHAR(36)Unique Identifier
titleVARCHAR(255)Titel des Tasks
descriptionTEXTBeschreibung
typeENUM'human_task', 'ai_task', 'mixed'
statusENUM'pending', 'in_progress', 'completed', 'failed', 'cancelled'
created_byVARCHAR(100)Ersteller
created_by_typeENUM'human', 'ai'
parent_task_idBIGINT UNSIGNEDFK zu übergeordnetem Task
due_dateDATETIMEFälligkeitsdatum
created_atDATETIME(6)Erstellungszeitpunkt
updated_atDATETIME(6)Letzte Änderung
completed_atDATETIME(6)Abschlusszeitpunkt
metadataJSONZusätzliche Daten

Indizes

PRIMARY KEY (id)
UNIQUE KEY uk_uuid (uuid)
KEY idx_status (status)
KEY idx_created_by (created_by)
KEY idx_type (type)
KEY idx_parent_task (parent_task_id)
KEY idx_created_at (created_at)
KEY idx_status_created (status, created_at)

task_assignments

Zuweisungen von Tasks an Bearbeiter.

SpalteTypBeschreibung
idBIGINT UNSIGNEDPrimary Key
task_idBIGINT UNSIGNEDFK zu tasks
assigneeVARCHAR(100)Bearbeiter-Name
assignee_typeENUM'human', 'ollama', 'claude', 'anthropic_api'
model_nameVARCHAR(100)KI-Model (z.B. mistral)
assigned_byVARCHAR(100)Zuweisender
assigned_by_typeENUM'human', 'ai'
statusENUM'pending', 'accepted', 'rejected', 'in_progress', 'completed'
assigned_atDATETIME(6)Zuweisungszeitpunkt
accepted_atDATETIME(6)Annahmezeitpunkt
completed_atDATETIME(6)Abschlusszeitpunkt
notesTEXTAnmerkungen zur Zuweisung

task_results

Ergebnisse von Task-Ausführungen mit Token-Tracking.

SpalteTypBeschreibung
idBIGINT UNSIGNEDPrimary Key
task_idBIGINT UNSIGNEDFK zu tasks
assignment_idBIGINT UNSIGNEDFK zu task_assignments
executorVARCHAR(100)Ausführender
executor_typeENUM'human', 'ollama', 'claude', 'anthropic_api'
model_nameVARCHAR(100)Verwendetes KI-Model
requestTEXTAnfrage/Prompt
responseLONGTEXTAntwort/Ergebnis
request_timestampDATETIME(6)Anfragezeitpunkt
response_timestampDATETIME(6)Antwortzeitpunkt
duration_msINT UNSIGNEDDauer in Millisekunden
tokens_inputINT UNSIGNEDInput-Tokens
tokens_outputINT UNSIGNEDOutput-Tokens
tokens_totalINT UNSIGNEDGesamt-Tokens
cost_usdDECIMAL(10,6)Kosten in USD
statusENUM'success', 'error', 'partial'
error_messageTEXTFehlermeldung bei Fehler
created_atDATETIME(6)Erstellungszeitpunkt

task_comments

Kommentare und Protokoll-Einträge zu Tasks.

SpalteTypBeschreibung
idBIGINT UNSIGNEDPrimary Key
task_idBIGINT UNSIGNEDFK zu tasks
authorVARCHAR(100)Autor
author_typeENUM'human', 'ai', 'system'
comment_typeENUM'comment', 'status_change', 'assignment', 'result', 'note'
contentTEXTInhalt
metadataJSONZusätzliche Daten
created_atDATETIME(6)Erstellungszeitpunkt

Abfragen

Letzte 10 Tasks

SELECT id, title, status, created_at
FROM tasks
ORDER BY id DESC
LIMIT 10;

Tasks nach Status

SELECT status, COUNT(*) as count
FROM tasks
GROUP BY status;

Token-Verbrauch pro Model

SELECT model_name,
       SUM(tokens_total) as total_tokens,
       SUM(cost_usd) as total_cost,
       COUNT(*) as executions
FROM task_results
WHERE model_name IS NOT NULL
GROUP BY model_name
ORDER BY total_tokens DESC;

Änderungshistorie

DatumÄnderung
2025-12-31Fehlende Felder ergänzt: task_assignments (assigned_at, accepted_at, completed_at, notes), task_results (10 Felder), task_comments (metadata, created_at)
2025-12-20Initial erstellt