Templates/Operations & logistics
Shipping & tracking database schema
Shipments of packages between addresses, carriers and tracking events.
5 tables, 5 relationships
Opens as a new diagram you can change. Free.
Tables
addresses
- iduuid not null
- nametext not null
- line1text not null
- citytext not null
- postcodetext not null
- countrytext not null
- created_attimestamptz not null
carriers
- iduuid not null
- nametext not null
- codetext not null
- created_attimestamptz not null
shipments
- iduuid not null
- carrier_id> carriersuuid not null
- from_address_id> addressesuuid not null
- to_address_id> addressesuuid not null
- servicetext not null
- statustext not null
- created_attimestamptz not null
packages
- iduuid not null
- shipment_id> shipmentsuuid not null
- tracking_numbertext not null
- weight_kgnumeric(6,2) not null
- created_attimestamptz not null
tracking_events
- iduuid not null
- package_id> packagesuuid not null
- statustext not null
- locationtext
- occurred_attimestamptz 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 "addresses" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"name" TEXT NOT NULL,
"line1" TEXT NOT NULL,
"city" TEXT NOT NULL,
"postcode" TEXT NOT NULL,
"country" TEXT NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "carriers" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"name" TEXT NOT NULL,
"code" TEXT NOT NULL UNIQUE,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "packages" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"shipment_id" UUID NOT NULL,
"tracking_number" TEXT NOT NULL UNIQUE,
"weight_kg" NUMERIC(6,2) NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "shipments" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"carrier_id" UUID NOT NULL,
"from_address_id" UUID NOT NULL,
"to_address_id" UUID NOT NULL,
"service" TEXT NOT NULL,
"status" TEXT DEFAULT 'created' NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "tracking_events" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"package_id" UUID NOT NULL,
"status" TEXT NOT NULL,
"location" TEXT,
"occurred_at" TIMESTAMPTZ NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
ALTER TABLE "shipments" ADD CONSTRAINT "fk_shipments_carrier_id" FOREIGN KEY ("carrier_id") REFERENCES "carriers" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "shipments" ADD CONSTRAINT "fk_shipments_from_address_id" FOREIGN KEY ("from_address_id") REFERENCES "addresses" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "shipments" ADD CONSTRAINT "fk_shipments_to_address_id" FOREIGN KEY ("to_address_id") REFERENCES "addresses" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "packages" ADD CONSTRAINT "fk_packages_shipment_id" FOREIGN KEY ("shipment_id") REFERENCES "shipments" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "tracking_events" ADD CONSTRAINT "fk_tracking_events_package_id" FOREIGN KEY ("package_id") REFERENCES "packages" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;More Operations & logistics templates
- Fleet managementVehicles and drivers, trips, maintenance records and fuel logs.
- ManufacturingProducts with bills of materials, work orders routed through machine operations.
- Field serviceCustomer sites, jobs dispatched to technicians, visits and parts used.
- 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.