Student Information System ER diagram and database schema

The Student Information System database schema is a DB Planner template with 28 tables, 175 columns and 46 relationships, free to use. Core tables include account_charges, account_payments, advisor_assignments, assessment_scores. It can be opened as an interactive ER diagram or exported as PostgreSQL, MySQL, or SQL Server DDL.

ER diagram of the Student Information System database schema, showing 28 tables and their relationships
FIG. 1: entity relationship diagram, 28 tables
Tables
28
Columns
175
Relationships
46
Category
Education
Exports
DBML, SQL, Prisma, C#
Price
Free

What this schema models

A complete student information system (SIS) database design for a college or university: 28 tables, 18 enums and 46 relationships covering terms and rooms, degree programs and the course catalog, sections and meeting times, registration with waitlists, the gradebook and final grades, attendance, degrees, advising, registration holds, and student accounts with financial aid. THE FOUR DESIGN RULES 1. A COURSE is not a SECTION. courses is the catalog entry (what CS 101 is); sections are one run of it in one term, with their own instructors, rooms and capacity. Students enroll in sections. 2. Enrollment is a status, not a delete. Dropping or withdrawing changes the row's status; the row stays, which is what puts a W on the transcript. 3. Final grades are append-only. A grade change is a new row that supersedes the old one, with who changed it and why. GPA is computed from the latest grade per enrollment, never stored. 4. Requirements follow the catalog year. A student's program is pinned to the term they declared it, and degree requirements are versioned, so a curriculum change never moves the goalposts for students already in it. DETAILS WORTH STEALING - Term deadlines (add/drop, withdrawal) live on the term row, so enrollment rules read data rather than hard-coded dates. - The grading scale is a table, so pass/fail, incompletes and GPA policy are configuration. - Prerequisites carry a minimum grade and a corequisite flag. - Holds say exactly what they block, registration or transcripts, and are released rather than deleted. - Student accounts are a ledger of charges, payments and disbursed aid; the balance is a sum, not a column. - Preferred name is shown in class rosters, while the legal name stays on official documents. WHAT YOU GET Clean DBML that imports directly into DB Planner, and a laid-out board with zones color-coded and framed: institution, course catalog, scheduling and faculty, enrollment and gradebook, grades and degrees, students, and student accounts. Every table carries a note. Postgres-flavoured types that port cleanly to MySQL or SQL Server. Useful for developers building an SIS, LMS or registration system, and for students who need a realistic student management system ER diagram for a DBMS project. This is a schema design reference; validate it against your institution's policies and privacy obligations (such as FERPA) before production use.

Tables (28)

Every table and its columns

departments

Academic departments. Own courses, programs and faculty appointments.

Columns of the departments table
ColumnTypeConstraintsReferencesDescription
iduuidPK
codevarchar(10)unique, not nulle.g. CS, MATH, HIST
namevarchar(200)not null

terms

Academic terms. Every deadline enrollment rules check against lives here, not in code.

Columns of the terms table
ColumnTypeConstraintsReferencesDescription
iduuidPK
codevarchar(20)unique, not nulle.g. 2026FA
namevarchar(60)not nulle.g. Fall 2026
starts_ondatenot null
ends_ondatenot null
registration_opens_attimestamptz
add_drop_ends_ondatenot nullDrops before this leave no trace on the transcript
withdraw_ends_ondatenot nullWithdrawals after add/drop and before this record a W
statusterm_statusnot null, default 'planned'

buildings

Campus buildings.

Columns of the buildings table
ColumnTypeConstraintsReferences
iduuidPK
codevarchar(10)unique, not null
namevarchar(200)not null

rooms

Bookable teaching spaces. Capacity is checked when a section meeting is scheduled.

Columns of the rooms table
ColumnTypeConstraintsReferences
iduuidPK
building_iduuidFK, not nullbuildings.id
numbervarchar(20)not null
capacitysmallintnot null
kindroom_kindnot null, default 'classroom'

Indexes: (building_id, number) unique

students

One row per person who has ever enrolled. A student who leaves and returns keeps the same row and history.

Columns of the students table
ColumnTypeConstraintsReferencesDescription
iduuidPK
student_numbervarchar(20)unique, not nullThe ID on the card and the transcript. FKs use the uuid.
legal_first_namevarchar(100)not null
legal_last_namevarchar(100)not null
preferred_namevarchar(100)Shown in rosters and class lists; the legal name stays on official documents
date_of_birthdate
emailvarchar(254)unique, not null
phonevarchar(30)
statusstudent_statusnot null, default 'active'
admitted_term_iduuidFKterms.id
created_attimestamptznot null, default `now()`

student_programs

Majors and minors a student is pursuing. A double major is two rows.

Columns of the student_programs table
ColumnTypeConstraintsReferencesDescription
iduuidPK
student_iduuidFK, not nullstudents.id
program_iduuidFK, not nullprograms.id
roleprogram_rolenot null, default 'major'
catalog_term_iduuidFK, not nullterms.idCatalog year: requirements are read as of this term, so later changes do not move the goalposts
declared_ondatenot null
statusprogram_statusnot null, default 'active'

emergency_contacts

Who to call, in order.

Columns of the emergency_contacts table
ColumnTypeConstraintsReferences
iduuidPK
student_iduuidFK, not nullstudents.id
namevarchar(200)not null
relationshipvarchar(60)not null
phonevarchar(30)not null
prioritysmallintnot null, default 1

student_holds

Registration and transcript blocks. A hold is released, never deleted, so "why could I not register in March?" has an answer.

Columns of the student_holds table
ColumnTypeConstraintsReferences
iduuidPK
student_iduuidFK, not nullstudents.id
reasonhold_reasonnot null
blocks_registrationbooleannot null, default true
blocks_transcriptbooleannot null, default false
placed_attimestamptznot null, default `now()`
placed_byuuidFK, not nullstaff_users.id
released_attimestamptz
released_byuuidFKstaff_users.id

instructors

Teaching faculty. Also the pool advisors are drawn from.

Columns of the instructors table
ColumnTypeConstraintsReferencesDescription
iduuidPK
employee_numbervarchar(20)unique, not null
first_namevarchar(100)not null
last_namevarchar(100)not null
emailvarchar(254)unique, not null
department_iduuidFK, not nulldepartments.idHome department
titlevarchar(100)e.g. Assistant Professor, Lecturer
activebooleannot null, default true

advisor_assignments

Who advised a student and when. Effective-dated rather than overwritten.

Columns of the advisor_assignments table
ColumnTypeConstraintsReferencesDescription
iduuidPK
student_iduuidFK, not nullstudents.id
instructor_iduuidFK, not nullinstructors.id
starts_ondatenot null
ends_ondateNull for the current advisor

staff_users

Registrar, bursar and advising staff who act on records. Referenced wherever an action needs an author.

Columns of the staff_users table
ColumnTypeConstraintsReferences
iduuidPK
emailvarchar(254)unique, not null
namevarchar(200)not null
officestaff_officenot null

programs

Degree programs, majors and minors.

Columns of the programs table
ColumnTypeConstraintsReferencesDescription
iduuidPK
department_iduuidFK, not nulldepartments.id
codevarchar(20)unique, not nulle.g. BS-CS
namevarchar(200)not null
leveldegree_levelnot null
credits_requirednumeric(5,1)not null
activebooleannot null, default true

courses

The catalog entry: what a course IS. When and where it runs is a section.

Columns of the courses table
ColumnTypeConstraintsReferencesDescription
iduuidPK
department_iduuidFK, not nulldepartments.id
subject_codevarchar(10)not nulle.g. CS
numbervarchar(10)not nulle.g. 101
titlevarchar(200)not null
creditsnumeric(3,1)not null
descriptiontext
activebooleannot null, default true

Indexes: (subject_code, number) unique

course_prerequisites

What must be completed before a course. Checked at registration against the final grades already posted.

Columns of the course_prerequisites table
ColumnTypeConstraintsReferencesDescription
course_iduuidFK, not nullcourses.id
required_course_iduuidFK, not nullcourses.id
minimum_gradevarchar(2)FKgrade_points.codeNull means any passing grade
concurrent_allowedbooleannot null, default falseTrue for a corequisite that may be taken the same term

program_requirements

Degree requirements, versioned by catalog year so a student is audited against the rules they declared under.

Columns of the program_requirements table
ColumnTypeConstraintsReferencesDescription
iduuidPK
program_iduuidFK, not nullprograms.id
course_iduuidFK, not nullcourses.id
requirement_groupvarchar(100)not nulle.g. Core, Math, Electives
requiredbooleannot null, default trueFalse for courses that count toward an elective group
effective_term_iduuidFK, not nullterms.idFirst catalog year this requirement applies to
retired_term_iduuidFKterms.id

sections

A course offered in a term. Enrollments, meetings and instructors attach here, never to the course.

Columns of the sections table
ColumnTypeConstraintsReferencesDescription
iduuidPK
course_iduuidFK, not nullcourses.id
term_iduuidFK, not nullterms.id
section_numbervarchar(10)not nulle.g. 001, L02
capacitysmallintnot null
waitlist_capacitysmallintnot null, default 0
deliverydelivery_modenot null, default 'in_person'
statussection_statusnot null, default 'scheduled'

Indexes: (course_id, term_id, section_number) unique

section_instructors

Who teaches a section. Team-taught sections have several rows; only primary can post final grades.

Columns of the section_instructors table
ColumnTypeConstraintsReferences
section_iduuidFK, not nullsections.id
instructor_iduuidFK, not nullinstructors.id
roleteaching_rolenot null, default 'primary'

section_meetings

Weekly meeting pattern. A Monday-Wednesday-Friday section is three rows.

Columns of the section_meetings table
ColumnTypeConstraintsReferencesDescription
iduuidPK
section_iduuidFK, not nullsections.id
room_iduuidFKrooms.idNull for online meetings
day_of_weeksmallintnot null1 = Monday ... 7 = Sunday
starts_attimenot null
ends_attimenot null

enrollments

A student in a section. Dropping or withdrawing changes status; the row stays, which is what puts a W on the transcript.

Columns of the enrollments table
ColumnTypeConstraintsReferencesDescription
iduuidPK
student_iduuidFK, not nullstudents.id
section_iduuidFK, not nullsections.id
statusenrollment_statusnot null
grading_basisgrading_basisnot null, default 'letter'
creditsnumeric(3,1)not nullCopied from the course at enrollment; variable-credit courses differ per student
waitlist_positionsmallint
enrolled_attimestamptznot null, default `now()`
status_changed_attimestamptznot null, default `now()`

Indexes: (student_id, section_id) unique, (section_id, status)

assessments

Graded work in a section.

Columns of the assessments table
ColumnTypeConstraintsReferencesDescription
iduuidPK
section_iduuidFK, not nullsections.id
namevarchar(120)not nulle.g. Midterm, Lab 3
weightnumeric(5,2)not nullPercent of the final grade
max_pointsnumeric(6,2)not null
due_attimestamptz

assessment_scores

The score one student earned on one assessment. The gradebook; final grades are posted separately.

Columns of the assessment_scores table
ColumnTypeConstraintsReferences
assessment_iduuidFK, not nullassessments.id
enrollment_iduuidFK, not nullenrollments.id
pointsnumeric(6,2)
excusedbooleannot null, default false
recorded_attimestamptznot null, default `now()`

grade_points

The grading scale. GPA rules are data, so a policy change is an update, not a deploy.

Columns of the grade_points table
ColumnTypeConstraintsReferencesDescription
codevarchar(2)PKA, A-, B+ ... F, P, NP, W, I
pointsnumeric(3,2)Null for grades that carry no points, e.g. P or W
counts_in_gpabooleannot null
earns_creditbooleannot null

final_grades

Posted final grades, append-only. A grade change is a new row pointing at the one it replaces; the latest row per enrollment is the grade of record. GPA is computed from these, never stored.

Columns of the final_grades table
ColumnTypeConstraintsReferencesDescription
iduuidPK
enrollment_iduuidFK, not nullenrollments.id
grade_codevarchar(2)FK, not nullgrade_points.code
posted_byuuidFK, not nullinstructors.id
posted_attimestamptznot null, default `now()`
supersedes_iduuidFKfinal_grades.idSet when this row is a grade change
change_reasontext

Indexes: (enrollment_id)

attendance_records

Attendance per student per class day.

Columns of the attendance_records table
ColumnTypeConstraintsReferences
enrollment_iduuidFK, not nullenrollments.id
class_datedatenot null
statusattendance_statusnot null
recorded_byuuidFK, not nullinstructors.id

degree_conferrals

A degree awarded. One per completed program.

Columns of the degree_conferrals table
ColumnTypeConstraintsReferencesDescription
iduuidPK
student_program_iduuidFK, unique, not nullstudent_programs.id
term_iduuidFK, not nullterms.id
conferred_ondatenot null
honorsvarchar(60)e.g. cum laude

account_charges

Tuition, fees and adjustments, as ledger entries. The balance is the sum of charges minus payments and aid.

Columns of the account_charges table
ColumnTypeConstraintsReferencesDescription
iduuidPK
student_iduuidFK, not nullstudents.id
term_iduuidFK, not nullterms.id
kindcharge_kindnot null
descriptionvarchar(200)not null
amount_centsintegernot nullNegative for credits and refunds of charges
posted_attimestamptznot null, default `now()`
posted_byuuidFKstaff_users.idNull for charges posted automatically at registration

