Fitness tracker database schema
Workouts made of exercises and sets, plus personal goals.
5 tables, 4 relationships
Opens as a new diagram you can change. Free.
Tables
athletes
- iduuid not null
- emailtext not null
- display_nametext not null
- created_attimestamptz not null
exercises
- iduuid not null
- nametext not null
- muscle_grouptext
- created_attimestamptz not null
workouts
- iduuid not null
- athlete_id> athletesuuid not null
- started_attimestamptz not null
- duration_minutesinteger
- notestext
- created_attimestamptz not null
workout_sets
- iduuid not null
- workout_id> workoutsuuid not null
- exercise_id> exercisesuuid not null
- repsinteger
- weight_kgnumeric(6,2)
- secondsinteger
- created_attimestamptz not null
goals
- iduuid not null
- athlete_id> athletesuuid not null
- descriptiontext not null
- target_ondate
- achieved_attimestamptz
- 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 "athletes" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"email" TEXT NOT NULL UNIQUE,
"display_name" TEXT NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "exercises" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"name" TEXT NOT NULL UNIQUE,
"muscle_group" TEXT,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "goals" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"athlete_id" UUID NOT NULL,
"description" TEXT NOT NULL,
"target_on" DATE,
"achieved_at" TIMESTAMPTZ,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "workout_sets" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"workout_id" UUID NOT NULL,
"exercise_id" UUID NOT NULL,
"reps" INTEGER,
"weight_kg" NUMERIC(6,2),
"seconds" INTEGER,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "workouts" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"athlete_id" UUID NOT NULL,
"started_at" TIMESTAMPTZ NOT NULL,
"duration_minutes" INTEGER,
"notes" TEXT,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
ALTER TABLE "workouts" ADD CONSTRAINT "fk_workouts_athlete_id" FOREIGN KEY ("athlete_id") REFERENCES "athletes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "workout_sets" ADD CONSTRAINT "fk_workout_sets_workout_id" FOREIGN KEY ("workout_id") REFERENCES "workouts" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "workout_sets" ADD CONSTRAINT "fk_workout_sets_exercise_id" FOREIGN KEY ("exercise_id") REFERENCES "exercises" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "goals" ADD CONSTRAINT "fk_goals_athlete_id" FOREIGN KEY ("athlete_id") REFERENCES "athletes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;More Health templates
- Clinic appointmentsPatients book practitioners at locations; visits get notes.
- Patient recordsEncounters with diagnoses, prescriptions, medications and allergies.
- PharmacyPrescriptions from prescribers, fills against stock and patient pickups.
- Gym membershipMembers on plans, scheduled classes with bookings, and door check-ins.
- Nutrition & meal planningFoods with nutrients, recipes, logged meals and daily targets.
- TelehealthVideo consultations between patients and clinicians, messages and payments.
- Laboratory resultsLab orders, collected samples, test panels and results with reference ranges.
- Therapy practiceClients and therapists, session bookings, private notes and assessments.
- Veterinary clinicOwners and their pets, vet appointments, treatments and vaccinations.
Start with one diagram, free
One diagram with two branches, no card needed. Upgrade when your team needs more.