Templates/Education

Tutoring marketplace database schema

Tutors teaching subjects, bookable lessons with students, and reviews.

6 tables, 6 relationships

Opens as a new diagram you can change. Free.

Tables

tutors

  • iduuid not null
  • full_nametext not null
  • hourly_ratenumeric(8,2) not null
  • biotext
  • created_attimestamptz not null

subjects

  • iduuid not null
  • nametext not null
  • created_attimestamptz not null

tutor_subjects

  • iduuid not null
  • tutor_id> tutorsuuid not null
  • subject_id> subjectsuuid not null
  • leveltext not null
  • created_attimestamptz not null

students

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

tutoring_sessions

  • iduuid not null
  • tutor_id> tutorsuuid not null
  • student_id> studentsuuid not null
  • subject_id> subjectsuuid not null
  • starts_attimestamptz not null
  • minutesinteger not null
  • created_attimestamptz not null

tutor_reviews

  • iduuid not null
  • session_id> tutoring_sessionsuuid not null
  • ratinginteger not null
  • commenttext
  • 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 "students" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "full_name" TEXT NOT NULL,
  "email" TEXT NOT NULL UNIQUE,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "subjects" (
  "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 "tutor_reviews" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "session_id" UUID NOT NULL UNIQUE,
  "rating" INTEGER NOT NULL,
  "comment" TEXT,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "tutor_subjects" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "tutor_id" UUID NOT NULL,
  "subject_id" UUID NOT NULL,
  "level" TEXT NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "tutoring_sessions" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "tutor_id" UUID NOT NULL,
  "student_id" UUID NOT NULL,
  "subject_id" UUID NOT NULL,
  "starts_at" TIMESTAMPTZ NOT NULL,
  "minutes" INTEGER NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "tutors" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "full_name" TEXT NOT NULL,
  "hourly_rate" NUMERIC(8,2) NOT NULL,
  "bio" TEXT,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

ALTER TABLE "tutor_subjects" ADD CONSTRAINT "fk_tutor_subjects_tutor_id" FOREIGN KEY ("tutor_id") REFERENCES "tutors" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "tutor_subjects" ADD CONSTRAINT "fk_tutor_subjects_subject_id" FOREIGN KEY ("subject_id") REFERENCES "subjects" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "tutoring_sessions" ADD CONSTRAINT "fk_tutoring_sessions_tutor_id" FOREIGN KEY ("tutor_id") REFERENCES "tutors" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE "tutoring_sessions" ADD CONSTRAINT "fk_tutoring_sessions_student_id" FOREIGN KEY ("student_id") REFERENCES "students" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE "tutoring_sessions" ADD CONSTRAINT "fk_tutoring_sessions_subject_id" FOREIGN KEY ("subject_id") REFERENCES "subjects" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE "tutor_reviews" ADD CONSTRAINT "fk_tutor_reviews_session_id" FOREIGN KEY ("session_id") REFERENCES "tutoring_sessions" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

More Education templates

Start with one diagram, free

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