iafisher / drill

Spaced-repetition quizzes on the command line
MIT License
2 stars 0 forks source link

Use SQLite database instead of custom format/JSON #96

Open iafisher opened 3 years ago

iafisher commented 3 years ago

This would let me combine the quiz files, which use a custom format, and the results files, which are in JSON, into a single file, and a ton of logic devoted to parsing the custom format could be deleted.

The downside is that I would have to write tools to be able to view and edit the quizzes. I think drill --list to print out the quiz, drill --edit <id> to edit a question, drill --add to add a question, and drill --delete <id> would be sufficient.

iafisher commented 3 years ago

Proposed schema:

CREATE TABLE quizzes(
  id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  name TEXT UNIQUE NOT NULL CHECK(name != ''),
);

CREATE TABLE questions(
  id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  quiz INTEGER NOT NULL REFERENCES quizzes,
  text TEXT NOT NULL CHECK(text != ''),
  ordered BOOLEAN NOT NULL DEFAULT 0,
);

CREATE TABLE answers(
  question INTEGER NOT NULL REFERENCES questions,
  text TEXT NOT NULL CHECK(text != ''),
  correct BOOLEAN NOT NULL DEFAULT 1,
  no_credit BOOLEAN NOT NULL DEFAULT 0,
);

Each table will also have a created_at column.

iafisher commented 3 years ago

I should also have a drill_version singleton table to make backwards compatibility easier.