Templates/Operations & logistics

Construction projects database schema

Projects on sites, contractors, tasks, change orders and inspections.

6 tables, 5 relationships

Opens as a new diagram you can change. Free.

Tables

construction_projects

  • iduuid not null
  • nametext not null
  • budgetnumeric(14,2) not null
  • starts_ondate not null
  • created_attimestamptz not null

sites

  • iduuid not null
  • project_id> construction_projectsuuid not null
  • addresstext not null
  • created_attimestamptz not null

contractors

  • iduuid not null
  • companytext not null
  • tradetext not null
  • phonetext
  • created_attimestamptz not null

project_tasks

  • iduuid not null
  • project_id> construction_projectsuuid not null
  • contractor_id> contractorsuuid
  • titletext not null
  • due_ondate
  • doneboolean not null
  • created_attimestamptz not null

change_orders

  • iduuid not null
  • project_id> construction_projectsuuid not null
  • descriptiontext not null
  • cost_deltanumeric(12,2) not null
  • approved_attimestamptz
  • created_attimestamptz not null

inspections

  • iduuid not null
  • site_id> sitesuuid not null
  • inspectortext not null
  • passedboolean not null
  • inspected_ondate 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 "change_orders" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "project_id" UUID NOT NULL,
  "description" TEXT NOT NULL,
  "cost_delta" NUMERIC(12,2) NOT NULL,
  "approved_at" TIMESTAMPTZ,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "construction_projects" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "name" TEXT NOT NULL,
  "budget" NUMERIC(14,2) NOT NULL,
  "starts_on" DATE NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "contractors" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "company" TEXT NOT NULL,
  "trade" TEXT NOT NULL,
  "phone" TEXT,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "inspections" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "site_id" UUID NOT NULL,
  "inspector" TEXT NOT NULL,
  "passed" BOOLEAN NOT NULL,
  "inspected_on" DATE NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "project_tasks" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "project_id" UUID NOT NULL,
  "contractor_id" UUID,
  "title" TEXT NOT NULL,
  "due_on" DATE,
  "done" BOOLEAN DEFAULT false NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "sites" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "project_id" UUID NOT NULL,
  "address" TEXT NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

ALTER TABLE "sites" ADD CONSTRAINT "fk_sites_project_id" FOREIGN KEY ("project_id") REFERENCES "construction_projects" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "project_tasks" ADD CONSTRAINT "fk_project_tasks_project_id" FOREIGN KEY ("project_id") REFERENCES "construction_projects" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "project_tasks" ADD CONSTRAINT "fk_project_tasks_contractor_id" FOREIGN KEY ("contractor_id") REFERENCES "contractors" ("id") ON DELETE SET NULL ON UPDATE NO ACTION;

ALTER TABLE "change_orders" ADD CONSTRAINT "fk_change_orders_project_id" FOREIGN KEY ("project_id") REFERENCES "construction_projects" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "inspections" ADD CONSTRAINT "fk_inspections_site_id" FOREIGN KEY ("site_id") REFERENCES "sites" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

More Operations & logistics templates

Start with one diagram, free

One diagram with two branches, no card needed. Upgrade when your team needs more.