account_payments

Money received toward a student account.

Columns of the account_payments table
ColumnTypeConstraintsReferences
iduuidPK
student_iduuidFK, not nullstudents.id
amount_centsintegernot null
methodpayment_methodnot null
paid_attimestamptznot null, default `now()`
external_referencevarchar(100)

financial_aid_awards

Aid offered and disbursed. Only disbursed awards reduce the account balance.

Columns of the financial_aid_awards table
ColumnTypeConstraintsReferencesDescription
iduuidPK
student_iduuidFK, not nullstudents.id
term_iduuidFK, not nullterms.id
kindaid_kindnot null
namevarchar(200)not nulle.g. Merit Scholarship, Federal Direct Loan
amount_centsintegernot null
statusaid_statusnot null, default 'offered'
disbursed_attimestamptz

Enums (18)

term_status
planned, registration_open, in_session, grades_due, closed
room_kind
classroom, lecture_hall, lab, seminar
student_status
applicant, active, on_leave, withdrawn, graduated
program_role
major, minor, concentration
program_status
active, completed, dropped
hold_reason
financial, advising, registrar, disciplinary, immunization
staff_office
registrar, bursar, advising, admissions
degree_level
associate, bachelor, master, doctorate, certificate
delivery_mode
in_person, online, hybrid
section_status
scheduled, open, closed, cancelled
teaching_role
primary, secondary, teaching_assistant
enrollment_status
enrolled, waitlisted, dropped, withdrawn, completed
grading_basis
letter, pass_fail, audit
attendance_status
present, absent, late, excused
charge_kind
tuition, fee, housing, meal_plan, adjustment
payment_method
card, bank_transfer, check, cash
aid_kind
grant, scholarship, loan, work_study
aid_status
offered, accepted, declined, disbursed, cancelled

Relationships (46)

  • account_charges.posted_by references staff_users.id many to one
  • account_charges.student_id references students.id many to one
  • account_charges.term_id references terms.id many to one
  • account_payments.student_id references students.id many to one
  • advisor_assignments.instructor_id references instructors.id many to one
  • advisor_assignments.student_id references students.id many to one
  • assessment_scores.assessment_id references assessments.id many to one
  • assessment_scores.enrollment_id references enrollments.id many to one
  • assessments.section_id references sections.id many to one
  • attendance_records.enrollment_id references enrollments.id many to one
  • attendance_records.recorded_by references instructors.id many to one
  • course_prerequisites.course_id references courses.id many to one
  • course_prerequisites.minimum_grade references grade_points.code many to one
  • course_prerequisites.required_course_id references courses.id many to one
  • courses.department_id references departments.id many to one
  • degree_conferrals.student_program_id references student_programs.id many to one
  • degree_conferrals.term_id references terms.id many to one
  • emergency_contacts.student_id references students.id many to one
  • enrollments.section_id references sections.id many to one
  • enrollments.student_id references students.id many to one
  • final_grades.enrollment_id references enrollments.id many to one
  • final_grades.grade_code references grade_points.code many to one
  • final_grades.posted_by references instructors.id many to one
  • final_grades.supersedes_id references final_grades.id many to one
  • financial_aid_awards.student_id references students.id many to one
  • financial_aid_awards.term_id references terms.id many to one
  • instructors.department_id references departments.id many to one
  • program_requirements.course_id references courses.id many to one
  • program_requirements.effective_term_id references terms.id many to one
  • program_requirements.program_id references programs.id many to one
  • program_requirements.retired_term_id references terms.id many to one
  • programs.department_id references departments.id many to one
  • rooms.building_id references buildings.id many to one
  • section_instructors.instructor_id references instructors.id many to one
  • section_instructors.section_id references sections.id many to one
  • section_meetings.room_id references rooms.id many to one
  • section_meetings.section_id references sections.id many to one
  • sections.course_id references courses.id many to one
  • sections.term_id references terms.id many to one
  • student_holds.placed_by references staff_users.id many to one
  • student_holds.released_by references staff_users.id many to one
  • student_holds.student_id references students.id many to one
  • student_programs.catalog_term_id references terms.id many to one
  • student_programs.program_id references programs.id many to one
  • student_programs.student_id references students.id many to one
  • students.admitted_term_id references terms.id many to one

Student Information System database schema in DBML

The schema as it is written: DBML, the text format DB Planner draws its diagrams from. Copy it into any DBML tool, or open it in the diagram above.

student-information-system.dbml dbml
// Student Information System
// Zones (header colors): institution (gray), students (green), faculty (teal),
// course catalog (blue), scheduling (amber), enrollment and grades (coral),
// student accounts (purple).

// ---------------------------------------------------------------------------
// INSTITUTION: the calendar and the places
// ---------------------------------------------------------------------------

Table departments [headercolor: #90a4ae] {
  id uuid [pk]
  code varchar(10) [not null, unique, note: 'e.g. CS, MATH, HIST']
  name varchar(200) [not null]
  Note: 'Academic departments. Own courses, programs and faculty appointments.'
}

Table terms [headercolor: #90a4ae] {
  id uuid [pk]
  code varchar(20) [not null, unique, note: 'e.g. 2026FA']
  name varchar(60) [not null, note: 'e.g. Fall 2026']
  starts_on date [not null]
  ends_on date [not null]
  registration_opens_at timestamptz
  add_drop_ends_on date [not null, note: 'Drops before this leave no trace on the transcript']
  withdraw_ends_on date [not null, note: 'Withdrawals after add/drop and before this record a W']
  status term_status [not null, default: 'planned']
  Note: 'Academic terms. Every deadline enrollment rules check against lives here, not in code.'
}

Table buildings [headercolor: #90a4ae] {
  id uuid [pk]
  code varchar(10) [not null, unique]
  name varchar(200) [not null]
  Note: 'Campus buildings.'
}

Table rooms [headercolor: #90a4ae] {
  id uuid [pk]
  building_id uuid [not null, ref: > buildings.id]
  number varchar(20) [not null]
  capacity smallint [not null]
  kind room_kind [not null, default: 'classroom']

  indexes {
    (building_id, number) [unique]
  }

  Note: 'Bookable teaching spaces. Capacity is checked when a section meeting is scheduled.'
}

// ---------------------------------------------------------------------------
// STUDENTS
// ---------------------------------------------------------------------------

Table students [headercolor: #8bc34a] {
  id uuid [pk]
  student_number varchar(20) [not null, unique, note: 'The ID on the card and the transcript. FKs use the uuid.']
  legal_first_name varchar(100) [not null]
  legal_last_name varchar(100) [not null]
  preferred_name varchar(100) [note: 'Shown in rosters and class lists; the legal name stays on official documents']
  date_of_birth date
  email varchar(254) [not null, unique]
  phone varchar(30)
  status student_status [not null, default: 'active']
  admitted_term_id uuid [ref: > terms.id]
  created_at timestamptz [not null, default: `now()`]
  Note: 'One row per person who has ever enrolled. A student who leaves and returns keeps the same row and history.'
}

Table student_programs [headercolor: #8bc34a] {
  id uuid [pk]
  student_id uuid [not null, ref: > students.id]
  program_id uuid [not null, ref: > programs.id]
  role program_role [not null, default: 'major']
  catalog_term_id uuid [not null, ref: > terms.id, note: 'Catalog year: requirements are read as of this term, so later changes do not move the goalposts']
  declared_on date [not null]
  status program_status [not null, default: 'active']
  Note: 'Majors and minors a student is pursuing. A double major is two rows.'
}

Table emergency_contacts [headercolor: #8bc34a] {
  id uuid [pk]
  student_id uuid [not null, ref: > students.id]
  name varchar(200) [not null]
  relationship varchar(60) [not null]
  phone varchar(30) [not null]
  priority smallint [not null, default: 1]
  Note: 'Who to call, in order.'
}

Table student_holds [headercolor: #8bc34a] {
  id uuid [pk]
  student_id uuid [not null, ref: > students.id]
  reason hold_reason [not null]
  blocks_registration boolean [not null, default: true]
  blocks_transcript boolean [not null, default: false]
  placed_at timestamptz [not null, default: `now()`]
  placed_by uuid [not null, ref: > staff_users.id]
  released_at timestamptz
  released_by uuid [ref: > staff_users.id]
  Note: 'Registration and transcript blocks. A hold is released, never deleted, so "why could I not register in March?" has an answer.'
}

// ---------------------------------------------------------------------------
// FACULTY AND STAFF
// ---------------------------------------------------------------------------

Table instructors [headercolor: #4cd0b0] {
  id uuid [pk]
  employee_number varchar(20) [not null, unique]
  first_name varchar(100) [not null]
  last_name varchar(100) [not null]
  email varchar(254) [not null, unique]
  department_id uuid [not null, ref: > departments.id, note: 'Home department']
  title varchar(100) [note: 'e.g. Assistant Professor, Lecturer']
  active boolean [not null, default: true]
  Note: 'Teaching faculty. Also the pool advisors are drawn from.'
}

Table advisor_assignments [headercolor: #4cd0b0] {
  id uuid [pk]
  student_id uuid [not null, ref: > students.id]
  instructor_id uuid [not null, ref: > instructors.id]
  starts_on date [not null]
  ends_on date [note: 'Null for the current advisor']
  Note: 'Who advised a student and when. Effective-dated rather than overwritten.'
}

Table staff_users [headercolor: #4cd0b0] {
  id uuid [pk]
  email varchar(254) [not null, unique]
  name varchar(200) [not null]
  office staff_office [not null]
  Note: 'Registrar, bursar and advising staff who act on records. Referenced wherever an action needs an author.'
}

// ---------------------------------------------------------------------------
// COURSE CATALOG: what can be taught
// ---------------------------------------------------------------------------

Table programs [headercolor: #4c8bf5] {
  id uuid [pk]
  department_id uuid [not null, ref: > departments.id]
  code varchar(20) [not null, unique, note: 'e.g. BS-CS']
  name varchar(200) [not null]
  level degree_level [not null]
  credits_required numeric(5,1) [not null]
  active boolean [not null, default: true]
  Note: 'Degree programs, majors and minors.'
}

Table courses [headercolor: #4c8bf5] {
  id uuid [pk]
  department_id uuid [not null, ref: > departments.id]
  subject_code varchar(10) [not null, note: 'e.g. CS']
  number varchar(10) [not null, note: 'e.g. 101']
  title varchar(200) [not null]
  credits numeric(3,1) [not null]
  description text
  active boolean [not null, default: true]

  indexes {
    (subject_code, number) [unique]
  }

  Note: 'The catalog entry: what a course IS. When and where it runs is a section.'
}

Table course_prerequisites [headercolor: #4c8bf5] {
  course_id uuid [not null, ref: > courses.id]
  required_course_id uuid [not null, ref: > courses.id]
  minimum_grade varchar(2) [ref: > grade_points.code, note: 'Null means any passing grade']
  concurrent_allowed boolean [not null, default: false, note: 'True for a corequisite that may be taken the same term']

  indexes {
    (course_id, required_course_id) [pk]
  }

  Note: 'What must be completed before a course. Checked at registration against the final grades already posted.'
}

Table program_requirements [headercolor: #4c8bf5] {
  id uuid [pk]
  program_id uuid [not null, ref: > programs.id]
  course_id uuid [not null, ref: > courses.id]
  requirement_group varchar(100) [not null, note: 'e.g. Core, Math, Electives']
  required boolean [not null, default: true, note: 'False for courses that count toward an elective group']
  effective_term_id uuid [not null, ref: > terms.id, note: 'First catalog year this requirement applies to']
  retired_term_id uuid [ref: > terms.id]
  Note: 'Degree requirements, versioned by catalog year so a student is audited against the rules they declared under.'
}

// ---------------------------------------------------------------------------
// SCHEDULING: one run of a course in one term
// ---------------------------------------------------------------------------

Table sections [headercolor: #f5b74c] {
  id uuid [pk]
  course_id uuid [not null, ref: > courses.id]
  term_id uuid [not null, ref: > terms.id]
  section_number varchar(10) [not null, note: 'e.g. 001, L02']
  capacity smallint [not null]
  waitlist_capacity smallint [not null, default: 0]
  delivery delivery_mode [not null, default: 'in_person']
  status section_status [not null, default: 'scheduled']

  indexes {
    (course_id, term_id, section_number) [unique]
  }

  Note: 'A course offered in a term. Enrollments, meetings and instructors attach here, never to the course.'
}

Table section_instructors [headercolor: #f5b74c] {
  section_id uuid [not null, ref: > sections.id]
  instructor_id uuid [not null, ref: > instructors.id]
  role teaching_role [not null, default: 'primary']

  indexes {
    (section_id, instructor_id) [pk]
  }

  Note: 'Who teaches a section. Team-taught sections have several rows; only primary can post final grades.'
}

Table section_meetings [headercolor: #f5b74c] {
  id uuid [pk]
  section_id uuid [not null, ref: > sections.id]
  room_id uuid [ref: > rooms.id, note: 'Null for online meetings']
  day_of_week smallint [not null, note: '1 = Monday ... 7 = Sunday']
  starts_at time [not null]
  ends_at time [not null]
  Note: 'Weekly meeting pattern. A Monday-Wednesday-Friday section is three rows.'
}

