Templates/Health

Veterinary clinic database schema

Owners and their pets, vet appointments, treatments and vaccinations.

6 tables, 5 relationships

Opens as a new diagram you can change. Free.

Tables

owners

  • iduuid not null
  • full_nametext not null
  • phonetext not null
  • emailtext
  • created_attimestamptz not null

pets

  • iduuid not null
  • owner_id> ownersuuid not null
  • nametext not null
  • speciestext not null
  • breedtext
  • born_ondate
  • created_attimestamptz not null

vets

  • iduuid not null
  • full_nametext not null
  • created_attimestamptz not null

vet_appointments

  • iduuid not null
  • pet_id> petsuuid not null
  • vet_id> vetsuuid not null
  • starts_attimestamptz not null
  • reasontext not null
  • created_attimestamptz not null

treatments

  • iduuid not null
  • appointment_id> vet_appointmentsuuid not null
  • descriptiontext not null
  • costnumeric(8,2) not null
  • created_attimestamptz not null

vaccinations

  • iduuid not null
  • pet_id> petsuuid not null
  • vaccinetext not null
  • given_ondate not null
  • due_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 "owners" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "full_name" TEXT NOT NULL,
  "phone" TEXT NOT NULL,
  "email" TEXT,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "pets" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "owner_id" UUID NOT NULL,
  "name" TEXT NOT NULL,
  "species" TEXT NOT NULL,
  "breed" TEXT,
  "born_on" DATE,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "treatments" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "appointment_id" UUID NOT NULL,
  "description" TEXT NOT NULL,
  "cost" NUMERIC(8,2) NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "vaccinations" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "pet_id" UUID NOT NULL,
  "vaccine" TEXT NOT NULL,
  "given_on" DATE NOT NULL,
  "due_on" DATE,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "vet_appointments" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "pet_id" UUID NOT NULL,
  "vet_id" UUID NOT NULL,
  "starts_at" TIMESTAMPTZ NOT NULL,
  "reason" TEXT NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "vets" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "full_name" TEXT NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

ALTER TABLE "pets" ADD CONSTRAINT "fk_pets_owner_id" FOREIGN KEY ("owner_id") REFERENCES "owners" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "vet_appointments" ADD CONSTRAINT "fk_vet_appointments_pet_id" FOREIGN KEY ("pet_id") REFERENCES "pets" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "vet_appointments" ADD CONSTRAINT "fk_vet_appointments_vet_id" FOREIGN KEY ("vet_id") REFERENCES "vets" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE "treatments" ADD CONSTRAINT "fk_treatments_appointment_id" FOREIGN KEY ("appointment_id") REFERENCES "vet_appointments" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "vaccinations" ADD CONSTRAINT "fk_vaccinations_pet_id" FOREIGN KEY ("pet_id") REFERENCES "pets" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

More Health templates

Start with one diagram, free

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