Tagly
Fifty-table schema
Designed Tagly's whole database, from accounts to the ledger and the job queues. The database has 50 tables and runs on RDS. Job queues live in their own schema, apart from the money and account data that has to last. Prisma handles the schema and ordinary queries, and Kysely handles the queries an ORM can't express. A few of the design decisions:
- Half-finished sign-ups live in separate pending tables. A real customer row only exists once it has a name, a verified email and a signed agreement. Abandoned sign-ups are deleted on a schedule without touching real accounts.
- Money is stored in whole cents and multipliers in basis points, so important data never uses a float. Balances are built per currency, so supporting a new currency means adding a column, not converting data.
- Important data is never denormalised. Lifetime spend, and which balance paid for a post, are both derived from the ledger.
- Public uids are random and start with a prefix that says what kind of record they belong to. Internal ids stay plain integers.