// ---------------------------------------------------------------------------
// ENROLLMENT AND GRADES
// ---------------------------------------------------------------------------

Table enrollments [headercolor: #f07178] {
  id uuid [pk]
  student_id uuid [not null, ref: > students.id]
  section_id uuid [not null, ref: > sections.id]
  status enrollment_status [not null]
  grading_basis grading_basis [not null, default: 'letter']
  credits numeric(3,1) [not null, note: 'Copied from the course at enrollment; variable-credit courses differ per student']
  waitlist_position smallint
  enrolled_at timestamptz [not null, default: `now()`]
  status_changed_at timestamptz [not null, default: `now()`]

  indexes {
    (student_id, section_id) [unique]
    (section_id, status)
  }

  Note: 'A student in a section. Dropping or withdrawing changes status; the row stays, which is what puts a W on the transcript.'
}

Table assessments [headercolor: #f07178] {
  id uuid [pk]
  section_id uuid [not null, ref: > sections.id]
  name varchar(120) [not null, note: 'e.g. Midterm, Lab 3']
  weight numeric(5,2) [not null, note: 'Percent of the final grade']
  max_points numeric(6,2) [not null]
  due_at timestamptz
  Note: 'Graded work in a section.'
}

Table assessment_scores [headercolor: #f07178] {
  assessment_id uuid [not null, ref: > assessments.id]
  enrollment_id uuid [not null, ref: > enrollments.id]
  points numeric(6,2)
  excused boolean [not null, default: false]
  recorded_at timestamptz [not null, default: `now()`]

  indexes {
    (assessment_id, enrollment_id) [pk]
  }

  Note: 'The score one student earned on one assessment. The gradebook; final grades are posted separately.'
}

Table grade_points [headercolor: #f07178] {
  code varchar(2) [pk, note: 'A, A-, B+ ... F, P, NP, W, I']
  points numeric(3,2) [note: 'Null for grades that carry no points, e.g. P or W']
  counts_in_gpa boolean [not null]
  earns_credit boolean [not null]
  Note: 'The grading scale. GPA rules are data, so a policy change is an update, not a deploy.'
}

Table final_grades [headercolor: #f07178] {
  id uuid [pk]
  enrollment_id uuid [not null, ref: > enrollments.id]
  grade_code varchar(2) [not null, ref: > grade_points.code]
  posted_by uuid [not null, ref: > instructors.id]
  posted_at timestamptz [not null, default: `now()`]
  supersedes_id uuid [ref: > final_grades.id, note: 'Set when this row is a grade change']
  change_reason text

  indexes {
    enrollment_id
  }

  Note: 'Posted final grades, append-only. A grade change is a new row pointing at the one it replaces; the latest row per enrollment is the grade of record. GPA is computed from these, never stored.'
}

Table attendance_records [headercolor: #f07178] {
  enrollment_id uuid [not null, ref: > enrollments.id]
  class_date date [not null]
  status attendance_status [not null]
  recorded_by uuid [not null, ref: > instructors.id]

  indexes {
    (enrollment_id, class_date) [pk]
  }

  Note: 'Attendance per student per class day.'
}

Table degree_conferrals [headercolor: #f07178] {
  id uuid [pk]
  student_program_id uuid [not null, unique, ref: > student_programs.id]
  term_id uuid [not null, ref: > terms.id]
  conferred_on date [not null]
  honors varchar(60) [note: 'e.g. cum laude']
  Note: 'A degree awarded. One per completed program.'
}

// ---------------------------------------------------------------------------
// STUDENT ACCOUNTS: what is owed and what was paid
// ---------------------------------------------------------------------------

Table account_charges [headercolor: #b98cf0] {
  id uuid [pk]
  student_id uuid [not null, ref: > students.id]
  term_id uuid [not null, ref: > terms.id]
  kind charge_kind [not null]
  description varchar(200) [not null]
  amount_cents integer [not null, note: 'Negative for credits and refunds of charges']
  posted_at timestamptz [not null, default: `now()`]
  posted_by uuid [ref: > staff_users.id, note: 'Null for charges posted automatically at registration']
  Note: 'Tuition, fees and adjustments, as ledger entries. The balance is the sum of charges minus payments and aid.'
}

Table account_payments [headercolor: #b98cf0] {
  id uuid [pk]
  student_id uuid [not null, ref: > students.id]
  amount_cents integer [not null]
  method payment_method [not null]
  paid_at timestamptz [not null, default: `now()`]
  external_reference varchar(100)
  Note: 'Money received toward a student account.'
}

Table financial_aid_awards [headercolor: #b98cf0] {
  id uuid [pk]
  student_id uuid [not null, ref: > students.id]
  term_id uuid [not null, ref: > terms.id]
  kind aid_kind [not null]
  name varchar(200) [not null, note: 'e.g. Merit Scholarship, Federal Direct Loan']
  amount_cents integer [not null]
  status aid_status [not null, default: 'offered']
  disbursed_at timestamptz
  Note: 'Aid offered and disbursed. Only disbursed awards reduce the account balance.'
}

// ---------------------------------------------------------------------------
// ENUMS
// ---------------------------------------------------------------------------

Enum term_status {
  planned
  registration_open
  in_session
  grades_due
  closed
}

Enum room_kind {
  classroom
  lecture_hall
  lab
  seminar
}

Enum student_status {
  applicant
  active
  on_leave
  withdrawn
  graduated
}

Enum program_role {
  major
  minor
  concentration
}

Enum program_status {
  active
  completed
  dropped
}

Enum hold_reason {
  financial
  advising
  registrar
  disciplinary
  immunization
}

Enum staff_office {
  registrar
  bursar
  advising
  admissions
}

Enum degree_level {
  associate
  bachelor
  master
  doctorate
  certificate
}

Enum delivery_mode {
  in_person
  online
  hybrid
}

Enum section_status {
  scheduled
  open
  closed
  cancelled
}

Enum teaching_role {
  primary
  secondary
  teaching_assistant
}

Enum enrollment_status {
  enrolled
  waitlisted
  dropped
  withdrawn
  completed
}

Enum grading_basis {
  letter
  pass_fail
  audit
}

Enum attendance_status {
  present
  absent
  late
  excused
}

Enum charge_kind {
  tuition
  fee
  housing
  meal_plan
  adjustment
}

Enum payment_method {
  card
  bank_transfer
  check
  cash
}

Enum aid_kind {
  grant
  scholarship
  loan
  work_study
}

Enum aid_status {
  offered
  accepted
  declined
  disbursed
  cancelled
}

Student Information System database schema as SQL

The same schema as CREATE TABLE statements, exported by DB Planner. PostgreSQL is shown first; MySQL and SQL Server are below it.

PostgreSQL
postgresql.sql PostgreSQL
CREATE TYPE "term_status" AS ENUM (
  'planned',
  'registration_open',
  'in_session',
  'grades_due',
  'closed'
);

CREATE TYPE "room_kind" AS ENUM (
  'classroom',
  'lecture_hall',
  'lab',
  'seminar'
);

CREATE TYPE "student_status" AS ENUM (
  'applicant',
  'active',
  'on_leave',
  'withdrawn',
  'graduated'
);

CREATE TYPE "program_role" AS ENUM (
  'major',
  'minor',
  'concentration'
);

CREATE TYPE "program_status" AS ENUM (
  'active',
  'completed',
  'dropped'
);

CREATE TYPE "hold_reason" AS ENUM (
  'financial',
  'advising',
  'registrar',
  'disciplinary',
  'immunization'
);

CREATE TYPE "staff_office" AS ENUM (
  'registrar',
  'bursar',
  'advising',
  'admissions'
);

CREATE TYPE "degree_level" AS ENUM (
  'associate',
  'bachelor',
  'master',
  'doctorate',
  'certificate'
);

CREATE TYPE "delivery_mode" AS ENUM (
  'in_person',
  'online',
  'hybrid'
);

CREATE TYPE "section_status" AS ENUM (
  'scheduled',
  'open',
  'closed',
  'cancelled'
);

CREATE TYPE "teaching_role" AS ENUM (
  'primary',
  'secondary',
  'teaching_assistant'
);

CREATE TYPE "enrollment_status" AS ENUM (
  'enrolled',
  'waitlisted',
  'dropped',
  'withdrawn',
  'completed'
);

CREATE TYPE "grading_basis" AS ENUM (
  'letter',
  'pass_fail',
  'audit'
);

CREATE TYPE "attendance_status" AS ENUM (
  'present',
  'absent',
  'late',
  'excused'
);

CREATE TYPE "charge_kind" AS ENUM (
  'tuition',
  'fee',
  'housing',
  'meal_plan',
  'adjustment'
);

CREATE TYPE "payment_method" AS ENUM (
  'card',
  'bank_transfer',
  'check',
  'cash'
);

CREATE TYPE "aid_kind" AS ENUM (
  'grant',
  'scholarship',
  'loan',
  'work_study'
);

CREATE TYPE "aid_status" AS ENUM (
  'offered',
  'accepted',
  'declined',
  'disbursed',
  'cancelled'
);

CREATE TABLE "departments" (
  "id" uuid PRIMARY KEY,
  "code" varchar(10) UNIQUE NOT NULL,
  "name" varchar(200) NOT NULL
);

CREATE TABLE "terms" (
  "id" uuid PRIMARY KEY,
  "code" varchar(20) UNIQUE NOT NULL,
  "name" varchar(60) NOT NULL,
  "starts_on" date NOT NULL,
  "ends_on" date NOT NULL,
  "registration_opens_at" timestamptz,
  "add_drop_ends_on" date NOT NULL,
  "withdraw_ends_on" date NOT NULL,
  "status" term_status NOT NULL DEFAULT 'planned'
);

CREATE TABLE "buildings" (
  "id" uuid PRIMARY KEY,
  "code" varchar(10) UNIQUE NOT NULL,
  "name" varchar(200) NOT NULL
);

CREATE TABLE "rooms" (
  "id" uuid PRIMARY KEY,
  "building_id" uuid NOT NULL,
  "number" varchar(20) NOT NULL,
  "capacity" smallint NOT NULL,
  "kind" room_kind NOT NULL DEFAULT 'classroom'
);

CREATE TABLE "students" (
  "id" uuid PRIMARY KEY,
  "student_number" varchar(20) UNIQUE NOT NULL,
  "legal_first_name" varchar(100) NOT NULL,
  "legal_last_name" varchar(100) NOT NULL,
  "preferred_name" varchar(100),
  "date_of_birth" date,
  "email" varchar(254) UNIQUE NOT NULL,
  "phone" varchar(30),
  "status" student_status NOT NULL DEFAULT 'active',
  "admitted_term_id" uuid,
  "created_at" timestamptz NOT NULL DEFAULT (now())
);

CREATE TABLE "student_programs" (
  "id" uuid PRIMARY KEY,
  "student_id" uuid NOT NULL,
  "program_id" uuid NOT NULL,
  "role" program_role NOT NULL DEFAULT 'major',
  "catalog_term_id" uuid NOT NULL,
  "declared_on" date NOT NULL,
  "status" program_status NOT NULL DEFAULT 'active'
);

CREATE TABLE "emergency_contacts" (
  "id" uuid PRIMARY KEY,
  "student_id" uuid NOT NULL,
  "name" varchar(200) NOT NULL,
  "relationship" varchar(60) NOT NULL,
  "phone" varchar(30) NOT NULL,
  "priority" smallint NOT NULL DEFAULT 1
);

CREATE TABLE "student_holds" (
  "id" uuid PRIMARY KEY,
  "student_id" uuid NOT NULL,
  "reason" hold_reason NOT NULL,
  "blocks_registration" boolean NOT NULL DEFAULT true,
  "blocks_transcript" boolean NOT NULL DEFAULT false,
  "placed_at" timestamptz NOT NULL DEFAULT (now()),
  "placed_by" uuid NOT NULL,
  "released_at" timestamptz,
  "released_by" uuid
);

CREATE TABLE "instructors" (
  "id" uuid PRIMARY KEY,
  "employee_number" varchar(20) UNIQUE NOT NULL,
  "first_name" varchar(100) NOT NULL,
  "last_name" varchar(100) NOT NULL,
  "email" varchar(254) UNIQUE NOT NULL,
  "department_id" uuid NOT NULL,
  "title" varchar(100),
  "active" boolean NOT NULL DEFAULT true
);

CREATE TABLE "advisor_assignments" (
  "id" uuid PRIMARY KEY,
  "student_id" uuid NOT NULL,
  "instructor_id" uuid NOT NULL,
  "starts_on" date NOT NULL,
  "ends_on" date
);

CREATE TABLE "staff_users" (
  "id" uuid PRIMARY KEY,
  "email" varchar(254) UNIQUE NOT NULL,
  "name" varchar(200) NOT NULL,
  "office" staff_office NOT NULL
);

CREATE TABLE "programs" (
  "id" uuid PRIMARY KEY,
  "department_id" uuid NOT NULL,
  "code" varchar(20) UNIQUE NOT NULL,
  "name" varchar(200) NOT NULL,
  "level" degree_level NOT NULL,
  "credits_required" numeric(5,1) NOT NULL,
  "active" boolean NOT NULL DEFAULT true
);

