# School Management System database

The schema is normalized around school-year enrollments, reusable class and subject records, and separate transaction records for payments and attendance. User accounts stay in Laravel's users table; optional student, guardian, and staff profiles link to those accounts.

```mermaid
erDiagram
    USERS ||--o| STUDENTS : account
    USERS ||--o| GUARDIANS : account
    USERS ||--o| STAFF_PROFILES : account
    STUDENTS ||--o{ ENROLLMENTS : enrolls
    ACADEMIC_YEARS ||--o{ ENROLLMENTS : includes
    SCHOOL_CLASSES ||--o{ SECTIONS : has
    SCHOOL_CLASSES ||--o{ ENROLLMENTS : groups
    SECTIONS ||--o{ ENROLLMENTS : groups
    STUDENTS }o--o{ GUARDIANS : supported_by
    STAFF_PROFILES ||--o{ TEACHER_SUBJECTS : teaches
    SUBJECTS ||--o{ TEACHER_SUBJECTS : assigned
    SECTIONS ||--o{ CLASS_ROUTINES : scheduled
    ENROLLMENTS ||--o{ STUDENT_ATTENDANCES : attendance
    STAFF_PROFILES ||--o{ STAFF_ATTENDANCES : attendance
    ACADEMIC_YEARS ||--o{ EXAMS : schedules
    SCHOOL_CLASSES ||--o{ EXAMS : takes
    EXAMS ||--o{ EXAM_SUBJECTS : assesses
    EXAM_SUBJECTS ||--o{ EXAM_RESULTS : records
    ENROLLMENTS ||--o{ EXAM_RESULTS : receives
    STUDENTS ||--o{ FEE_INVOICES : billed
    FEE_INVOICES ||--o{ FEE_INVOICE_ITEMS : item
    FEE_INVOICES ||--o{ FEE_PAYMENTS : settled_by
    STAFF_PROFILES ||--o{ PAYROLLS : paid
    BOOKS ||--o{ BOOK_LOANS : borrowed
    STUDENTS ||--o{ BOOK_LOANS : borrows
    USERS ||--o{ NOTICES : publishes
    USERS ||--o{ EVENTS : publishes
```

## Table groups

- **Accounts:** Laravel users, sessions, password resets, cache, and queue tables.
- **Academics:** academic_years, school_classes, sections, subjects, teacher_subjects, class_routines, syllabi, and assignments.
- **People:** staff_profiles, students, guardians, student_guardian, and year-specific enrollments.
- **Attendance:** student_attendances records one status per enrollment per date; staff_attendances records one status per staff member per date.
- **Assessments:** exam_types, exams, exam_subjects, exam_results, and configurable grade_scales.
- **Finance:** fee categories and class/year fee structures, invoices and line items, payments, income, expenses, and monthly payroll.
- **Library:** book categories, catalog records, and dated loans with return and fine fields.
- **Website and communication:** notices, events, hero slides, gallery images, testimonials, contact messages, newsletter subscribers, settings, parent/teacher message threads, and admission applications.

Money columns use fixed-precision decimals. Foreign keys define delete behavior; enrollment and ledger records restrict deletion where preserving history matters. Common search and reporting columns have indexes, and natural identifiers and business uniqueness rules have database constraints.
