SaaS database schemas

Tenancy, roles, plans and metering. The shape that matters here is the tenant id on every row and a membership table between users and workspaces, because both are almost impossible to retrofit later. Every one opens in the free drawDB editor in a click, and is public domain.

6 schemas here, from 10 to 13 tables (73 tables and 614 columns in total), written for PostgreSQL. Each one ships an ER diagram you can open and edit, a column-by-column reference, design notes explaining the trade-offs, and SQL for all six dialects. Recurring themes across the set: analytics, billing.

PostgreSQL
SaaS

A/B testing & experimentation platform schema

An experimentation platform end to end: experiments and weighted variants, deterministic hash bucketing, exposure events, metric definitions, per-variant aggregates with sufficient statistics, significance results and staged rollout.

PostgreSQL
SaaS

Product analytics platform database schema

How a product analytics service stores its data: projects and a discovered event registry, raw events with JSONB properties, anonymous and identified users with identity merges, sessions, funnels, cohorts, retention reports and precomputed metric snapshots.

PostgreSQL
SaaS

Email marketing & campaign database schema

How a campaign sender stores its data: lists and contacts with custom fields, rule-based segments, campaigns with A/B variants, one send row per recipient, opens and clicks, bounces and suppressions, and drip automations.

PostgreSQL
SaaS

Help desk & customer support ticketing schema

A support desk modelled properly: tickets in queues, one thread that mixes public replies with internal notes, SLA clocks measured in business hours with breach tracking, macros, tags, merges and CSAT.

PostgreSQL
SaaS

Multi-tenant SaaS database schema

Shared-database multi-tenancy done properly: organizations as tenants, global users joined through memberships, invitations, scoped API keys, plans, subscriptions, metered usage and an append-only audit log.

PostgreSQL
SaaS

Usage-based & metered billing database schema

Metered billing modelled properly: price plans built from components, tiered and volume and graduated pricing as rows, meters and raw usage, per-period aggregation, invoices with line items, prepaid credits, proration and dunning.

other categories