CREATE TABLE "courses" (
  "id" uuid PRIMARY KEY,
  "department_id" uuid NOT NULL,
  "subject_code" varchar(10) NOT NULL,
  "number" varchar(10) NOT NULL,
  "title" varchar(200) NOT NULL,
  "credits" numeric(3,1) NOT NULL,
  "description" text,
  "active" boolean NOT NULL DEFAULT true
);

CREATE TABLE "course_prerequisites" (
  "course_id" uuid NOT NULL,
  "required_course_id" uuid NOT NULL,
  "minimum_grade" varchar(2),
  "concurrent_allowed" boolean NOT NULL DEFAULT false,
  PRIMARY KEY ("course_id", "required_course_id")
);

CREATE TABLE "program_requirements" (
  "id" uuid PRIMARY KEY,
  "program_id" uuid NOT NULL,
  "course_id" uuid NOT NULL,
  "requirement_group" varchar(100) NOT NULL,
  "required" boolean NOT NULL DEFAULT true,
  "effective_term_id" uuid NOT NULL,
  "retired_term_id" uuid
);

CREATE TABLE "sections" (
  "id" uuid PRIMARY KEY,
  "course_id" uuid NOT NULL,
  "term_id" uuid NOT NULL,
  "section_number" varchar(10) NOT NULL,
  "capacity" smallint NOT NULL,
  "waitlist_capacity" smallint NOT NULL DEFAULT 0,
  "delivery" delivery_mode NOT NULL DEFAULT 'in_person',
  "status" section_status NOT NULL DEFAULT 'scheduled'
);

CREATE TABLE "section_instructors" (
  "section_id" uuid NOT NULL,
  "instructor_id" uuid NOT NULL,
  "role" teaching_role NOT NULL DEFAULT 'primary',
  PRIMARY KEY ("section_id", "instructor_id")
);

CREATE TABLE "section_meetings" (
  "id" uuid PRIMARY KEY,
  "section_id" uuid NOT NULL,
  "room_id" uuid,
  "day_of_week" smallint NOT NULL,
  "starts_at" time NOT NULL,
  "ends_at" time NOT NULL
);

CREATE TABLE "enrollments" (
  "id" uuid PRIMARY KEY,
  "student_id" uuid NOT NULL,
  "section_id" uuid NOT NULL,
  "status" enrollment_status NOT NULL,
  "grading_basis" grading_basis NOT NULL DEFAULT 'letter',
  "credits" numeric(3,1) NOT NULL,
  "waitlist_position" smallint,
  "enrolled_at" timestamptz NOT NULL DEFAULT (now()),
  "status_changed_at" timestamptz NOT NULL DEFAULT (now())
);

CREATE TABLE "assessments" (
  "id" uuid PRIMARY KEY,
  "section_id" uuid NOT NULL,
  "name" varchar(120) NOT NULL,
  "weight" numeric(5,2) NOT NULL,
  "max_points" numeric(6,2) NOT NULL,
  "due_at" timestamptz
);

CREATE TABLE "assessment_scores" (
  "assessment_id" uuid NOT NULL,
  "enrollment_id" uuid NOT NULL,
  "points" numeric(6,2),
  "excused" boolean NOT NULL DEFAULT false,
  "recorded_at" timestamptz NOT NULL DEFAULT (now()),
  PRIMARY KEY ("assessment_id", "enrollment_id")
);

CREATE TABLE "grade_points" (
  "code" varchar(2) PRIMARY KEY,
  "points" numeric(3,2),
  "counts_in_gpa" boolean NOT NULL,
  "earns_credit" boolean NOT NULL
);

CREATE TABLE "final_grades" (
  "id" uuid PRIMARY KEY,
  "enrollment_id" uuid NOT NULL,
  "grade_code" varchar(2) NOT NULL,
  "posted_by" uuid NOT NULL,
  "posted_at" timestamptz NOT NULL DEFAULT (now()),
  "supersedes_id" uuid,
  "change_reason" text
);

CREATE TABLE "attendance_records" (
  "enrollment_id" uuid NOT NULL,
  "class_date" date NOT NULL,
  "status" attendance_status NOT NULL,
  "recorded_by" uuid NOT NULL,
  PRIMARY KEY ("enrollment_id", "class_date")
);

CREATE TABLE "degree_conferrals" (
  "id" uuid PRIMARY KEY,
  "student_program_id" uuid UNIQUE NOT NULL,
  "term_id" uuid NOT NULL,
  "conferred_on" date NOT NULL,
  "honors" varchar(60)
);

CREATE TABLE "account_charges" (
  "id" uuid PRIMARY KEY,
  "student_id" uuid NOT NULL,
  "term_id" uuid NOT NULL,
  "kind" charge_kind NOT NULL,
  "description" varchar(200) NOT NULL,
  "amount_cents" integer NOT NULL,
  "posted_at" timestamptz NOT NULL DEFAULT (now()),
  "posted_by" uuid
);

CREATE TABLE "account_payments" (
  "id" uuid PRIMARY KEY,
  "student_id" uuid NOT NULL,
  "amount_cents" integer NOT NULL,
  "method" payment_method NOT NULL,
  "paid_at" timestamptz NOT NULL DEFAULT (now()),
  "external_reference" varchar(100)
);

CREATE TABLE "financial_aid_awards" (
  "id" uuid PRIMARY KEY,
  "student_id" uuid NOT NULL,
  "term_id" uuid NOT NULL,
  "kind" aid_kind NOT NULL,
  "name" varchar(200) NOT NULL,
  "amount_cents" integer NOT NULL,
  "status" aid_status NOT NULL DEFAULT 'offered',
  "disbursed_at" timestamptz
);

CREATE UNIQUE INDEX ON "rooms" ("building_id", "number");

CREATE UNIQUE INDEX ON "courses" ("subject_code", "number");

CREATE UNIQUE INDEX ON "sections" ("course_id", "term_id", "section_number");

CREATE UNIQUE INDEX ON "enrollments" ("student_id", "section_id");

CREATE INDEX ON "enrollments" ("section_id", "status");

CREATE INDEX ON "final_grades" ("enrollment_id");

COMMENT ON TABLE "departments" IS 'Academic departments. Own courses, programs and faculty appointments.';

COMMENT ON COLUMN "departments"."code" IS 'e.g. CS, MATH, HIST';

COMMENT ON TABLE "terms" IS 'Academic terms. Every deadline enrollment rules check against lives here, not in code.';

COMMENT ON COLUMN "terms"."code" IS 'e.g. 2026FA';

COMMENT ON COLUMN "terms"."name" IS 'e.g. Fall 2026';

COMMENT ON COLUMN "terms"."add_drop_ends_on" IS 'Drops before this leave no trace on the transcript';

COMMENT ON COLUMN "terms"."withdraw_ends_on" IS 'Withdrawals after add/drop and before this record a W';

COMMENT ON TABLE "buildings" IS 'Campus buildings.';

COMMENT ON TABLE "rooms" IS 'Bookable teaching spaces. Capacity is checked when a section meeting is scheduled.';

COMMENT ON TABLE "students" IS 'One row per person who has ever enrolled. A student who leaves and returns keeps the same row and history.';

COMMENT ON COLUMN "students"."student_number" IS 'The ID on the card and the transcript. FKs use the uuid.';

COMMENT ON COLUMN "students"."preferred_name" IS 'Shown in rosters and class lists; the legal name stays on official documents';

COMMENT ON TABLE "student_programs" IS 'Majors and minors a student is pursuing. A double major is two rows.';

COMMENT ON COLUMN "student_programs"."catalog_term_id" IS 'Catalog year: requirements are read as of this term, so later changes do not move the goalposts';

COMMENT ON TABLE "emergency_contacts" IS 'Who to call, in order.';

COMMENT ON TABLE "student_holds" IS 'Registration and transcript blocks. A hold is released, never deleted, so "why could I not register in March?" has an answer.';

COMMENT ON TABLE "instructors" IS 'Teaching faculty. Also the pool advisors are drawn from.';

COMMENT ON COLUMN "instructors"."department_id" IS 'Home department';

COMMENT ON COLUMN "instructors"."title" IS 'e.g. Assistant Professor, Lecturer';

COMMENT ON TABLE "advisor_assignments" IS 'Who advised a student and when. Effective-dated rather than overwritten.';

COMMENT ON COLUMN "advisor_assignments"."ends_on" IS 'Null for the current advisor';

COMMENT ON TABLE "staff_users" IS 'Registrar, bursar and advising staff who act on records. Referenced wherever an action needs an author.';

COMMENT ON TABLE "programs" IS 'Degree programs, majors and minors.';

COMMENT ON COLUMN "programs"."code" IS 'e.g. BS-CS';

COMMENT ON TABLE "courses" IS 'The catalog entry: what a course IS. When and where it runs is a section.';

COMMENT ON COLUMN "courses"."subject_code" IS 'e.g. CS';

COMMENT ON COLUMN "courses"."number" IS 'e.g. 101';

COMMENT ON TABLE "course_prerequisites" IS 'What must be completed before a course. Checked at registration against the final grades already posted.';

COMMENT ON COLUMN "course_prerequisites"."minimum_grade" IS 'Null means any passing grade';

COMMENT ON COLUMN "course_prerequisites"."concurrent_allowed" IS 'True for a corequisite that may be taken the same term';

COMMENT ON TABLE "program_requirements" IS 'Degree requirements, versioned by catalog year so a student is audited against the rules they declared under.';

COMMENT ON COLUMN "program_requirements"."requirement_group" IS 'e.g. Core, Math, Electives';

COMMENT ON COLUMN "program_requirements"."required" IS 'False for courses that count toward an elective group';

COMMENT ON COLUMN "program_requirements"."effective_term_id" IS 'First catalog year this requirement applies to';

COMMENT ON TABLE "sections" IS 'A course offered in a term. Enrollments, meetings and instructors attach here, never to the course.';

COMMENT ON COLUMN "sections"."section_number" IS 'e.g. 001, L02';

COMMENT ON TABLE "section_instructors" IS 'Who teaches a section. Team-taught sections have several rows; only primary can post final grades.';

COMMENT ON TABLE "section_meetings" IS 'Weekly meeting pattern. A Monday-Wednesday-Friday section is three rows.';

COMMENT ON COLUMN "section_meetings"."room_id" IS 'Null for online meetings';

COMMENT ON COLUMN "section_meetings"."day_of_week" IS '1 = Monday ... 7 = Sunday';

COMMENT ON TABLE "enrollments" IS 'A student in a section. Dropping or withdrawing changes status; the row stays, which is what puts a W on the transcript.';

COMMENT ON COLUMN "enrollments"."credits" IS 'Copied from the course at enrollment; variable-credit courses differ per student';

COMMENT ON TABLE "assessments" IS 'Graded work in a section.';

COMMENT ON COLUMN "assessments"."name" IS 'e.g. Midterm, Lab 3';

COMMENT ON COLUMN "assessments"."weight" IS 'Percent of the final grade';

COMMENT ON TABLE "assessment_scores" IS 'The score one student earned on one assessment. The gradebook; final grades are posted separately.';

COMMENT ON TABLE "grade_points" IS 'The grading scale. GPA rules are data, so a policy change is an update, not a deploy.';

COMMENT ON COLUMN "grade_points"."code" IS 'A, A-, B+ ... F, P, NP, W, I';

COMMENT ON COLUMN "grade_points"."points" IS 'Null for grades that carry no points, e.g. P or W';

COMMENT ON TABLE "final_grades" IS 'Posted final grades, append-only. A grade change is a new row pointing at the one it replaces; the latest row per enrollment is the grade of record. GPA is computed from these, never stored.';

COMMENT ON COLUMN "final_grades"."supersedes_id" IS 'Set when this row is a grade change';

COMMENT ON TABLE "attendance_records" IS 'Attendance per student per class day.';

COMMENT ON TABLE "degree_conferrals" IS 'A degree awarded. One per completed program.';

COMMENT ON COLUMN "degree_conferrals"."honors" IS 'e.g. cum laude';

COMMENT ON TABLE "account_charges" IS 'Tuition, fees and adjustments, as ledger entries. The balance is the sum of charges minus payments and aid.';

COMMENT ON COLUMN "account_charges"."amount_cents" IS 'Negative for credits and refunds of charges';

COMMENT ON COLUMN "account_charges"."posted_by" IS 'Null for charges posted automatically at registration';

COMMENT ON TABLE "account_payments" IS 'Money received toward a student account.';

COMMENT ON TABLE "financial_aid_awards" IS 'Aid offered and disbursed. Only disbursed awards reduce the account balance.';

COMMENT ON COLUMN "financial_aid_awards"."name" IS 'e.g. Merit Scholarship, Federal Direct Loan';

ALTER TABLE "rooms" ADD FOREIGN KEY ("building_id") REFERENCES "buildings" ("id");

ALTER TABLE "students" ADD FOREIGN KEY ("admitted_term_id") REFERENCES "terms" ("id");

ALTER TABLE "student_programs" ADD FOREIGN KEY ("student_id") REFERENCES "students" ("id");

ALTER TABLE "student_programs" ADD FOREIGN KEY ("program_id") REFERENCES "programs" ("id");

