Templates/Work & productivity

OKRs & goals database schema

Teams set objectives with measurable key results and regular check-ins.

6 tables, 8 relationships

Opens as a new diagram you can change. Free.

Tables

teams

  • iduuid not null
  • nametext not null
  • parent_id> teamsuuid
  • created_attimestamptz not null

people

  • iduuid not null
  • nametext not null
  • team_id> teamsuuid
  • created_attimestamptz not null

cycles

  • iduuid not null
  • nametext not null
  • starts_ondate not null
  • ends_ondate not null
  • created_attimestamptz not null

objectives

  • iduuid not null
  • cycle_id> cyclesuuid not null
  • team_id> teamsuuid not null
  • owner_id> peopleuuid not null
  • titletext not null
  • created_attimestamptz not null

key_results

  • iduuid not null
  • objective_id> objectivesuuid not null
  • titletext not null
  • start_valuenumeric not null
  • target_valuenumeric not null
  • current_valuenumeric not null
  • created_attimestamptz not null

check_ins

  • iduuid not null
  • key_result_id> key_resultsuuid not null
  • author_id> peopleuuid not null
  • valuenumeric not null
  • confidenceinteger not null
  • notetext
  • 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 "check_ins" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "key_result_id" UUID NOT NULL,
  "author_id" UUID NOT NULL,
  "value" NUMERIC NOT NULL,
  "confidence" INTEGER NOT NULL,
  "note" TEXT,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "cycles" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "name" TEXT NOT NULL,
  "starts_on" DATE NOT NULL,
  "ends_on" DATE NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "key_results" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "objective_id" UUID NOT NULL,
  "title" TEXT NOT NULL,
  "start_value" NUMERIC NOT NULL,
  "target_value" NUMERIC NOT NULL,
  "current_value" NUMERIC NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "objectives" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "cycle_id" UUID NOT NULL,
  "team_id" UUID NOT NULL,
  "owner_id" UUID NOT NULL,
  "title" TEXT NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "people" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "name" TEXT NOT NULL,
  "team_id" UUID,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "teams" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "name" TEXT NOT NULL,
  "parent_id" UUID,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

ALTER TABLE "teams" ADD CONSTRAINT "fk_teams_parent_id" FOREIGN KEY ("parent_id") REFERENCES "teams" ("id") ON DELETE SET NULL ON UPDATE NO ACTION;

ALTER TABLE "people" ADD CONSTRAINT "fk_people_team_id" FOREIGN KEY ("team_id") REFERENCES "teams" ("id") ON DELETE SET NULL ON UPDATE NO ACTION;

ALTER TABLE "objectives" ADD CONSTRAINT "fk_objectives_cycle_id" FOREIGN KEY ("cycle_id") REFERENCES "cycles" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE "objectives" ADD CONSTRAINT "fk_objectives_team_id" FOREIGN KEY ("team_id") REFERENCES "teams" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE "objectives" ADD CONSTRAINT "fk_objectives_owner_id" FOREIGN KEY ("owner_id") REFERENCES "people" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE "key_results" ADD CONSTRAINT "fk_key_results_objective_id" FOREIGN KEY ("objective_id") REFERENCES "objectives" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "check_ins" ADD CONSTRAINT "fk_check_ins_key_result_id" FOREIGN KEY ("key_result_id") REFERENCES "key_results" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "check_ins" ADD CONSTRAINT "fk_check_ins_author_id" FOREIGN KEY ("author_id") REFERENCES "people" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

More Work & productivity templates

Start with one diagram, free

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