Templates/Operations & logistics
Field service database schema
Customer sites, jobs dispatched to technicians, visits and parts used.
7 tables, 6 relationships
Opens as a new diagram you can change. Free.
Tables
customers
- iduuid not null
- nametext not null
- phonetext not null
- created_attimestamptz not null
sites
- iduuid not null
- customer_id> customersuuid not null
- addresstext not null
- access_notestext
- created_attimestamptz not null
technicians
- iduuid not null
- full_nametext not null
- skillstext[] not null
- created_attimestamptz not null
jobs
- iduuid not null
- site_id> sitesuuid not null
- summarytext not null
- prioritytext not null
- statustext not null
- created_attimestamptz not null
visits
- iduuid not null
- job_id> jobsuuid not null
- technician_id> techniciansuuid not null
- scheduled_attimestamptz not null
- completed_attimestamptz
- created_attimestamptz not null
parts
- iduuid not null
- skutext not null
- nametext not null
- pricenumeric(10,2) not null
- created_attimestamptz not null
visit_parts
- iduuid not null
- visit_id> visitsuuid not null
- part_id> partsuuid not null
- quantityinteger 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 "customers" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"name" TEXT NOT NULL,
"phone" TEXT NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "jobs" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"site_id" UUID NOT NULL,
"summary" TEXT NOT NULL,
"priority" TEXT DEFAULT 'normal' NOT NULL,
"status" TEXT DEFAULT 'new' NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "parts" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"sku" TEXT NOT NULL UNIQUE,
"name" TEXT NOT NULL,
"price" NUMERIC(10,2) NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "sites" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"customer_id" UUID NOT NULL,
"address" TEXT NOT NULL,
"access_notes" TEXT,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "technicians" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"full_name" TEXT NOT NULL,
"skills" TEXT[] NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "visit_parts" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"visit_id" UUID NOT NULL,
"part_id" UUID NOT NULL,
"quantity" INTEGER NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "visits" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"job_id" UUID NOT NULL,
"technician_id" UUID NOT NULL,
"scheduled_at" TIMESTAMPTZ NOT NULL,
"completed_at" TIMESTAMPTZ,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
ALTER TABLE "sites" ADD CONSTRAINT "fk_sites_customer_id" FOREIGN KEY ("customer_id") REFERENCES "customers" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "jobs" ADD CONSTRAINT "fk_jobs_site_id" FOREIGN KEY ("site_id") REFERENCES "sites" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "visits" ADD CONSTRAINT "fk_visits_job_id" FOREIGN KEY ("job_id") REFERENCES "jobs" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "visits" ADD CONSTRAINT "fk_visits_technician_id" FOREIGN KEY ("technician_id") REFERENCES "technicians" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "visit_parts" ADD CONSTRAINT "fk_visit_parts_visit_id" FOREIGN KEY ("visit_id") REFERENCES "visits" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "visit_parts" ADD CONSTRAINT "fk_visit_parts_part_id" FOREIGN KEY ("part_id") REFERENCES "parts" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;More Operations & logistics templates
- Fleet managementVehicles and drivers, trips, maintenance records and fuel logs.
- Shipping & trackingShipments of packages between addresses, carriers and tracking events.
- ManufacturingProducts with bills of materials, work orders routed through machine operations.
- IT asset managementHardware and licences assigned to employees, with a maintenance history.
- IoT telemetryDevices with sensors streaming readings, thresholds and alerts.
- Ride hailingRiders request trips, drivers with vehicles accept, then payments and ratings.
- ParkingCar parks with spaces, permits for vehicles and paid parking sessions.
- Construction projectsProjects on sites, contractors, tasks, change orders and inspections.
- Farm managementFields planted with crops, harvests, equipment and livestock.
- Sensor readings (Cassandra)Time series per device and day, newest first, with the latest reading kept in a table of its own.
Start with one diagram, free
One diagram with two branches, no card needed. Upgrade when your team needs more.