ALTER TABLE "student_programs" ADD FOREIGN KEY ("catalog_term_id") REFERENCES "terms" ("id");

ALTER TABLE "emergency_contacts" ADD FOREIGN KEY ("student_id") REFERENCES "students" ("id");

ALTER TABLE "student_holds" ADD FOREIGN KEY ("student_id") REFERENCES "students" ("id");

ALTER TABLE "student_holds" ADD FOREIGN KEY ("placed_by") REFERENCES "staff_users" ("id");

ALTER TABLE "student_holds" ADD FOREIGN KEY ("released_by") REFERENCES "staff_users" ("id");

ALTER TABLE "instructors" ADD FOREIGN KEY ("department_id") REFERENCES "departments" ("id");

ALTER TABLE "advisor_assignments" ADD FOREIGN KEY ("student_id") REFERENCES "students" ("id");

ALTER TABLE "advisor_assignments" ADD FOREIGN KEY ("instructor_id") REFERENCES "instructors" ("id");

ALTER TABLE "programs" ADD FOREIGN KEY ("department_id") REFERENCES "departments" ("id");

ALTER TABLE "courses" ADD FOREIGN KEY ("department_id") REFERENCES "departments" ("id");

ALTER TABLE "course_prerequisites" ADD FOREIGN KEY ("course_id") REFERENCES "courses" ("id");

ALTER TABLE "course_prerequisites" ADD FOREIGN KEY ("required_course_id") REFERENCES "courses" ("id");

ALTER TABLE "course_prerequisites" ADD FOREIGN KEY ("minimum_grade") REFERENCES "grade_points" ("code");

ALTER TABLE "program_requirements" ADD FOREIGN KEY ("program_id") REFERENCES "programs" ("id");

ALTER TABLE "program_requirements" ADD FOREIGN KEY ("course_id") REFERENCES "courses" ("id");

ALTER TABLE "program_requirements" ADD FOREIGN KEY ("effective_term_id") REFERENCES "terms" ("id");

ALTER TABLE "program_requirements" ADD FOREIGN KEY ("retired_term_id") REFERENCES "terms" ("id");

ALTER TABLE "sections" ADD FOREIGN KEY ("course_id") REFERENCES "courses" ("id");

ALTER TABLE "sections" ADD FOREIGN KEY ("term_id") REFERENCES "terms" ("id");

ALTER TABLE "section_instructors" ADD FOREIGN KEY ("section_id") REFERENCES "sections" ("id");

ALTER TABLE "section_instructors" ADD FOREIGN KEY ("instructor_id") REFERENCES "instructors" ("id");

ALTER TABLE "section_meetings" ADD FOREIGN KEY ("section_id") REFERENCES "sections" ("id");

ALTER TABLE "section_meetings" ADD FOREIGN KEY ("room_id") REFERENCES "rooms" ("id");

ALTER TABLE "enrollments" ADD FOREIGN KEY ("student_id") REFERENCES "students" ("id");

ALTER TABLE "enrollments" ADD FOREIGN KEY ("section_id") REFERENCES "sections" ("id");

ALTER TABLE "assessments" ADD FOREIGN KEY ("section_id") REFERENCES "sections" ("id");

ALTER TABLE "assessment_scores" ADD FOREIGN KEY ("assessment_id") REFERENCES "assessments" ("id");

ALTER TABLE "assessment_scores" ADD FOREIGN KEY ("enrollment_id") REFERENCES "enrollments" ("id");

ALTER TABLE "final_grades" ADD FOREIGN KEY ("enrollment_id") REFERENCES "enrollments" ("id");

ALTER TABLE "final_grades" ADD FOREIGN KEY ("grade_code") REFERENCES "grade_points" ("code");

ALTER TABLE "final_grades" ADD FOREIGN KEY ("posted_by") REFERENCES "instructors" ("id");

ALTER TABLE "final_grades" ADD FOREIGN KEY ("supersedes_id") REFERENCES "final_grades" ("id");

ALTER TABLE "attendance_records" ADD FOREIGN KEY ("enrollment_id") REFERENCES "enrollments" ("id");

ALTER TABLE "attendance_records" ADD FOREIGN KEY ("recorded_by") REFERENCES "instructors" ("id");

ALTER TABLE "degree_conferrals" ADD FOREIGN KEY ("student_program_id") REFERENCES "student_programs" ("id");

ALTER TABLE "degree_conferrals" ADD FOREIGN KEY ("term_id") REFERENCES "terms" ("id");

ALTER TABLE "account_charges" ADD FOREIGN KEY ("student_id") REFERENCES "students" ("id");

ALTER TABLE "account_charges" ADD FOREIGN KEY ("term_id") REFERENCES "terms" ("id");

ALTER TABLE "account_charges" ADD FOREIGN KEY ("posted_by") REFERENCES "staff_users" ("id");

ALTER TABLE "account_payments" ADD FOREIGN KEY ("student_id") REFERENCES "students" ("id");

ALTER TABLE "financial_aid_awards" ADD FOREIGN KEY ("student_id") REFERENCES "students" ("id");

ALTER TABLE "financial_aid_awards" ADD FOREIGN KEY ("term_id") REFERENCES "terms" ("id");
MySQL
mysql.sql MySQL
CREATE TABLE `departments` (
  `id` uuid PRIMARY KEY,
  `code` varchar(10) UNIQUE NOT NULL COMMENT 'e.g. CS, MATH, HIST',
  `name` varchar(200) NOT NULL
);

CREATE TABLE `terms` (
  `id` uuid PRIMARY KEY,
  `code` varchar(20) UNIQUE NOT NULL COMMENT 'e.g. 2026FA',
  `name` varchar(60) NOT NULL COMMENT 'e.g. Fall 2026',
  `starts_on` date NOT NULL,
  `ends_on` date NOT NULL,
  `registration_opens_at` timestamptz,
  `add_drop_ends_on` date NOT NULL COMMENT 'Drops before this leave no trace on the transcript',
  `withdraw_ends_on` date NOT NULL COMMENT 'Withdrawals after add/drop and before this record a W',
  `status` ENUM ('planned', 'registration_open', 'in_session', 'grades_due', 'closed') NOT NULL DEFAULT 'planned'
);

CREATE TABLE `buildings` (
  `id` uuid PRIMARY KEY,
  `code` varchar(10) UNIQUE NOT NULL,
  `name` varchar(200) NOT NULL
);

CREATE TABLE `rooms` (
  `id` uuid PRIMARY KEY,
  `building_id` uuid NOT NULL,
  `number` varchar(20) NOT NULL,
  `capacity` smallint NOT NULL,
  `kind` ENUM ('classroom', 'lecture_hall', 'lab', 'seminar') NOT NULL DEFAULT 'classroom'
);

CREATE TABLE `students` (
  `id` uuid PRIMARY KEY,
  `student_number` varchar(20) UNIQUE NOT NULL COMMENT 'The ID on the card and the transcript. FKs use the uuid.',
  `legal_first_name` varchar(100) NOT NULL,
  `legal_last_name` varchar(100) NOT NULL,
  `preferred_name` varchar(100) COMMENT 'Shown in rosters and class lists; the legal name stays on official documents',
  `date_of_birth` date,
  `email` varchar(254) UNIQUE NOT NULL,
  `phone` varchar(30),
  `status` ENUM ('applicant', 'active', 'on_leave', 'withdrawn', 'graduated') NOT NULL DEFAULT 'active',
  `admitted_term_id` uuid,
  `created_at` timestamptz NOT NULL DEFAULT (now())
);

CREATE TABLE `student_programs` (
  `id` uuid PRIMARY KEY,
  `student_id` uuid NOT NULL,
  `program_id` uuid NOT NULL,
  `role` ENUM ('major', 'minor', 'concentration') NOT NULL DEFAULT 'major',
  `catalog_term_id` uuid NOT NULL COMMENT 'Catalog year: requirements are read as of this term, so later changes do not move the goalposts',
  `declared_on` date NOT NULL,
  `status` ENUM ('active', 'completed', 'dropped') NOT NULL DEFAULT 'active'
);

CREATE TABLE `emergency_contacts` (
  `id` uuid PRIMARY KEY,
  `student_id` uuid NOT NULL,
  `name` varchar(200) NOT NULL,
  `relationship` varchar(60) NOT NULL,
  `phone` varchar(30) NOT NULL,
  `priority` smallint NOT NULL DEFAULT 1
);

CREATE TABLE `student_holds` (
  `id` uuid PRIMARY KEY,
  `student_id` uuid NOT NULL,
  `reason` ENUM ('financial', 'advising', 'registrar', 'disciplinary', 'immunization') NOT NULL,
  `blocks_registration` boolean NOT NULL DEFAULT true,
  `blocks_transcript` boolean NOT NULL DEFAULT false,
  `placed_at` timestamptz NOT NULL DEFAULT (now()),
  `placed_by` uuid NOT NULL,
  `released_at` timestamptz,
  `released_by` uuid
);

CREATE TABLE `instructors` (
  `id` uuid PRIMARY KEY,
  `employee_number` varchar(20) UNIQUE NOT NULL,
  `first_name` varchar(100) NOT NULL,
  `last_name` varchar(100) NOT NULL,
  `email` varchar(254) UNIQUE NOT NULL,
  `department_id` uuid NOT NULL COMMENT 'Home department',
  `title` varchar(100) COMMENT 'e.g. Assistant Professor, Lecturer',
  `active` boolean NOT NULL DEFAULT true
);

CREATE TABLE `advisor_assignments` (
  `id` uuid PRIMARY KEY,
  `student_id` uuid NOT NULL,
  `instructor_id` uuid NOT NULL,
  `starts_on` date NOT NULL,
  `ends_on` date COMMENT 'Null for the current advisor'
);

CREATE TABLE `staff_users` (
  `id` uuid PRIMARY KEY,
  `email` varchar(254) UNIQUE NOT NULL,
  `name` varchar(200) NOT NULL,
  `office` ENUM ('registrar', 'bursar', 'advising', 'admissions') NOT NULL
);

CREATE TABLE `programs` (
  `id` uuid PRIMARY KEY,
  `department_id` uuid NOT NULL,
  `code` varchar(20) UNIQUE NOT NULL COMMENT 'e.g. BS-CS',
  `name` varchar(200) NOT NULL,
  `level` ENUM ('associate', 'bachelor', 'master', 'doctorate', 'certificate') NOT NULL,
  `credits_required` numeric(5,1) NOT NULL,
  `active` boolean NOT NULL DEFAULT true
);

CREATE TABLE `courses` (
  `id` uuid PRIMARY KEY,
  `department_id` uuid NOT NULL,
  `subject_code` varchar(10) NOT NULL COMMENT 'e.g. CS',
  `number` varchar(10) NOT NULL COMMENT 'e.g. 101',
  `title` varchar(200) NOT NULL,
  `credits` numeric(3,1) NOT NULL,
  `description` text,
  `active` boolean NOT NULL DEFAULT true
);

CREATE TABLE `course_prerequisites` (
  `course_id` uuid NOT NULL,
  `required_course_id` uuid NOT NULL,
  `minimum_grade` varchar(2) COMMENT 'Null means any passing grade',
  `concurrent_allowed` boolean NOT NULL DEFAULT false COMMENT 'True for a corequisite that may be taken the same term',
  PRIMARY KEY (`course_id`, `required_course_id`)
);

CREATE TABLE `program_requirements` (
  `id` uuid PRIMARY KEY,
  `program_id` uuid NOT NULL,
  `course_id` uuid NOT NULL,
  `requirement_group` varchar(100) NOT NULL COMMENT 'e.g. Core, Math, Electives',
  `required` boolean NOT NULL DEFAULT true COMMENT 'False for courses that count toward an elective group',
  `effective_term_id` uuid NOT NULL COMMENT 'First catalog year this requirement applies to',
  `retired_term_id` uuid
);

CREATE TABLE `sections` (
  `id` uuid PRIMARY KEY,
  `course_id` uuid NOT NULL,
  `term_id` uuid NOT NULL,
  `section_number` varchar(10) NOT NULL COMMENT 'e.g. 001, L02',
  `capacity` smallint NOT NULL,
  `waitlist_capacity` smallint NOT NULL DEFAULT 0,
  `delivery` ENUM ('in_person', 'online', 'hybrid') NOT NULL DEFAULT 'in_person',
  `status` ENUM ('scheduled', 'open', 'closed', 'cancelled') NOT NULL DEFAULT 'scheduled'
);

CREATE TABLE `section_instructors` (
  `section_id` uuid NOT NULL,
  `instructor_id` uuid NOT NULL,
  `role` ENUM ('primary', 'secondary', 'teaching_assistant') NOT NULL DEFAULT 'primary',
  PRIMARY KEY (`section_id`, `instructor_id`)
);

CREATE TABLE `section_meetings` (
  `id` uuid PRIMARY KEY,
  `section_id` uuid NOT NULL,
  `room_id` uuid COMMENT 'Null for online meetings',
  `day_of_week` smallint NOT NULL COMMENT '1 = Monday ... 7 = Sunday',
  `starts_at` time NOT NULL,
  `ends_at` time NOT NULL
);

