Personal budgeting database schema
Accounts, categorised transactions and monthly budgets per category.
5 tables, 6 relationships
Opens as a new diagram you can change. Free.
Tables
users
- iduuid not null
- emailtext not null
- created_attimestamptz not null
money_accounts
- iduuid not null
- user_id> usersuuid not null
- nametext not null
- kindtext not null
- balancenumeric(12,2) not null
- created_attimestamptz not null
categories
- iduuid not null
- user_id> usersuuid not null
- nametext not null
- parent_id> categoriesuuid
- created_attimestamptz not null
budgets
- iduuid not null
- category_id> categoriesuuid not null
- monthdate not null
- amountnumeric(12,2) not null
- created_attimestamptz not null
money_transactions
- iduuid not null
- account_id> money_accountsuuid not null
- category_id> categoriesuuid
- amountnumeric(12,2) not null
- payeetext not null
- occurred_ondate not null
- created_attimestamptz not null
As PostgreSQL
The same diagram exports to MySQL, MariaDB, SQLite, SQL Server and Oracle, and to Prisma, Drizzle, SQLAlchemy and Convex models.
CREATE TABLE "budgets" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"category_id" UUID NOT NULL,
"month" DATE NOT NULL,
"amount" NUMERIC(12,2) NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "categories" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"user_id" UUID NOT NULL,
"name" TEXT NOT NULL,
"parent_id" UUID,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "money_accounts" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"user_id" UUID NOT NULL,
"name" TEXT NOT NULL,
"kind" TEXT NOT NULL,
"balance" NUMERIC(12,2) DEFAULT 0 NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "money_transactions" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"account_id" UUID NOT NULL,
"category_id" UUID,
"amount" NUMERIC(12,2) NOT NULL,
"payee" TEXT NOT NULL,
"occurred_on" DATE NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "users" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"email" TEXT NOT NULL UNIQUE,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
ALTER TABLE "money_accounts" ADD CONSTRAINT "fk_money_accounts_user_id" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "categories" ADD CONSTRAINT "fk_categories_user_id" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "categories" ADD CONSTRAINT "fk_categories_parent_id" FOREIGN KEY ("parent_id") REFERENCES "categories" ("id") ON DELETE SET NULL ON UPDATE NO ACTION;
ALTER TABLE "budgets" ADD CONSTRAINT "fk_budgets_category_id" FOREIGN KEY ("category_id") REFERENCES "categories" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "money_transactions" ADD CONSTRAINT "fk_money_transactions_account_id" FOREIGN KEY ("account_id") REFERENCES "money_accounts" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "money_transactions" ADD CONSTRAINT "fk_money_transactions_category_id" FOREIGN KEY ("category_id") REFERENCES "categories" ("id") ON DELETE SET NULL ON UPDATE NO ACTION;More Finance templates
- Double-entry accountingChart of accounts, journals and balanced journal entries per period.
- Banking coreCustomers, accounts, cards, transactions and transfers between accounts.
- Expense managementEmployees submit expense reports with receipts for policy checks and approval.
- InvoicingClients, invoices with line items and tax rates, and payments received.
- Crypto walletUsers' wallets holding balances in assets, with on-chain transactions.
- Loan servicingBorrowers, loan products, loans with repayment schedules and payments.
- Insurance policiesPolicyholders, products, policies with coverages, premiums and claims.
- PayrollPay periods, payslips with earnings and deduction lines per employee.
- CrowdfundingCampaigns with reward tiers, backers' pledges and creator updates.
Start with one diagram, free
One diagram with two branches, no card needed. Upgrade when your team needs more.