Templates/Operations & logistics
Farm management database schema
Fields planted with crops, harvests, equipment and livestock.
7 tables, 6 relationships
Opens as a new diagram you can change. Free.
Tables
farms
- iduuid not null
- nametext not null
- hectaresnumeric(8,2) not null
- created_attimestamptz not null
fields
- iduuid not null
- farm_id> farmsuuid not null
- nametext not null
- hectaresnumeric(8,2) not null
- soil_typetext
- created_attimestamptz not null
crops
- iduuid not null
- nametext not null
- created_attimestamptz not null
plantings
- iduuid not null
- field_id> fieldsuuid not null
- crop_id> cropsuuid not null
- planted_ondate not null
- expected_harvest_ondate
- created_attimestamptz not null
harvests
- iduuid not null
- planting_id> plantingsuuid not null
- tonnesnumeric(8,2) not null
- harvested_ondate not null
- created_attimestamptz not null
equipment
- iduuid not null
- farm_id> farmsuuid not null
- nametext not null
- serviced_ondate
- created_attimestamptz not null
livestock
- iduuid not null
- farm_id> farmsuuid not null
- tagtext not null
- speciestext not null
- born_ondate
- 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 "crops" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"name" TEXT NOT NULL UNIQUE,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "equipment" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"farm_id" UUID NOT NULL,
"name" TEXT NOT NULL,
"serviced_on" DATE,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "farms" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"name" TEXT NOT NULL,
"hectares" NUMERIC(8,2) NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "fields" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"farm_id" UUID NOT NULL,
"name" TEXT NOT NULL,
"hectares" NUMERIC(8,2) NOT NULL,
"soil_type" TEXT,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "harvests" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"planting_id" UUID NOT NULL,
"tonnes" NUMERIC(8,2) NOT NULL,
"harvested_on" DATE NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "livestock" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"farm_id" UUID NOT NULL,
"tag" TEXT NOT NULL UNIQUE,
"species" TEXT NOT NULL,
"born_on" DATE,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "plantings" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"field_id" UUID NOT NULL,
"crop_id" UUID NOT NULL,
"planted_on" DATE NOT NULL,
"expected_harvest_on" DATE,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
ALTER TABLE "fields" ADD CONSTRAINT "fk_fields_farm_id" FOREIGN KEY ("farm_id") REFERENCES "farms" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "plantings" ADD CONSTRAINT "fk_plantings_field_id" FOREIGN KEY ("field_id") REFERENCES "fields" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "plantings" ADD CONSTRAINT "fk_plantings_crop_id" FOREIGN KEY ("crop_id") REFERENCES "crops" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "harvests" ADD CONSTRAINT "fk_harvests_planting_id" FOREIGN KEY ("planting_id") REFERENCES "plantings" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "equipment" ADD CONSTRAINT "fk_equipment_farm_id" FOREIGN KEY ("farm_id") REFERENCES "farms" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "livestock" ADD CONSTRAINT "fk_livestock_farm_id" FOREIGN KEY ("farm_id") REFERENCES "farms" ("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.
- 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.
- 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.