CREATE TABLE `enrollments` (
  `id` uuid PRIMARY KEY,
  `student_id` uuid NOT NULL,
  `section_id` uuid NOT NULL,
  `status` ENUM ('enrolled', 'waitlisted', 'dropped', 'withdrawn', 'completed') NOT NULL,
  `grading_basis` ENUM ('letter', 'pass_fail', 'audit') NOT NULL DEFAULT 'letter',
  `credits` numeric(3,1) NOT NULL COMMENT 'Copied from the course at enrollment; variable-credit courses differ per student',
  `waitlist_position` smallint,
  `enrolled_at` timestamptz NOT NULL DEFAULT (now()),
  `status_changed_at` timestamptz NOT NULL DEFAULT (now())
);

CREATE TABLE `assessments` (
  `id` uuid PRIMARY KEY,
  `section_id` uuid NOT NULL,
  `name` varchar(120) NOT NULL COMMENT 'e.g. Midterm, Lab 3',
  `weight` numeric(5,2) NOT NULL COMMENT 'Percent of the final grade',
  `max_points` numeric(6,2) NOT NULL,
  `due_at` timestamptz
);

CREATE TABLE `assessment_scores` (
  `assessment_id` uuid NOT NULL,
  `enrollment_id` uuid NOT NULL,
  `points` numeric(6,2),
  `excused` boolean NOT NULL DEFAULT false,
  `recorded_at` timestamptz NOT NULL DEFAULT (now()),
  PRIMARY KEY (`assessment_id`, `enrollment_id`)
);

CREATE TABLE `grade_points` (
  `code` varchar(2) PRIMARY KEY COMMENT 'A, A-, B+ ... F, P, NP, W, I',
  `points` numeric(3,2) COMMENT 'Null for grades that carry no points, e.g. P or W',
  `counts_in_gpa` boolean NOT NULL,
  `earns_credit` boolean NOT NULL
);

CREATE TABLE `final_grades` (
  `id` uuid PRIMARY KEY,
  `enrollment_id` uuid NOT NULL,
  `grade_code` varchar(2) NOT NULL,
  `posted_by` uuid NOT NULL,
  `posted_at` timestamptz NOT NULL DEFAULT (now()),
  `supersedes_id` uuid COMMENT 'Set when this row is a grade change',
  `change_reason` text
);

CREATE TABLE `attendance_records` (
  `enrollment_id` uuid NOT NULL,
  `class_date` date NOT NULL,
  `status` ENUM ('present', 'absent', 'late', 'excused') NOT NULL,
  `recorded_by` uuid NOT NULL,
  PRIMARY KEY (`enrollment_id`, `class_date`)
);

CREATE TABLE `degree_conferrals` (
  `id` uuid PRIMARY KEY,
  `student_program_id` uuid UNIQUE NOT NULL,
  `term_id` uuid NOT NULL,
  `conferred_on` date NOT NULL,
  `honors` varchar(60) COMMENT 'e.g. cum laude'
);

CREATE TABLE `account_charges` (
  `id` uuid PRIMARY KEY,
  `student_id` uuid NOT NULL,
  `term_id` uuid NOT NULL,
  `kind` ENUM ('tuition', 'fee', 'housing', 'meal_plan', 'adjustment') NOT NULL,
  `description` varchar(200) NOT NULL,
  `amount_cents` integer NOT NULL COMMENT 'Negative for credits and refunds of charges',
  `posted_at` timestamptz NOT NULL DEFAULT (now()),
  `posted_by` uuid COMMENT 'Null for charges posted automatically at registration'
);

CREATE TABLE `account_payments` (
  `id` uuid PRIMARY KEY,
  `student_id` uuid NOT NULL,
  `amount_cents` integer NOT NULL,
  `method` ENUM ('card', 'bank_transfer', 'check', 'cash') NOT NULL,
  `paid_at` timestamptz NOT NULL DEFAULT (now()),
  `external_reference` varchar(100)
);

CREATE TABLE `financial_aid_awards` (
  `id` uuid PRIMARY KEY,
  `student_id` uuid NOT NULL,
  `term_id` uuid NOT NULL,
  `kind` ENUM ('grant', 'scholarship', 'loan', 'work_study') NOT NULL,
  `name` varchar(200) NOT NULL COMMENT 'e.g. Merit Scholarship, Federal Direct Loan',
  `amount_cents` integer NOT NULL,
  `status` ENUM ('offered', 'accepted', 'declined', 'disbursed', 'cancelled') NOT NULL DEFAULT 'offered',
  `disbursed_at` timestamptz
);

CREATE UNIQUE INDEX `rooms_index_0` ON `rooms` (`building_id`, `number`);

CREATE UNIQUE INDEX `courses_index_1` ON `courses` (`subject_code`, `number`);

CREATE UNIQUE INDEX `sections_index_2` ON `sections` (`course_id`, `term_id`, `section_number`);

CREATE UNIQUE INDEX `enrollments_index_3` ON `enrollments` (`student_id`, `section_id`);

CREATE INDEX `enrollments_index_4` ON `enrollments` (`section_id`, `status`);

CREATE INDEX `final_grades_index_5` ON `final_grades` (`enrollment_id`);

ALTER TABLE `departments` COMMENT = 'Academic departments. Own courses, programs and faculty appointments.';

ALTER TABLE `terms` COMMENT = 'Academic terms. Every deadline enrollment rules check against lives here, not in code.';

ALTER TABLE `buildings` COMMENT = 'Campus buildings.';

ALTER TABLE `rooms` COMMENT = 'Bookable teaching spaces. Capacity is checked when a section meeting is scheduled.';

ALTER TABLE `students` COMMENT = 'One row per person who has ever enrolled. A student who leaves and returns keeps the same row and history.';

ALTER TABLE `student_programs` COMMENT = 'Majors and minors a student is pursuing. A double major is two rows.';

ALTER TABLE `emergency_contacts` COMMENT = 'Who to call, in order.';

ALTER TABLE `student_holds` COMMENT = 'Registration and transcript blocks. A hold is released, never deleted, so "why could I not register in March?" has an answer.';

ALTER TABLE `instructors` COMMENT = 'Teaching faculty. Also the pool advisors are drawn from.';

ALTER TABLE `advisor_assignments` COMMENT = 'Who advised a student and when. Effective-dated rather than overwritten.';

ALTER TABLE `staff_users` COMMENT = 'Registrar, bursar and advising staff who act on records. Referenced wherever an action needs an author.';

ALTER TABLE `programs` COMMENT = 'Degree programs, majors and minors.';

ALTER TABLE `courses` COMMENT = 'The catalog entry: what a course IS. When and where it runs is a section.';

ALTER TABLE `course_prerequisites` COMMENT = 'What must be completed before a course. Checked at registration against the final grades already posted.';

ALTER TABLE `program_requirements` COMMENT = 'Degree requirements, versioned by catalog year so a student is audited against the rules they declared under.';

ALTER TABLE `sections` COMMENT = 'A course offered in a term. Enrollments, meetings and instructors attach here, never to the course.';

ALTER TABLE `section_instructors` COMMENT = 'Who teaches a section. Team-taught sections have several rows; only primary can post final grades.';

ALTER TABLE `section_meetings` COMMENT = 'Weekly meeting pattern. A Monday-Wednesday-Friday section is three rows.';

ALTER TABLE `enrollments` COMMENT = 'A student in a section. Dropping or withdrawing changes status; the row stays, which is what puts a W on the transcript.';

ALTER TABLE `assessments` COMMENT = 'Graded work in a section.';

ALTER TABLE `assessment_scores` COMMENT = 'The score one student earned on one assessment. The gradebook; final grades are posted separately.';

ALTER TABLE `grade_points` COMMENT = 'The grading scale. GPA rules are data, so a policy change is an update, not a deploy.';

ALTER TABLE `final_grades` COMMENT = 'Posted final grades, append-only. A grade change is a new row pointing at the one it replaces; the latest row per enrollment is the grade of record. GPA is computed from these, never stored.';

ALTER TABLE `attendance_records` COMMENT = 'Attendance per student per class day.';

ALTER TABLE `degree_conferrals` COMMENT = 'A degree awarded. One per completed program.';

ALTER TABLE `account_charges` COMMENT = 'Tuition, fees and adjustments, as ledger entries. The balance is the sum of charges minus payments and aid.';

ALTER TABLE `account_payments` COMMENT = 'Money received toward a student account.';

ALTER TABLE `financial_aid_awards` COMMENT = 'Aid offered and disbursed. Only disbursed awards reduce the account balance.';

ALTER TABLE `rooms` ADD FOREIGN KEY (`building_id`) REFERENCES `buildings` (`id`);

ALTER TABLE `students` ADD FOREIGN KEY (`admitted_term_id`) REFERENCES `terms` (`id`);

ALTER TABLE `student_programs` ADD FOREIGN KEY (`student_id`) REFERENCES `students` (`id`);

ALTER TABLE `student_programs` ADD FOREIGN KEY (`program_id`) REFERENCES `programs` (`id`);

ALTER TABLE `student_programs` ADD FOREIGN KEY (`catalog_term_id`) REFERENCES `terms` (`id`);

ALTER TABLE `emergency_contacts` ADD FOREIGN KEY (`student_id`) REFERENCES `students` (`id`);

ALTER TABLE `student_holds` ADD FOREIGN KEY (`student_id`) REFERENCES `students` (`id`);

ALTER TABLE `student_holds` ADD FOREIGN KEY (`placed_by`) REFERENCES `staff_users` (`id`);

ALTER TABLE `student_holds` ADD FOREIGN KEY (`released_by`) REFERENCES `staff_users` (`id`);

ALTER TABLE `instructors` ADD FOREIGN KEY (`department_id`) REFERENCES `departments` (`id`);

ALTER TABLE `advisor_assignments` ADD FOREIGN KEY (`student_id`) REFERENCES `students` (`id`);

ALTER TABLE `advisor_assignments` ADD FOREIGN KEY (`instructor_id`) REFERENCES `instructors` (`id`);

ALTER TABLE `programs` ADD FOREIGN KEY (`department_id`) REFERENCES `departments` (`id`);

ALTER TABLE `courses` ADD FOREIGN KEY (`department_id`) REFERENCES `departments` (`id`);

ALTER TABLE `course_prerequisites` ADD FOREIGN KEY (`course_id`) REFERENCES `courses` (`id`);

ALTER TABLE `course_prerequisites` ADD FOREIGN KEY (`required_course_id`) REFERENCES `courses` (`id`);

ALTER TABLE `course_prerequisites` ADD FOREIGN KEY (`minimum_grade`) REFERENCES `grade_points` (`code`);

ALTER TABLE `program_requirements` ADD FOREIGN KEY (`program_id`) REFERENCES `programs` (`id`);

ALTER TABLE `program_requirements` ADD FOREIGN KEY (`course_id`) REFERENCES `courses` (`id`);

ALTER TABLE `program_requirements` ADD FOREIGN KEY (`effective_term_id`) REFERENCES `terms` (`id`);

ALTER TABLE `program_requirements` ADD FOREIGN KEY (`retired_term_id`) REFERENCES `terms` (`id`);

ALTER TABLE `sections` ADD FOREIGN KEY (`course_id`) REFERENCES `courses` (`id`);

ALTER TABLE `sections` ADD FOREIGN KEY (`term_id`) REFERENCES `terms` (`id`);

ALTER TABLE `section_instructors` ADD FOREIGN KEY (`section_id`) REFERENCES `sections` (`id`);

ALTER TABLE `section_instructors` ADD FOREIGN KEY (`instructor_id`) REFERENCES `instructors` (`id`);

ALTER TABLE `section_meetings` ADD FOREIGN KEY (`section_id`) REFERENCES `sections` (`id`);

ALTER TABLE `section_meetings` ADD FOREIGN KEY (`room_id`) REFERENCES `rooms` (`id`);

ALTER TABLE `enrollments` ADD FOREIGN KEY (`student_id`) REFERENCES `students` (`id`);

ALTER TABLE `enrollments` ADD FOREIGN KEY (`section_id`) REFERENCES `sections` (`id`);

ALTER TABLE `assessments` ADD FOREIGN KEY (`section_id`) REFERENCES `sections` (`id`);

ALTER TABLE `assessment_scores` ADD FOREIGN KEY (`assessment_id`) REFERENCES `assessments` (`id`);

ALTER TABLE `assessment_scores` ADD FOREIGN KEY (`enrollment_id`) REFERENCES `enrollments` (`id`);

ALTER TABLE `final_grades` ADD FOREIGN KEY (`enrollment_id`) REFERENCES `enrollments` (`id`);

ALTER TABLE `final_grades` ADD FOREIGN KEY (`grade_code`) REFERENCES `grade_points` (`code`);

ALTER TABLE `final_grades` ADD FOREIGN KEY (`posted_by`) REFERENCES `instructors` (`id`);

ALTER TABLE `final_grades` ADD FOREIGN KEY (`supersedes_id`) REFERENCES `final_grades` (`id`);

ALTER TABLE `attendance_records` ADD FOREIGN KEY (`enrollment_id`) REFERENCES `enrollments` (`id`);

ALTER TABLE `attendance_records` ADD FOREIGN KEY (`recorded_by`) REFERENCES `instructors` (`id`);

ALTER TABLE `degree_conferrals` ADD FOREIGN KEY (`student_program_id`) REFERENCES `student_programs` (`id`);

