School management database schema
Students and guardians, classes taught by teachers, grades and attendance.
8 tables, 7 relationships
Opens as a new diagram you can change. Free.
Tables
students
- iduuid not null
- full_nametext not null
- date_of_birthdate not null
- year_groupinteger not null
- created_attimestamptz not null
guardians
- iduuid not null
- full_nametext not null
- phonetext not null
- emailtext
- created_attimestamptz not null
student_guardians
- iduuid not null
- student_id> studentsuuid not null
- guardian_id> guardiansuuid not null
- relationshiptext not null
- created_attimestamptz not null
teachers
- iduuid not null
- full_nametext not null
- emailtext not null
- created_attimestamptz not null
classes
- iduuid not null
- teacher_id> teachersuuid not null
- subjecttext not null
- roomtext
- created_attimestamptz not null
class_enrollments
- iduuid not null
- class_id> classesuuid not null
- student_id> studentsuuid not null
- created_attimestamptz not null
grades
- iduuid not null
- enrollment_id> class_enrollmentsuuid not null
- assessmenttext not null
- scorenumeric(5,2) not null
- created_attimestamptz not null
attendance
- iduuid not null
- student_id> studentsuuid not null
- on_datedate not null
- presentboolean 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 TABLE "attendance" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"student_id" UUID NOT NULL,
"on_date" DATE NOT NULL,
"present" BOOLEAN NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "class_enrollments" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"class_id" UUID NOT NULL,
"student_id" UUID NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "classes" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"teacher_id" UUID NOT NULL,
"subject" TEXT NOT NULL,
"room" TEXT,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "grades" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"enrollment_id" UUID NOT NULL,
"assessment" TEXT NOT NULL,
"score" NUMERIC(5,2) NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "guardians" (
"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 "student_guardians" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"student_id" UUID NOT NULL,
"guardian_id" UUID NOT NULL,
"relationship" TEXT NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "students" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"full_name" TEXT NOT NULL,
"date_of_birth" DATE NOT NULL,
"year_group" INTEGER NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "teachers" (
"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")
);
ALTER TABLE "student_guardians" ADD CONSTRAINT "fk_student_guardians_student_id" FOREIGN KEY ("student_id") REFERENCES "students" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "student_guardians" ADD CONSTRAINT "fk_student_guardians_guardian_id" FOREIGN KEY ("guardian_id") REFERENCES "guardians" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "classes" ADD CONSTRAINT "fk_classes_teacher_id" FOREIGN KEY ("teacher_id") REFERENCES "teachers" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "class_enrollments" ADD CONSTRAINT "fk_class_enrollments_class_id" FOREIGN KEY ("class_id") REFERENCES "classes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "class_enrollments" ADD CONSTRAINT "fk_class_enrollments_student_id" FOREIGN KEY ("student_id") REFERENCES "students" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "grades" ADD CONSTRAINT "fk_grades_enrollment_id" FOREIGN KEY ("enrollment_id") REFERENCES "class_enrollments" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "attendance" ADD CONSTRAINT "fk_attendance_student_id" FOREIGN KEY ("student_id") REFERENCES "students" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;More Education templates
- Online coursesCourses of modules and lessons, enrolments, lesson progress and quizzes.
- University registrarDepartments, courses offered as sections each term, instructors and registrations.
- Quizzes & assessmentsQuizzes of multiple-choice questions, attempts and recorded answers.
- LibraryBooks with authors, physical copies, members, loans and holds.
- Tutoring marketplaceTutors teaching subjects, bookable lessons with students, and reviews.
- CertificationsCertification programmes with exams, candidate attempts and issued certificates.
- Language learningCourses by language, units of lessons and exercises, learner attempts and streaks.
- FlashcardsDecks of cards with spaced-repetition review history per learner.
- Nursery / childcareChildren in rooms with key staff, guardians, daily attendance and incident reports.
Start with one diagram, free
One diagram with two branches, no card needed. Upgrade when your team needs more.