Model the learning record
Translate product behavior into entities and relationships.
17 minutes
Name what you store
A minimal learning platform has users, lessons and progress. Each progress row connects one user to one lesson, with status and timestamps. Stable lesson IDs allow titles to change without erasing a learner’s history.
Enforce the rule where data lives
A unique constraint on user_id and lesson_id prevents duplicate progress rows. The database should protect this invariant even if two tabs save simultaneously. UI checks help usability but cannot enforce a rule across concurrent requests.
sql
CREATE TABLE progress (
user_id TEXT NOT NULL,
lesson_id TEXT NOT NULL,
completed_at TEXT,
PRIMARY KEY (user_id, lesson_id)
);