ALTER TABLE `degree_conferrals` ADD FOREIGN KEY (`term_id`) REFERENCES `terms` (`id`);

ALTER TABLE `account_charges` ADD FOREIGN KEY (`student_id`) REFERENCES `students` (`id`);

ALTER TABLE `account_charges` ADD FOREIGN KEY (`term_id`) REFERENCES `terms` (`id`);

ALTER TABLE `account_charges` ADD FOREIGN KEY (`posted_by`) REFERENCES `staff_users` (`id`);

ALTER TABLE `account_payments` ADD FOREIGN KEY (`student_id`) REFERENCES `students` (`id`);

ALTER TABLE `financial_aid_awards` ADD FOREIGN KEY (`student_id`) REFERENCES `students` (`id`);

ALTER TABLE `financial_aid_awards` ADD FOREIGN KEY (`term_id`) REFERENCES `terms` (`id`);
SQL Server
sql-server.sql SQL Server
CREATE TABLE [departments] (
  [id] uuid PRIMARY KEY,
  [code] varchar(10) UNIQUE NOT NULL,
  [name] varchar(200) NOT NULL
)
GO

CREATE TABLE [terms] (
  [id] uuid PRIMARY KEY,
  [code] varchar(20) UNIQUE NOT NULL,
  [name] varchar(60) NOT NULL,
  [starts_on] date NOT NULL,
  [ends_on] date NOT NULL,
  [registration_opens_at] timestamptz,
  [add_drop_ends_on] date NOT NULL,
  [withdraw_ends_on] date NOT NULL,
  [status] nvarchar(255) NOT NULL CHECK ([status] IN ('planned', 'registration_open', 'in_session', 'grades_due', 'closed')) DEFAULT 'planned'
)
GO

CREATE TABLE [buildings] (
  [id] uuid PRIMARY KEY,
  [code] varchar(10) UNIQUE NOT NULL,
  [name] varchar(200) NOT NULL
)
GO

CREATE TABLE [rooms] (
  [id] uuid PRIMARY KEY,
  [building_id] uuid NOT NULL,
  [number] varchar(20) NOT NULL,
  [capacity] smallint NOT NULL,
  [kind] nvarchar(255) NOT NULL CHECK ([kind] IN ('classroom', 'lecture_hall', 'lab', 'seminar')) DEFAULT 'classroom'
)
GO

CREATE TABLE [students] (
  [id] uuid PRIMARY KEY,
  [student_number] varchar(20) UNIQUE NOT NULL,
  [legal_first_name] varchar(100) NOT NULL,
  [legal_last_name] varchar(100) NOT NULL,
  [preferred_name] varchar(100),
  [date_of_birth] date,
  [email] varchar(254) UNIQUE NOT NULL,
  [phone] varchar(30),
  [status] nvarchar(255) NOT NULL CHECK ([status] IN ('applicant', 'active', 'on_leave', 'withdrawn', 'graduated')) DEFAULT 'active',
  [admitted_term_id] uuid,
  [created_at] timestamptz NOT NULL DEFAULT (now())
)
GO

CREATE TABLE [student_programs] (
  [id] uuid PRIMARY KEY,
  [student_id] uuid NOT NULL,
  [program_id] uuid NOT NULL,
  [role] nvarchar(255) NOT NULL CHECK ([role] IN ('major', 'minor', 'concentration')) DEFAULT 'major',
  [catalog_term_id] uuid NOT NULL,
  [declared_on] date NOT NULL,
  [status] nvarchar(255) NOT NULL CHECK ([status] IN ('active', 'completed', 'dropped')) DEFAULT 'active'
)
GO

CREATE TABLE [emergency_contacts] (
  [id] uuid PRIMARY KEY,
  [student_id] uuid NOT NULL,
  [name] varchar(200) NOT NULL,
  [relationship] varchar(60) NOT NULL,
  [phone] varchar(30) NOT NULL,
  [priority] smallint NOT NULL DEFAULT (1)
)
GO

CREATE TABLE [student_holds] (
  [id] uuid PRIMARY KEY,
  [student_id] uuid NOT NULL,
  [reason] nvarchar(255) NOT NULL CHECK ([reason] IN ('financial', 'advising', 'registrar', 'disciplinary', 'immunization')),
  [blocks_registration] boolean NOT NULL DEFAULT (true),
  [blocks_transcript] boolean NOT NULL DEFAULT (false),
  [placed_at] timestamptz NOT NULL DEFAULT (now()),
  [placed_by] uuid NOT NULL,
  [released_at] timestamptz,
  [released_by] uuid
)
GO

CREATE TABLE [instructors] (
  [id] uuid PRIMARY KEY,
  [employee_number] varchar(20) UNIQUE NOT NULL,
  [first_name] varchar(100) NOT NULL,
  [last_name] varchar(100) NOT NULL,
  [email] varchar(254) UNIQUE NOT NULL,
  [department_id] uuid NOT NULL,
  [title] varchar(100),
  [active] boolean NOT NULL DEFAULT (true)
)
GO

CREATE TABLE [advisor_assignments] (
  [id] uuid PRIMARY KEY,
  [student_id] uuid NOT NULL,
  [instructor_id] uuid NOT NULL,
  [starts_on] date NOT NULL,
  [ends_on] date
)
GO

CREATE TABLE [staff_users] (
  [id] uuid PRIMARY KEY,
  [email] varchar(254) UNIQUE NOT NULL,
  [name] varchar(200) NOT NULL,
  [office] nvarchar(255) NOT NULL CHECK ([office] IN ('registrar', 'bursar', 'advising', 'admissions'))
)
GO

CREATE TABLE [programs] (
  [id] uuid PRIMARY KEY,
  [department_id] uuid NOT NULL,
  [code] varchar(20) UNIQUE NOT NULL,
  [name] varchar(200) NOT NULL,
  [level] nvarchar(255) NOT NULL CHECK ([level] IN ('associate', 'bachelor', 'master', 'doctorate', 'certificate')),
  [credits_required] numeric(5,1) NOT NULL,
  [active] boolean NOT NULL DEFAULT (true)
)
GO

CREATE TABLE [courses] (
  [id] uuid PRIMARY KEY,
  [department_id] uuid NOT NULL,
  [subject_code] varchar(10) NOT NULL,
  [number] varchar(10) NOT NULL,
  [title] varchar(200) NOT NULL,
  [credits] numeric(3,1) NOT NULL,
  [description] text,
  [active] boolean NOT NULL DEFAULT (true)
)
GO

CREATE TABLE [course_prerequisites] (
  [course_id] uuid NOT NULL,
  [required_course_id] uuid NOT NULL,
  [minimum_grade] varchar(2),
  [concurrent_allowed] boolean NOT NULL DEFAULT (false),
  PRIMARY KEY ([course_id], [required_course_id])
)
GO

CREATE TABLE [program_requirements] (
  [id] uuid PRIMARY KEY,
  [program_id] uuid NOT NULL,
  [course_id] uuid NOT NULL,
  [requirement_group] varchar(100) NOT NULL,
  [required] boolean NOT NULL DEFAULT (true),
  [effective_term_id] uuid NOT NULL,
  [retired_term_id] uuid
)
GO

CREATE TABLE [sections] (
  [id] uuid PRIMARY KEY,
  [course_id] uuid NOT NULL,
  [term_id] uuid NOT NULL,
  [section_number] varchar(10) NOT NULL,
  [capacity] smallint NOT NULL,
  [waitlist_capacity] smallint NOT NULL DEFAULT (0),
  [delivery] nvarchar(255) NOT NULL CHECK ([delivery] IN ('in_person', 'online', 'hybrid')) DEFAULT 'in_person',
  [status] nvarchar(255) NOT NULL CHECK ([status] IN ('scheduled', 'open', 'closed', 'cancelled')) DEFAULT 'scheduled'
)
GO

CREATE TABLE [section_instructors] (
  [section_id] uuid NOT NULL,
  [instructor_id] uuid NOT NULL,
  [role] nvarchar(255) NOT NULL CHECK ([role] IN ('primary', 'secondary', 'teaching_assistant')) DEFAULT 'primary',
  PRIMARY KEY ([section_id], [instructor_id])
)
GO

CREATE TABLE [section_meetings] (
  [id] uuid PRIMARY KEY,
  [section_id] uuid NOT NULL,
  [room_id] uuid,
  [day_of_week] smallint NOT NULL,
  [starts_at] time NOT NULL,
  [ends_at] time NOT NULL
)
GO

CREATE TABLE [enrollments] (
  [id] uuid PRIMARY KEY,
  [student_id] uuid NOT NULL,
  [section_id] uuid NOT NULL,
  [status] nvarchar(255) NOT NULL CHECK ([status] IN ('enrolled', 'waitlisted', 'dropped', 'withdrawn', 'completed')),
  [grading_basis] nvarchar(255) NOT NULL CHECK ([grading_basis] IN ('letter', 'pass_fail', 'audit')) DEFAULT 'letter',
  [credits] numeric(3,1) NOT NULL,
  [waitlist_position] smallint,
  [enrolled_at] timestamptz NOT NULL DEFAULT (now()),
  [status_changed_at] timestamptz NOT NULL DEFAULT (now())
)
GO

CREATE TABLE [assessments] (
  [id] uuid PRIMARY KEY,
  [section_id] uuid NOT NULL,
  [name] varchar(120) NOT NULL,
  [weight] numeric(5,2) NOT NULL,
  [max_points] numeric(6,2) NOT NULL,
  [due_at] timestamptz
)
GO

CREATE TABLE [assessment_scores] (
  [assessment_id] uuid NOT NULL,
  [enrollment_id] uuid NOT NULL,
  [points] numeric(6,2),
  [excused] boolean NOT NULL DEFAULT (false),
  [recorded_at] timestamptz NOT NULL DEFAULT (now()),
  PRIMARY KEY ([assessment_id], [enrollment_id])
)
GO

CREATE TABLE [grade_points] (
  [code] varchar(2) PRIMARY KEY,
  [points] numeric(3,2),
  [counts_in_gpa] boolean NOT NULL,
  [earns_credit] boolean NOT NULL
)
GO

CREATE TABLE [final_grades] (
  [id] uuid PRIMARY KEY,
  [enrollment_id] uuid NOT NULL,
  [grade_code] varchar(2) NOT NULL,
  [posted_by] uuid NOT NULL,
  [posted_at] timestamptz NOT NULL DEFAULT (now()),
  [supersedes_id] uuid,
  [change_reason] text
)
GO

CREATE TABLE [attendance_records] (
  [enrollment_id] uuid NOT NULL,
  [class_date] date NOT NULL,
  [status] nvarchar(255) NOT NULL CHECK ([status] IN ('present', 'absent', 'late', 'excused')),
  [recorded_by] uuid NOT NULL,
  PRIMARY KEY ([enrollment_id], [class_date])
)
GO

CREATE TABLE [degree_conferrals] (
  [id] uuid PRIMARY KEY,
  [student_program_id] uuid UNIQUE NOT NULL,
  [term_id] uuid NOT NULL,
  [conferred_on] date NOT NULL,
  [honors] varchar(60)
)
GO

CREATE TABLE [account_charges] (
  [id] uuid PRIMARY KEY,
  [student_id] uuid NOT NULL,
  [term_id] uuid NOT NULL,
  [kind] nvarchar(255) NOT NULL CHECK ([kind] IN ('tuition', 'fee', 'housing', 'meal_plan', 'adjustment')),
  [description] varchar(200) NOT NULL,
  [amount_cents] integer NOT NULL,
  [posted_at] timestamptz NOT NULL DEFAULT (now()),
  [posted_by] uuid
)
GO

CREATE TABLE [account_payments] (
  [id] uuid PRIMARY KEY,
  [student_id] uuid NOT NULL,
  [amount_cents] integer NOT NULL,
  [method] nvarchar(255) NOT NULL CHECK ([method] IN ('card', 'bank_transfer', 'check', 'cash')),
  [paid_at] timestamptz NOT NULL DEFAULT (now()),
  [external_reference] varchar(100)
)
GO

CREATE TABLE [financial_aid_awards] (
  [id] uuid PRIMARY KEY,
  [student_id] uuid NOT NULL,
  [term_id] uuid NOT NULL,
  [kind] nvarchar(255) NOT NULL CHECK ([kind] IN ('grant', 'scholarship', 'loan', 'work_study')),
  [name] varchar(200) NOT NULL,
  [amount_cents] integer NOT NULL,
  [status] nvarchar(255) NOT NULL CHECK ([status] IN ('offered', 'accepted', 'declined', 'disbursed', 'cancelled')) DEFAULT 'offered',
  [disbursed_at] timestamptz
)
GO

CREATE UNIQUE INDEX [rooms_index_0] ON [rooms] ("building_id", "number")
GO

CREATE UNIQUE INDEX [courses_index_1] ON [courses] ("subject_code", "number")
GO

CREATE UNIQUE INDEX [sections_index_2] ON [sections] ("course_id", "term_id", "section_number")
GO

CREATE UNIQUE INDEX [enrollments_index_3] ON [enrollments] ("student_id", "section_id")
GO

CREATE INDEX [enrollments_index_4] ON [enrollments] ("section_id", "status")
GO

