Templates/Operations & logistics
Manufacturing database schema
Products with bills of materials, work orders routed through machine operations.
6 tables, 6 relationships
Opens as a new diagram you can change. Free.
Tables
items
- iduuid not null
- skutext not null
- nametext not null
- kindtext not null
- created_attimestamptz not null
bom_lines
- iduuid not null
- parent_item_id> itemsuuid not null
- component_item_id> itemsuuid not null
- quantitynumeric(10,3) not null
- created_attimestamptz not null
machines
- iduuid not null
- nametext not null
- work_centretext not null
- created_attimestamptz not null
work_orders
- iduuid not null
- item_id> itemsuuid not null
- quantityinteger not null
- due_ondate not null
- statustext not null
- created_attimestamptz not null
operations
- iduuid not null
- work_order_id> work_ordersuuid not null
- machine_id> machinesuuid not null
- sequenceinteger not null
- minutesinteger not null
- created_attimestamptz not null
production_logs
- iduuid not null
- operation_id> operationsuuid not null
- good_quantityinteger not null
- scrap_quantityinteger not null
- logged_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 "bom_lines" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"parent_item_id" UUID NOT NULL,
"component_item_id" UUID NOT NULL,
"quantity" NUMERIC(10,3) NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "items" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"sku" TEXT NOT NULL UNIQUE,
"name" TEXT NOT NULL,
"kind" TEXT NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "machines" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"name" TEXT NOT NULL,
"work_centre" TEXT NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "operations" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"work_order_id" UUID NOT NULL,
"machine_id" UUID NOT NULL,
"sequence" INTEGER NOT NULL,
"minutes" INTEGER NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "production_logs" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"operation_id" UUID NOT NULL,
"good_quantity" INTEGER NOT NULL,
"scrap_quantity" INTEGER DEFAULT 0 NOT NULL,
"logged_at" TIMESTAMPTZ NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "work_orders" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"item_id" UUID NOT NULL,
"quantity" INTEGER NOT NULL,
"due_on" DATE NOT NULL,
"status" TEXT DEFAULT 'planned' NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
ALTER TABLE "bom_lines" ADD CONSTRAINT "fk_bom_lines_parent_item_id" FOREIGN KEY ("parent_item_id") REFERENCES "items" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "bom_lines" ADD CONSTRAINT "fk_bom_lines_component_item_id" FOREIGN KEY ("component_item_id") REFERENCES "items" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "work_orders" ADD CONSTRAINT "fk_work_orders_item_id" FOREIGN KEY ("item_id") REFERENCES "items" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "operations" ADD CONSTRAINT "fk_operations_work_order_id" FOREIGN KEY ("work_order_id") REFERENCES "work_orders" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "operations" ADD CONSTRAINT "fk_operations_machine_id" FOREIGN KEY ("machine_id") REFERENCES "machines" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "production_logs" ADD CONSTRAINT "fk_production_logs_operation_id" FOREIGN KEY ("operation_id") REFERENCES "operations" ("id") ON DELETE CASCADE 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.
- 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.