feat: add SQLite database schema and documentation #2

Merged
koval merged 4 commits from feature/db-schema into master 2026-08-21 13:50:38 +02:00
3 changed files with 51 additions and 0 deletions

18
.gitignore vendored Normal file
View file

@ -0,0 +1,18 @@
/bin/
/vendor/
*.exe
*.exe~
*.dll
*.so
*.dylib
*.test
*.out
/storage/*.db
/storage/*.db-journal
.env
.idea/
.vscode/
*.swp
*.swo
.DS_Store

View file

@ -1 +1,9 @@
# PieVR
## Database Schema & Core Concepts
- **Storage:** SQLite (`storage/` directory, ignored in `.gitignore`).
- **Tables:**
- `questions`: stores core question data (`id`, `type`, `question_text`, `payload` as JSON, `active`, `last_asked_at`, `streak`, `times_asked`, `times_correct`, `created_at`).
- `tags`: tags for granular and cross-cutting topic selection (`id`, `name`).
- `question_tags`: many-to-many relationship between questions and tags.
- **Priority & Spaced Repetition:** No hardcoded calendar intervals. Priorities and scheduling metrics are stored as raw counters (`streak`, `times_asked`, `last_asked_at`) in the database, while complex priority/decay formulas are calculated dynamically on the fly in Go.

View file

@ -0,0 +1,25 @@
-- PieVR Database Schema
CREATE TABLE IF NOT EXISTS questions (
id INTEGER PRIMARY KEY AUTOINCREMENT,
type TEXT NOT NULL,
question_text TEXT NOT NULL,
payload TEXT NOT NULL,
active BOOLEAN DEFAULT 1,
last_asked_at DATETIME,
streak INTEGER DEFAULT 0,
times_asked INTEGER DEFAULT 0,
times_correct INTEGER DEFAULT 0,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS tags (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT UNIQUE NOT NULL
);
CREATE TABLE IF NOT EXISTS question_tags (
question_id INTEGER REFERENCES questions(id) ON DELETE CASCADE,
tag_id INTEGER REFERENCES tags(id) ON DELETE CASCADE,
PRIMARY KEY (question_id, tag_id)
);