CREATE INDEX [final_grades_index_5] ON [final_grades] ("enrollment_id")
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Academic departments. Own courses, programs and faculty appointments.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'departments';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'e.g. CS, MATH, HIST',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'departments',
@level2type = N'Column', @level2name = 'code';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Academic terms. Every deadline enrollment rules check against lives here, not in code.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'terms';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'e.g. 2026FA',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'terms',
@level2type = N'Column', @level2name = 'code';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'e.g. Fall 2026',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'terms',
@level2type = N'Column', @level2name = 'name';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Drops before this leave no trace on the transcript',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'terms',
@level2type = N'Column', @level2name = 'add_drop_ends_on';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Withdrawals after add/drop and before this record a W',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'terms',
@level2type = N'Column', @level2name = 'withdraw_ends_on';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Campus buildings.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'buildings';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Bookable teaching spaces. Capacity is checked when a section meeting is scheduled.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'rooms';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'One row per person who has ever enrolled. A student who leaves and returns keeps the same row and history.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'students';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'The ID on the card and the transcript. FKs use the uuid.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'students',
@level2type = N'Column', @level2name = 'student_number';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Shown in rosters and class lists; the legal name stays on official documents',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'students',
@level2type = N'Column', @level2name = 'preferred_name';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Majors and minors a student is pursuing. A double major is two rows.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'student_programs';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Catalog year: requirements are read as of this term, so later changes do not move the goalposts',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'student_programs',
@level2type = N'Column', @level2name = 'catalog_term_id';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Who to call, in order.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'emergency_contacts';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Registration and transcript blocks. A hold is released, never deleted, so "why could I not register in March?" has an answer.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'student_holds';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Teaching faculty. Also the pool advisors are drawn from.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'instructors';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Home department',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'instructors',
@level2type = N'Column', @level2name = 'department_id';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'e.g. Assistant Professor, Lecturer',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'instructors',
@level2type = N'Column', @level2name = 'title';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Who advised a student and when. Effective-dated rather than overwritten.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'advisor_assignments';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Null for the current advisor',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'advisor_assignments',
@level2type = N'Column', @level2name = 'ends_on';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Registrar, bursar and advising staff who act on records. Referenced wherever an action needs an author.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'staff_users';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Degree programs, majors and minors.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'programs';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'e.g. BS-CS',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'programs',
@level2type = N'Column', @level2name = 'code';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'The catalog entry: what a course IS. When and where it runs is a section.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'courses';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'e.g. CS',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'courses',
@level2type = N'Column', @level2name = 'subject_code';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'e.g. 101',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'courses',
@level2type = N'Column', @level2name = 'number';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'What must be completed before a course. Checked at registration against the final grades already posted.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'course_prerequisites';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Null means any passing grade',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'course_prerequisites',
@level2type = N'Column', @level2name = 'minimum_grade';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'True for a corequisite that may be taken the same term',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'course_prerequisites',
@level2type = N'Column', @level2name = 'concurrent_allowed';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Degree requirements, versioned by catalog year so a student is audited against the rules they declared under.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'program_requirements';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'e.g. Core, Math, Electives',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'program_requirements',
@level2type = N'Column', @level2name = 'requirement_group';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'False for courses that count toward an elective group',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'program_requirements',
@level2type = N'Column', @level2name = 'required';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'First catalog year this requirement applies to',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'program_requirements',
@level2type = N'Column', @level2name = 'effective_term_id';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'A course offered in a term. Enrollments, meetings and instructors attach here, never to the course.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'sections';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'e.g. 001, L02',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'sections',
@level2type = N'Column', @level2name = 'section_number';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Who teaches a section. Team-taught sections have several rows; only primary can post final grades.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'section_instructors';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Weekly meeting pattern. A Monday-Wednesday-Friday section is three rows.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'section_meetings';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Null for online meetings',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'section_meetings',
@level2type = N'Column', @level2name = 'room_id';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = '1 = Monday ... 7 = Sunday',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'section_meetings',
@level2type = N'Column', @level2name = 'day_of_week';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'A student in a section. Dropping or withdrawing changes status; the row stays, which is what puts a W on the transcript.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'enrollments';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Copied from the course at enrollment; variable-credit courses differ per student',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'enrollments',
@level2type = N'Column', @level2name = 'credits';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Graded work in a section.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'assessments';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'e.g. Midterm, Lab 3',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'assessments',
@level2type = N'Column', @level2name = 'name';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Percent of the final grade',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'assessments',
@level2type = N'Column', @level2name = 'weight';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'The score one student earned on one assessment. The gradebook; final grades are posted separately.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'assessment_scores';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'The grading scale. GPA rules are data, so a policy change is an update, not a deploy.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'grade_points';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'A, A-, B+ ... F, P, NP, W, I',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'grade_points',
@level2type = N'Column', @level2name = 'code';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Null for grades that carry no points, e.g. P or W',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'grade_points',
@level2type = N'Column', @level2name = 'points';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Posted final grades, append-only. A grade change is a new row pointing at the one it replaces; the latest row per enrollment is the grade of record. GPA is computed from these, never stored.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'final_grades';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Set when this row is a grade change',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'final_grades',
@level2type = N'Column', @level2name = 'supersedes_id';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Attendance per student per class day.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'attendance_records';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'A degree awarded. One per completed program.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'degree_conferrals';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'e.g. cum laude',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'degree_conferrals',
@level2type = N'Column', @level2name = 'honors';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Tuition, fees and adjustments, as ledger entries. The balance is the sum of charges minus payments and aid.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'account_charges';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Negative for credits and refunds of charges',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'account_charges',
@level2type = N'Column', @level2name = 'amount_cents';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Null for charges posted automatically at registration',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'account_charges',
@level2type = N'Column', @level2name = 'posted_by';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Money received toward a student account.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'account_payments';
GO

EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Aid offered and disbursed. Only disbursed awards reduce the account balance.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'financial_aid_awards';
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'e.g. Merit Scholarship, Federal Direct Loan',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table',  @level1name = 'financial_aid_awards',
@level2type = N'Column', @level2name = 'name';
GO

ALTER TABLE [rooms] ADD FOREIGN KEY ([building_id]) REFERENCES [buildings] ([id])
GO

ALTER TABLE [students] ADD FOREIGN KEY ([admitted_term_id]) REFERENCES [terms] ([id])
GO

ALTER TABLE [student_programs] ADD FOREIGN KEY ([student_id]) REFERENCES [students] ([id])
GO

ALTER TABLE [student_programs] ADD FOREIGN KEY ([program_id]) REFERENCES [programs] ([id])
GO

ALTER TABLE [student_programs] ADD FOREIGN KEY ([catalog_term_id]) REFERENCES [terms] ([id])
GO

ALTER TABLE [emergency_contacts] ADD FOREIGN KEY ([student_id]) REFERENCES [students] ([id])
GO

ALTER TABLE [student_holds] ADD FOREIGN KEY ([student_id]) REFERENCES [students] ([id])
GO

ALTER TABLE [student_holds] ADD FOREIGN KEY ([placed_by]) REFERENCES [staff_users] ([id])
GO

ALTER TABLE [student_holds] ADD FOREIGN KEY ([released_by]) REFERENCES [staff_users] ([id])
GO

ALTER TABLE [instructors] ADD FOREIGN KEY ([department_id]) REFERENCES [departments] ([id])
GO

ALTER TABLE [advisor_assignments] ADD FOREIGN KEY ([student_id]) REFERENCES [students] ([id])
GO

ALTER TABLE [advisor_assignments] ADD FOREIGN KEY ([instructor_id]) REFERENCES [instructors] ([id])
GO

ALTER TABLE [programs] ADD FOREIGN KEY ([department_id]) REFERENCES [departments] ([id])
GO

ALTER TABLE [courses] ADD FOREIGN KEY ([department_id]) REFERENCES [departments] ([id])
GO

ALTER TABLE [course_prerequisites] ADD FOREIGN KEY ([course_id]) REFERENCES [courses] ([id])
GO

ALTER TABLE [course_prerequisites] ADD FOREIGN KEY ([required_course_id]) REFERENCES [courses] ([id])
GO

ALTER TABLE [course_prerequisites] ADD FOREIGN KEY ([minimum_grade]) REFERENCES [grade_points] ([code])
GO

ALTER TABLE [program_requirements] ADD FOREIGN KEY ([program_id]) REFERENCES [programs] ([id])
GO

ALTER TABLE [program_requirements] ADD FOREIGN KEY ([course_id]) REFERENCES [courses] ([id])
GO

ALTER TABLE [program_requirements] ADD FOREIGN KEY ([effective_term_id]) REFERENCES [terms] ([id])
GO

ALTER TABLE [program_requirements] ADD FOREIGN KEY ([retired_term_id]) REFERENCES [terms] ([id])
GO

ALTER TABLE [sections] ADD FOREIGN KEY ([course_id]) REFERENCES [courses] ([id])
GO

ALTER TABLE [sections] ADD FOREIGN KEY ([term_id]) REFERENCES [terms] ([id])
GO

ALTER TABLE [section_instructors] ADD FOREIGN KEY ([section_id]) REFERENCES [sections] ([id])
GO

ALTER TABLE [section_instructors] ADD FOREIGN KEY ([instructor_id]) REFERENCES [instructors] ([id])
GO

ALTER TABLE [section_meetings] ADD FOREIGN KEY ([section_id]) REFERENCES [sections] ([id])
GO

ALTER TABLE [section_meetings] ADD FOREIGN KEY ([room_id]) REFERENCES [rooms] ([id])
GO

ALTER TABLE [enrollments] ADD FOREIGN KEY ([student_id]) REFERENCES [students] ([id])
GO

ALTER TABLE [enrollments] ADD FOREIGN KEY ([section_id]) REFERENCES [sections] ([id])
GO

ALTER TABLE [assessments] ADD FOREIGN KEY ([section_id]) REFERENCES [sections] ([id])
GO

ALTER TABLE [assessment_scores] ADD FOREIGN KEY ([assessment_id]) REFERENCES [assessments] ([id])
GO

ALTER TABLE [assessment_scores] ADD FOREIGN KEY ([enrollment_id]) REFERENCES [enrollments] ([id])
GO

ALTER TABLE [final_grades] ADD FOREIGN KEY ([enrollment_id]) REFERENCES [enrollments] ([id])
GO

ALTER TABLE [final_grades] ADD FOREIGN KEY ([grade_code]) REFERENCES [grade_points] ([code])
GO

ALTER TABLE [final_grades] ADD FOREIGN KEY ([posted_by]) REFERENCES [instructors] ([id])
GO

ALTER TABLE [final_grades] ADD FOREIGN KEY ([supersedes_id]) REFERENCES [final_grades] ([id])
GO

ALTER TABLE [attendance_records] ADD FOREIGN KEY ([enrollment_id]) REFERENCES [enrollments] ([id])
GO

ALTER TABLE [attendance_records] ADD FOREIGN KEY ([recorded_by]) REFERENCES [instructors] ([id])
GO

ALTER TABLE [degree_conferrals] ADD FOREIGN KEY ([student_program_id]) REFERENCES [student_programs] ([id])
GO

ALTER TABLE [degree_conferrals] ADD FOREIGN KEY ([term_id]) REFERENCES [terms] ([id])
GO

ALTER TABLE [account_charges] ADD FOREIGN KEY ([student_id]) REFERENCES [students] ([id])
GO

ALTER TABLE [account_charges] ADD FOREIGN KEY ([term_id]) REFERENCES [terms] ([id])
GO

ALTER TABLE [account_charges] ADD FOREIGN KEY ([posted_by]) REFERENCES [staff_users] ([id])
GO

ALTER TABLE [account_payments] ADD FOREIGN KEY ([student_id]) REFERENCES [students] ([id])
GO

ALTER TABLE [financial_aid_awards] ADD FOREIGN KEY ([student_id]) REFERENCES [students] ([id])
GO

ALTER TABLE [financial_aid_awards] ADD FOREIGN KEY ([term_id]) REFERENCES [terms] ([id])
GO

How to use this template

  1. Open the ER diagram to see the tables and how they relate.
  2. Copy it into your workspace. You get your own editable copy, in DBML.
  3. Export it as PostgreSQL, MySQL, or SQL Server DDL, or as Prisma, Drizzle, SQLAlchemy, TypeScript, Zod or C# models.

The copy opens in DB Planner’s ER diagram tool, with the schema as text in the DBML editor beside it. Have a database already? Turn its SQL into an ER diagram instead.

Frequently asked questions

Which table is at the centre of the Student Information System database schema?
students. It is referenced by 8 other tables: account_charges, account_payments, advisor_assignments, emergency_contacts, enrollments and 3 more.
How is account_charges related to students?
account_charges.student_id references students.id, a many to one relationship. All 46 relationships in the schema are listed on this page.
Which table in the Student Information System database schema has the most columns?
students, with 11 columns, followed by enrollments (9) and student_holds (9). The schema has 175 columns across 28 tables.
Can I export it to PostgreSQL or MySQL?
Yes. Every DB Planner template exports as DBML, as PostgreSQL, MySQL, or SQL Server DDL, and as C# models.
Is this template free?
Yes. You can open it in the browser without an account, and copy it into your own workspace with a free DB Planner account.
Can I change it after copying it?
Yes. A copy is yours: you can rename tables, add columns, and export it. Changes the author makes later do not affect your copy.