Loan servicing database schema
Borrowers, loan products, loans with repayment schedules and payments.
5 tables, 4 relationships
Opens as a new diagram you can change. Free.
Tables
borrowers
- iduuid not null
- full_nametext not null
- emailtext not null
- credit_scoreinteger
- created_attimestamptz not null
loan_products
- iduuid not null
- nametext not null
- annual_ratenumeric(5,2) not null
- term_monthsinteger not null
- created_attimestamptz not null
loans
- iduuid not null
- borrower_id> borrowersuuid not null
- product_id> loan_productsuuid not null
- principalnumeric(14,2) not null
- disbursed_ondate
- statustext not null
- created_attimestamptz not null
repayment_schedule
- iduuid not null
- loan_id> loansuuid not null
- due_ondate not null
- principal_duenumeric(14,2) not null
- interest_duenumeric(14,2) not null
- created_attimestamptz not null
loan_payments
- iduuid not null
- loan_id> loansuuid not null
- amountnumeric(14,2) not null
- paid_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 "borrowers" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"full_name" TEXT NOT NULL,
"email" TEXT NOT NULL UNIQUE,
"credit_score" INTEGER,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "loan_payments" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"loan_id" UUID NOT NULL,
"amount" NUMERIC(14,2) NOT NULL,
"paid_on" DATE NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "loan_products" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"name" TEXT NOT NULL,
"annual_rate" NUMERIC(5,2) NOT NULL,
"term_months" INTEGER NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "loans" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"borrower_id" UUID NOT NULL,
"product_id" UUID NOT NULL,
"principal" NUMERIC(14,2) NOT NULL,
"disbursed_on" DATE,
"status" TEXT DEFAULT 'applied' NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "repayment_schedule" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"loan_id" UUID NOT NULL,
"due_on" DATE NOT NULL,
"principal_due" NUMERIC(14,2) NOT NULL,
"interest_due" NUMERIC(14,2) NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
ALTER TABLE "loans" ADD CONSTRAINT "fk_loans_borrower_id" FOREIGN KEY ("borrower_id") REFERENCES "borrowers" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "loans" ADD CONSTRAINT "fk_loans_product_id" FOREIGN KEY ("product_id") REFERENCES "loan_products" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "repayment_schedule" ADD CONSTRAINT "fk_repayment_schedule_loan_id" FOREIGN KEY ("loan_id") REFERENCES "loans" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "loan_payments" ADD CONSTRAINT "fk_loan_payments_loan_id" FOREIGN KEY ("loan_id") REFERENCES "loans" ("id") ON DELETE NO ACTION 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.
- Personal budgetingAccounts, categorised transactions and monthly budgets per category.
- Crypto walletUsers' wallets holding balances in assets, with on-chain transactions.
- 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.