Help desk database schema
Customer tickets, threaded messages, agents, SLA policies and tags.
7 tables, 7 relationships
Opens as a new diagram you can change. Free.
Tables
customers
- iduuid not null
- emailtext not null
- nametext not null
- created_attimestamptz not null
agents
- iduuid not null
- emailtext not null
- nametext not null
- created_attimestamptz not null
sla_policies
- iduuid not null
- nametext not null
- first_response_minutesinteger not null
- resolution_minutesinteger not null
- created_attimestamptz not null
tickets
- iduuid not null
- customer_id> customersuuid not null
- assignee_id> agentsuuid
- sla_policy_id> sla_policiesuuid
- subjecttext not null
- statusticket_status not null
- prioritytext not null
- created_attimestamptz not null
ticket_messages
- iduuid not null
- ticket_id> ticketsuuid not null
- agent_id> agentsuuid
- bodytext not null
- internalboolean not null
- created_attimestamptz not null
tags
- iduuid not null
- nametext not null
- created_attimestamptz not null
ticket_tags
- iduuid not null
- ticket_id> ticketsuuid not null
- tag_id> tagsuuid 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 TYPE "ticket_status" AS ENUM ('open', 'pending', 'solved', 'closed');
CREATE TABLE "agents" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"email" TEXT NOT NULL UNIQUE,
"name" TEXT NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "customers" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"email" TEXT NOT NULL UNIQUE,
"name" TEXT NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "sla_policies" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"name" TEXT NOT NULL,
"first_response_minutes" INTEGER NOT NULL,
"resolution_minutes" INTEGER NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "tags" (
"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 "ticket_messages" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"ticket_id" UUID NOT NULL,
"agent_id" UUID,
"body" TEXT NOT NULL,
"internal" BOOLEAN DEFAULT false NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "ticket_tags" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"ticket_id" UUID NOT NULL,
"tag_id" UUID NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "tickets" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"customer_id" UUID NOT NULL,
"assignee_id" UUID,
"sla_policy_id" UUID,
"subject" TEXT NOT NULL,
"status" "ticket_status" DEFAULT 'open' NOT NULL,
"priority" TEXT DEFAULT 'normal' NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
ALTER TABLE "tickets" ADD CONSTRAINT "fk_tickets_customer_id" FOREIGN KEY ("customer_id") REFERENCES "customers" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "tickets" ADD CONSTRAINT "fk_tickets_assignee_id" FOREIGN KEY ("assignee_id") REFERENCES "agents" ("id") ON DELETE SET NULL ON UPDATE NO ACTION;
ALTER TABLE "tickets" ADD CONSTRAINT "fk_tickets_sla_policy_id" FOREIGN KEY ("sla_policy_id") REFERENCES "sla_policies" ("id") ON DELETE SET NULL ON UPDATE NO ACTION;
ALTER TABLE "ticket_messages" ADD CONSTRAINT "fk_ticket_messages_ticket_id" FOREIGN KEY ("ticket_id") REFERENCES "tickets" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "ticket_messages" ADD CONSTRAINT "fk_ticket_messages_agent_id" FOREIGN KEY ("agent_id") REFERENCES "agents" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "ticket_tags" ADD CONSTRAINT "fk_ticket_tags_ticket_id" FOREIGN KEY ("ticket_id") REFERENCES "tickets" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "ticket_tags" ADD CONSTRAINT "fk_ticket_tags_tag_id" FOREIGN KEY ("tag_id") REFERENCES "tags" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;More Work & productivity templates
- Projects & tasksWorkspaces, projects and tasks with assignees, labels and comments.
- Kanban boardBoards with columns of cards, members and checklists.
- CRMCompanies, contacts, deals moving through pipeline stages, and activities.
- HR & peopleEmployees in departments and positions, reporting lines, leave and salary history.
- Applicant trackingJob openings, candidates, applications through stages, interviews and scorecards.
- Time trackingClients, projects and tasks with time entries that bill into invoices.
- Calendar & schedulingCalendars, events with attendees, recurrence rules and reminders.
- OKRs & goalsTeams set objectives with measurable key results and regular check-ins.
- Document e-signatureDocuments sent to signers, signature fields, signatures and an audit trail.
- Task lists (Firestore)Workspaces, their projects and tasks, with due-date queries indexed and finished tasks expiring.
Start with one diagram, free
One diagram with two branches, no card needed. Upgrade when your team needs more.