Templates/Social & community

Mentorship programme database schema

Programmes matching mentors with mentees, sessions and feedback.

5 tables, 6 relationships

Opens as a new diagram you can change. Free.

Tables

people

  • iduuid not null
  • nametext not null
  • emailtext not null
  • biotext
  • created_attimestamptz not null

programs

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

mentor_matches

  • iduuid not null
  • program_id> programsuuid not null
  • mentor_id> peopleuuid not null
  • mentee_id> peopleuuid not null
  • goalstext
  • created_attimestamptz not null

mentor_sessions

  • iduuid not null
  • match_id> mentor_matchesuuid not null
  • scheduled_attimestamptz not null
  • notestext
  • created_attimestamptz not null

session_feedback

  • iduuid not null
  • session_id> mentor_sessionsuuid not null
  • author_id> peopleuuid 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 "mentor_matches" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "program_id" UUID NOT NULL,
  "mentor_id" UUID NOT NULL,
  "mentee_id" UUID NOT NULL,
  "goals" TEXT,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "mentor_sessions" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "match_id" UUID NOT NULL,
  "scheduled_at" TIMESTAMPTZ NOT NULL,
  "notes" TEXT,
  "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,
  "email" TEXT NOT NULL UNIQUE,
  "bio" TEXT,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

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

CREATE TABLE "session_feedback" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "session_id" UUID NOT NULL,
  "author_id" UUID NOT NULL,
  "rating" INTEGER NOT NULL,
  "comment" TEXT,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

ALTER TABLE "mentor_matches" ADD CONSTRAINT "fk_mentor_matches_program_id" FOREIGN KEY ("program_id") REFERENCES "programs" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "mentor_matches" ADD CONSTRAINT "fk_mentor_matches_mentor_id" FOREIGN KEY ("mentor_id") REFERENCES "people" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE "mentor_matches" ADD CONSTRAINT "fk_mentor_matches_mentee_id" FOREIGN KEY ("mentee_id") REFERENCES "people" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE "mentor_sessions" ADD CONSTRAINT "fk_mentor_sessions_match_id" FOREIGN KEY ("match_id") REFERENCES "mentor_matches" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "session_feedback" ADD CONSTRAINT "fk_session_feedback_session_id" FOREIGN KEY ("session_id") REFERENCES "mentor_sessions" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

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

More Social & community templates

Start with one diagram, free

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