I already loved your writing, but I never would have predicted that anyone else (besides me) was trying to put spaced repetition algorithms into SQL.
I've been in touch with the guys making Open Spaced Repetition: https://github.com/open-spaced-repetition
... specifically the Free Spaced Repetition Scheduler (FSRS), of which they recommended if we're going to copy one of the implementations it should be the TypeScript one, since that's the best documented: https://github.com/open-spaced-repetition/ts-fsrs + https://open-spaced-repetition.github.io/ts-fsrs/
I've been working on it the last few days and was working on it this morning, then I saw this/your post on HN. Jaw dropped.
I always enjoy making things from scratch as a way of getting to know them, but in this case it seems wise (and a bit of a new experience for me) to copy someone else's open source work and try to do a real implementation of the FSRS-5 scheduler in PostgreSQL PL/pgSQL functions.
Then cards and their data-logic can stay together in one place, and anyone can use whatever language they want for UI/API.