-- https://www.phpmyadmin.net/
--

START TRANSACTION;



--
-- Database: `school_db`
--

-- --------------------------------------------------------

--
-- Table structure for table `academic_years`
--

CREATE TABLE `academic_years` (
  `id` int(10) UNSIGNED NOT NULL,
  `name` varchar(50) NOT NULL,
  `start_date` date NOT NULL,
  `end_date` date NOT NULL,
  `status` enum('active','inactive') NOT NULL DEFAULT 'inactive',
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  `deleted_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `academic_years`
--

INSERT INTO `academic_years` (`id`, `name`, `start_date`, `end_date`, `status`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, '2024-2025', '2025-07-24', '2025-07-28', 'active', '2025-07-01 15:22:35', '2025-07-01 15:24:56', NULL),
(2, '2025-2026', '2025-09-08', '2025-07-25', 'active', '2025-07-01 15:28:26', '2025-07-03 08:34:33', NULL);

-- --------------------------------------------------------

--
-- Table structure for table `activity_logs`
--

CREATE TABLE `activity_logs` (
  `id` int(9) UNSIGNED NOT NULL,
  `user_id` int(9) UNSIGNED DEFAULT NULL,
  `role` varchar(50) DEFAULT NULL,
  `action` varchar(255) NOT NULL,
  `ip_address` varchar(50) DEFAULT NULL,
  `user_agent` varchar(255) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `assessment_components`
--

CREATE TABLE `assessment_components` (
  `id` int(10) UNSIGNED NOT NULL,
  `assessment_section_id` int(10) UNSIGNED NOT NULL,
  `name` varchar(255) NOT NULL,
  `max_mark` float NOT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `assessment_modules`
--

CREATE TABLE `assessment_modules` (
  `id` int(10) UNSIGNED NOT NULL,
  `department_id` int(10) UNSIGNED NOT NULL,
  `name` varchar(100) NOT NULL,
  `description` text DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `assessment_sections`
--

CREATE TABLE `assessment_sections` (
  `id` int(10) UNSIGNED NOT NULL,
  `assessment_module_id` int(10) UNSIGNED NOT NULL,
  `name` varchar(255) NOT NULL,
  `percentage` float DEFAULT NULL,
  `use_percentage` tinyint(1) NOT NULL DEFAULT 0,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `attendance_records`
--

CREATE TABLE `attendance_records` (
  `id` int(9) UNSIGNED NOT NULL,
  `academic_year_id` int(9) UNSIGNED NOT NULL,
  `term_id` int(9) UNSIGNED NOT NULL,
  `class_id` int(9) UNSIGNED NOT NULL,
  `house_id` int(9) UNSIGNED DEFAULT NULL,
  `student_id` int(9) UNSIGNED NOT NULL,
  `attendance_date` date NOT NULL,
  `status` enum('Present','Absent','Late','Excused') NOT NULL DEFAULT 'Present',
  `remarks` varchar(255) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `classes`
--

CREATE TABLE `classes` (
  `id` int(10) UNSIGNED NOT NULL,
  `name` varchar(100) NOT NULL,
  `department_id` int(10) UNSIGNED NOT NULL,
  `description` text DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `classes`
--

INSERT INTO `classes` (`id`, `name`, `department_id`, `description`, `created_at`, `updated_at`) VALUES
(7, 'Creche', 8, '', '2025-07-26 10:07:03', '2025-07-26 10:14:40'),
(8, 'Nursey 1', 8, '', '2025-07-26 10:07:41', '2025-07-26 10:07:41'),
(9, 'Nursery 2', 8, '', '2025-07-26 10:08:11', '2025-07-26 10:08:11'),
(10, 'Class 1A', 5, '', '2025-07-26 10:11:42', '2025-07-26 10:11:42'),
(11, 'Class 1B', 5, '', '2025-07-26 10:12:04', '2025-07-26 10:12:04'),
(12, 'JHS 1A', 6, '', '2025-07-26 10:12:35', '2025-07-26 10:12:35'),
(13, 'JHS 1B', 6, '', '2025-07-26 10:13:05', '2025-07-26 10:13:05');

-- --------------------------------------------------------

--
-- Table structure for table `class_subjects`
--

CREATE TABLE `class_subjects` (
  `id` int(10) UNSIGNED NOT NULL,
  `class_id` int(10) UNSIGNED NOT NULL,
  `subject_id` int(10) UNSIGNED NOT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  `deleted_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `departments`
--

CREATE TABLE `departments` (
  `id` int(10) UNSIGNED NOT NULL,
  `name` varchar(100) NOT NULL,
  `description` text DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `departments`
--

INSERT INTO `departments` (`id`, `name`, `description`, `created_at`, `updated_at`) VALUES
(5, 'Primary', 'Lower', '2025-07-03 11:50:14', '2025-07-03 11:50:14'),
(6, 'Junior High School', 'High', '2025-07-03 11:56:21', '2025-07-03 11:56:21'),
(8, 'Pre School', '', '2025-07-26 07:00:57', '2025-07-26 07:00:57');

-- --------------------------------------------------------

--
-- Table structure for table `enrollments`
--

CREATE TABLE `enrollments` (
  `id` int(9) UNSIGNED NOT NULL,
  `student_id` int(9) UNSIGNED NOT NULL,
  `academic_year_id` int(9) UNSIGNED NOT NULL,
  `term_id` int(9) UNSIGNED NOT NULL,
  `department_id` int(9) UNSIGNED NOT NULL,
  `class_id` int(9) UNSIGNED NOT NULL,
  `house_id` int(9) UNSIGNED DEFAULT NULL,
  `enrollment_date` date DEFAULT NULL,
  `status` enum('active','transferred','graduated','suspended','withdrawn') DEFAULT 'active',
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `exam_schedules`
--

CREATE TABLE `exam_schedules` (
  `id` int(9) UNSIGNED NOT NULL,
  `department_id` int(10) UNSIGNED NOT NULL,
  `academic_year_id` int(10) UNSIGNED NOT NULL,
  `term_id` int(10) UNSIGNED NOT NULL,
  `exam_name` varchar(100) NOT NULL,
  `exam_date` date NOT NULL,
  `grading_system_id` int(10) UNSIGNED NOT NULL,
  `score_conversion_id` int(10) UNSIGNED NOT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `exam_schedules`
--

INSERT INTO `exam_schedules` (`id`, `department_id`, `academic_year_id`, `term_id`, `exam_name`, `exam_date`, `grading_system_id`, `score_conversion_id`, `created_at`, `updated_at`) VALUES
(3, 6, 1, 1, 'End of First Term Examination, 2024', '2025-03-08', 7, 6, '2025-07-22 13:34:15', '2025-07-22 13:34:15'),
(5, 6, 1, 1, 'End of First Term Examination, 2024', '2025-12-02', 7, 6, '2025-07-22 13:48:08', '2025-07-22 13:48:08');

-- --------------------------------------------------------

--
-- Table structure for table `fees_categories`
--

CREATE TABLE `fees_categories` (
  `id` int(9) UNSIGNED NOT NULL,
  `name` varchar(100) NOT NULL,
  `description` varchar(255) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `fees_structures`
--

CREATE TABLE `fees_structures` (
  `id` int(9) UNSIGNED NOT NULL,
  `academic_year_id` int(9) UNSIGNED NOT NULL,
  `term_id` int(9) UNSIGNED NOT NULL,
  `class_id` int(9) UNSIGNED NOT NULL,
  `fees_category_id` int(9) UNSIGNED NOT NULL,
  `amount` decimal(10,2) NOT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `fee_payments`
--

CREATE TABLE `fee_payments` (
  `id` int(9) UNSIGNED NOT NULL,
  `student_id` int(9) UNSIGNED NOT NULL,
  `academic_year_id` int(9) UNSIGNED NOT NULL,
  `term_id` int(9) UNSIGNED NOT NULL,
  `class_id` int(9) UNSIGNED NOT NULL,
  `fees_category_id` int(9) UNSIGNED NOT NULL,
  `amount_paid` decimal(10,2) NOT NULL,
  `payment_date` date NOT NULL,
  `payment_method` varchar(50) DEFAULT NULL,
  `reference_number` varchar(100) DEFAULT NULL,
  `notes` varchar(255) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `grading_bands`
--

CREATE TABLE `grading_bands` (
  `id` int(9) UNSIGNED NOT NULL,
  `grading_system_id` int(9) UNSIGNED NOT NULL,
  `score_from` decimal(5,2) NOT NULL,
  `score_to` decimal(5,2) NOT NULL,
  `grade` varchar(5) NOT NULL,
  `remark` varchar(100) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `grading_bands`
--

INSERT INTO `grading_bands` (`id`, `grading_system_id`, `score_from`, `score_to`, `grade`, `remark`, `created_at`, `updated_at`) VALUES
(12, 7, 90.00, 100.00, '1', 'HIGHEST', '2025-07-17 12:45:55', '2025-07-17 12:45:55'),
(13, 7, 80.00, 89.00, '2', 'HIGHER', '2025-07-17 12:45:55', '2025-07-17 12:45:55'),
(14, 7, 70.00, 79.00, '3', 'HIGH', '2025-07-17 12:45:55', '2025-07-17 12:45:55'),
(15, 7, 60.00, 69.00, '4', 'HIGH AVERAGE', '2025-07-17 12:45:55', '2025-07-17 12:45:55'),
(16, 7, 50.00, 59.00, '5', 'AVERAGE', '2025-07-17 12:45:55', '2025-07-17 12:45:55'),
(17, 7, 40.00, 49.00, '6', 'LOW AVERAGE', '2025-07-17 12:45:55', '2025-07-17 12:45:55'),
(18, 7, 30.00, 39.00, '7', 'LOW', '2025-07-17 12:45:55', '2025-07-17 12:45:55'),
(19, 7, 20.00, 29.00, '8', 'LOWER', '2025-07-17 12:45:55', '2025-07-17 12:45:55'),
(20, 7, 10.00, 19.00, '9', 'LOWEST', '2025-07-17 12:45:55', '2025-07-17 12:45:55'),
(21, 8, 90.00, 100.00, 'A', 'Excellent', '2025-07-22 12:55:34', '2025-07-22 12:55:34'),
(22, 8, 80.00, 89.00, 'B', 'Very Good', '2025-07-22 12:55:34', '2025-07-22 12:55:34');

-- --------------------------------------------------------

--
-- Table structure for table `grading_systems`
--

CREATE TABLE `grading_systems` (
  `id` int(9) UNSIGNED NOT NULL,
  `name` varchar(100) NOT NULL,
  `description` text DEFAULT NULL,
  `department_id` int(9) UNSIGNED DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `grading_systems`
--

INSERT INTO `grading_systems` (`id`, `name`, `description`, `department_id`, `created_at`, `updated_at`) VALUES
(7, 'JHS Grading System', '', 6, '2025-07-17 12:30:25', '2025-07-17 12:45:55'),
(8, 'Primary Grading System', '', 5, '2025-07-22 12:55:33', '2025-07-22 12:55:33');

-- --------------------------------------------------------

--
-- Table structure for table `houses`
--

CREATE TABLE `houses` (
  `id` int(10) UNSIGNED NOT NULL,
  `name` varchar(100) NOT NULL,
  `description` text DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  `deleted_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `houses`
--

INSERT INTO `houses` (`id`, `name`, `description`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'Yellow', '', '2025-07-03 12:14:47', '2025-07-03 12:14:47', NULL),
(2, 'Red', '', '2025-07-03 12:23:27', '2025-07-03 12:23:27', NULL),
(3, 'Blue', '', '2025-07-03 12:23:42', '2025-07-03 12:23:42', NULL),
(4, 'Green', '', '2025-07-03 12:23:54', '2025-07-03 12:23:54', NULL),
(5, 'pink', '', '2025-07-03 12:24:05', '2025-07-03 12:24:24', '2025-07-03 12:24:24');

-- --------------------------------------------------------

--
-- Table structure for table `migrations`
--

CREATE TABLE `migrations` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `version` varchar(255) NOT NULL,
  `class` varchar(255) NOT NULL,
  `group` varchar(255) NOT NULL,
  `namespace` varchar(255) NOT NULL,
  `time` int(11) NOT NULL,
  `batch` int(11) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `migrations`
--

INSERT INTO `migrations` (`id`, `version`, `class`, `group`, `namespace`, `time`, `batch`) VALUES
(1, '2025-06-27-110000', 'App\\Database\\Migrations\\CreateRolesTable', 'default', 'App', 1751053594, 1),
(2, '2025-06-27-110010', 'App\\Database\\Migrations\\CreateUsersTable', 'default', 'App', 1751053594, 1),
(3, '2025-06-27-110020', 'App\\Database\\Migrations\\CreateAcademicYearsTable', 'default', 'App', 1751053594, 1),
(4, '2025-06-27-110030', 'App\\Database\\Migrations\\CreateTermsTable', 'default', 'App', 1751053594, 1),
(5, '2025-06-27-110040', 'App\\Database\\Migrations\\CreateDepartmentsTable', 'default', 'App', 1751053594, 1),
(6, '2025-06-27-110050', 'App\\Database\\Migrations\\CreateClassesTable', 'default', 'App', 1751053594, 1),
(7, '2025-06-27-110060', 'App\\Database\\Migrations\\CreateHousesTable', 'default', 'App', 1751053594, 1),
(8, '2025-06-27-110070', 'App\\Database\\Migrations\\CreateSubjectsTable', 'default', 'App', 1751053594, 1),
(9, '2025-06-27-110080', 'App\\Database\\Migrations\\CreateTeachersTable', 'default', 'App', 1751053594, 1),
(10, '2025-06-27-110090', 'App\\Database\\Migrations\\CreateParentsTable', 'default', 'App', 1751053595, 1),
(11, '2025-06-27-110100', 'App\\Database\\Migrations\\CreateStudentsTable', 'default', 'App', 1751053595, 1),
(12, '2025-06-27-110105', 'App\\Database\\Migrations\\CreateStudentParentsTable', 'default', 'App', 1751053595, 1),
(13, '2025-06-27-110110', 'App\\Database\\Migrations\\CreateEnrollmentsTable', 'default', 'App', 1751053595, 1),
(14, '2025-06-27-110120', 'App\\Database\\Migrations\\CreateClassSubjectsTable', 'default', 'App', 1751053595, 1),
(15, '2025-06-27-110130', 'App\\Database\\Migrations\\CreateTeacherAssignmentsTable', 'default', 'App', 1751053595, 1),
(16, '2025-06-27-110140', 'App\\Database\\Migrations\\CreateGradingSystemsTable', 'default', 'App', 1751053595, 1),
(17, '2025-06-27-110150', 'App\\Database\\Migrations\\CreateGradingBandsTable', 'default', 'App', 1751053595, 1),
(18, '2025-06-27-110160', 'App\\Database\\Migrations\\CreateScoreConversionsTable', 'default', 'App', 1751053595, 1),
(19, '2025-06-27-110170', 'App\\Database\\Migrations\\CreateFeesCategoriesTable', 'default', 'App', 1751053595, 1),
(20, '2025-06-27-110180', 'App\\Database\\Migrations\\CreateFeesStructuresTable', 'default', 'App', 1751053595, 1),
(21, '2025-06-27-110190', 'App\\Database\\Migrations\\CreateFeePaymentsTable', 'default', 'App', 1751053595, 1),
(22, '2025-06-27-110200', 'App\\Database\\Migrations\\CreateAttendanceRecordsTable', 'default', 'App', 1751116390, 2),
(23, '2025-06-27-110210', 'App\\Database\\Migrations\\CreateResultsTable', 'default', 'App', 1751116390, 2),
(24, '2025-06-27-110220', 'App\\Database\\Migrations\\CreateResultCommentsTable', 'default', 'App', 1751116390, 2),
(25, '2025-06-27-110230', 'App\\Database\\Migrations\\CreateSettingsTable', 'default', 'App', 1751116390, 2),
(26, '2025-06-27-110240', 'App\\Database\\Migrations\\CreateActivityLogsTable', 'default', 'App', 1751116390, 2),
(27, '2025-06-28-132243', 'App\\Database\\Migrations\\CreatePromotionRecordsTable', 'default', 'App', 1751117146, 3),
(28, '2025-06-28-132436', 'App\\Database\\Migrations\\CreateTimetablesTable', 'default', 'App', 1751117146, 3),
(29, '2025-06-28-161914', 'App\\Database\\Migrations\\CreateUserRolesTable', 'default', 'App', 1751127616, 4),
(30, '2025-06-28-110000', 'App\\Database\\Migrations\\CreateRolesTable', 'default', 'App', 1751131723, 5),
(31, '2025-06-28-110010', 'App\\Database\\Migrations\\CreateUsersTable', 'default', 'App', 1751131723, 5),
(32, '2025-06-28-110015', 'App\\Database\\Migrations\\CreateUserRolesTable', 'default', 'App', 1751131723, 5),
(33, '2025-06-29-110000', 'App\\Database\\Migrations\\CreateRolesTable', 'default', 'App', 1751199231, 6),
(34, '2025-06-29-110010', 'App\\Database\\Migrations\\CreateUsersTable', 'default', 'App', 1751199231, 6),
(35, '2025-06-29-110015', 'App\\Database\\Migrations\\CreateUserRolesTable', 'default', 'App', 1751199231, 6),
(36, '2025-07-04-215007', 'App\\Database\\Migrations\\AlterTeachersTable', 'default', 'App', 1751666035, 7),
(37, '2025-07-05-100838', 'App\\Database\\Migrations\\CreateTeacherAssignmentClassSubject', 'default', 'App', 1751710271, 8),
(38, '2025-07-05-115753', 'App\\Database\\Migrations\\RemoveClassAndSubjectFromTeacherAssignments', 'default', 'App', 1751716791, 9),
(39, '2025-07-06-125106', 'App\\Database\\Migrations\\AddStatusToEnrollments', 'default', 'App', 1752773040, 10),
(40, '2025-07-17-134153', 'App\\Database\\Migrations\\CreateAssessmentModules', 'default', 'App', 1752773471, 11),
(41, '2025-07-17-100000', 'App\\Database\\Migrations\\CreateAssessmentModules', 'default', 'App', 1752776053, 12),
(42, '2025-07-17-100100', 'App\\Database\\Migrations\\CreateAssessmentSections', 'default', 'App', 1752776053, 12),
(43, '2025-07-17-100200', 'App\\Database\\Migrations\\CreateAssessmentComponents', 'default', 'App', 1752776053, 12),
(44, '2025-07-20-112031', 'App\\Database\\Migrations\\CreateExamSchedulesTable', 'default', 'App', 1753010576, 13),
(45, '2025-07-22-110010', 'App\\Database\\Migrations\\CreateResultsTable', 'default', 'App', 1753197229, 14),
(46, '2025-07-22-152020', 'App\\Database\\Migrations\\CreateResultsTable', 'default', 'App', 1753197711, 15),
(47, '2025-07-22-162020', 'App\\Database\\Migrations\\CreateResultsTable', 'default', 'App', 1753222281, 16);

-- --------------------------------------------------------

--
-- Table structure for table `promotion_records`
--

CREATE TABLE `promotion_records` (
  `id` int(10) UNSIGNED NOT NULL,
  `student_id` int(10) UNSIGNED NOT NULL,
  `from_class_id` int(10) UNSIGNED NOT NULL,
  `to_class_id` int(10) UNSIGNED NOT NULL,
  `from_academic_year_id` int(10) UNSIGNED NOT NULL,
  `to_academic_year_id` int(10) UNSIGNED NOT NULL,
  `from_term_id` int(10) UNSIGNED DEFAULT NULL,
  `to_term_id` int(10) UNSIGNED DEFAULT NULL,
  `promotion_date` date NOT NULL,
  `promoted_by` int(10) UNSIGNED DEFAULT NULL,
  `remarks` text DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  `deleted_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `results`
--

CREATE TABLE `results` (
  `id` int(10) UNSIGNED NOT NULL,
  `student_id` int(10) UNSIGNED NOT NULL,
  `class_id` int(10) UNSIGNED NOT NULL,
  `subject_id` int(10) UNSIGNED NOT NULL,
  `academic_year_id` int(10) UNSIGNED NOT NULL,
  `term_id` int(10) UNSIGNED NOT NULL,
  `class_score` decimal(5,2) DEFAULT NULL,
  `exam_score` decimal(5,2) DEFAULT NULL,
  `converted_class_score` decimal(5,2) DEFAULT NULL,
  `converted_exam_score` decimal(5,2) DEFAULT NULL,
  `total_score` decimal(5,2) DEFAULT NULL,
  `grade` varchar(10) DEFAULT NULL,
  `remark` varchar(255) DEFAULT NULL,
  `position` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `result_comments`
--

CREATE TABLE `result_comments` (
  `id` int(9) UNSIGNED NOT NULL,
  `academic_year_id` int(9) UNSIGNED NOT NULL,
  `term_id` int(9) UNSIGNED NOT NULL,
  `class_id` int(9) UNSIGNED NOT NULL,
  `house_id` int(9) UNSIGNED DEFAULT NULL,
  `student_id` int(9) UNSIGNED NOT NULL,
  `teacher_id` int(9) UNSIGNED DEFAULT NULL,
  `comment` text DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `roles`
--

CREATE TABLE `roles` (
  `id` int(10) UNSIGNED NOT NULL,
  `name` varchar(50) NOT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `roles`
--

INSERT INTO `roles` (`id`, `name`, `created_at`, `updated_at`) VALUES
(1, 'admin', NULL, NULL),
(2, 'teacher', NULL, NULL),
(3, 'student', NULL, NULL),
(4, 'parent', NULL, NULL),
(5, 'accountant', NULL, NULL);

-- --------------------------------------------------------

--
-- Table structure for table `score_conversions`
--

CREATE TABLE `score_conversions` (
  `id` int(9) UNSIGNED NOT NULL,
  `department_id` int(9) UNSIGNED DEFAULT NULL,
  `class_score` int(3) NOT NULL,
  `exam_score` int(3) NOT NULL,
  `description` varchar(150) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `score_conversions`
--

INSERT INTO `score_conversions` (`id`, `department_id`, `class_score`, `exam_score`, `description`, `created_at`, `updated_at`) VALUES
(3, 6, 40, 60, '', '2025-07-17 21:04:39', '2025-07-17 21:13:26'),
(6, 5, 50, 50, '', '2025-07-17 22:06:41', '2025-07-17 22:06:41'),
(10, 6, 30, 70, NULL, '2025-07-18 06:12:04', '2025-07-18 08:36:10');

-- --------------------------------------------------------

--
-- Table structure for table `settings`
--

CREATE TABLE `settings` (
  `id` int(9) UNSIGNED NOT NULL,
  `school_name` varchar(255) DEFAULT NULL,
  `school_email` varchar(100) DEFAULT NULL,
  `school_phone` varchar(50) DEFAULT NULL,
  `school_address` varchar(255) DEFAULT NULL,
  `motto` varchar(255) DEFAULT NULL,
  `logo` varchar(255) DEFAULT NULL,
  `signature_principal` varchar(255) DEFAULT NULL,
  `signature_accountant` varchar(255) DEFAULT NULL,
  `current_academic_year_id` int(9) UNSIGNED DEFAULT NULL,
  `current_term_id` int(9) UNSIGNED DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `settings`
--

INSERT INTO `settings` (`id`, `school_name`, `school_email`, `school_phone`, `school_address`, `motto`, `logo`, `signature_principal`, `signature_accountant`, `current_academic_year_id`, `current_term_id`, `created_at`, `updated_at`) VALUES
(3, 'Proswoan Academy, Accra', 'proswoan@gmail.com', '0249710432', 'BOX 45, ACCRA', 'Excellence is the Hall Mark', '1752142505_79b0136b6bab163f3a96.png', 'uploads/settings/1751383993_94c5f6e3f578e67d4e55.jpg', NULL, 1, 1, NULL, NULL);

-- --------------------------------------------------------

--
-- Table structure for table `students`
--

CREATE TABLE `students` (
  `id` int(9) UNSIGNED NOT NULL,
  `surname` varchar(100) NOT NULL,
  `first_name` varchar(100) NOT NULL,
  `other_names` varchar(100) DEFAULT NULL,
  `gender` enum('Male','Female') NOT NULL,
  `date_of_birth` date NOT NULL,
  `nationality` varchar(100) DEFAULT NULL,
  `photo` varchar(255) DEFAULT NULL,
  `academic_year_id` int(9) UNSIGNED NOT NULL,
  `term_id` int(9) UNSIGNED NOT NULL,
  `department_id` int(9) UNSIGNED NOT NULL,
  `class_id` int(9) UNSIGNED NOT NULL,
  `house_id` int(9) UNSIGNED DEFAULT NULL,
  `admission_number` varchar(50) NOT NULL,
  `admission_date` date NOT NULL,
  `religion` varchar(50) DEFAULT NULL,
  `previous_school` varchar(150) DEFAULT NULL,
  `disability` varchar(150) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `students`
--

INSERT INTO `students` (`id`, `surname`, `first_name`, `other_names`, `gender`, `date_of_birth`, `nationality`, `photo`, `academic_year_id`, `term_id`, `department_id`, `class_id`, `house_id`, `admission_number`, `admission_date`, `religion`, `previous_school`, `disability`, `created_at`, `updated_at`) VALUES
(37, 'Akoto', 'Marshal', 'Mawunyo', 'Male', '2016-07-14', '', '68866ab1de57b.jpg', 1, 1, 5, 10, NULL, 'Adm-001', '2022-12-11', '', '', '', NULL, NULL),
(38, 'Agbenyo', 'Saviour', 'Amina', 'Female', '2019-07-15', '', '68866b288a172.jpg', 1, 1, 5, 10, NULL, 'adm-002', '2021-07-01', '', '', '', NULL, NULL);

-- --------------------------------------------------------

--
-- Table structure for table `student_parents`
--

CREATE TABLE `student_parents` (
  `id` int(10) UNSIGNED NOT NULL,
  `student_id` int(10) UNSIGNED NOT NULL,
  `parent_id` int(10) UNSIGNED NOT NULL,
  `relationship` enum('Father','Mother','Guardian') NOT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `student_parents`
--

INSERT INTO `student_parents` (`id`, `student_id`, `parent_id`, `relationship`, `created_at`, `updated_at`) VALUES
(20, 37, 5, 'Father', '2025-07-27 18:06:42', '2025-07-27 18:06:42'),
(21, 38, 18, 'Mother', '2025-07-27 18:08:40', '2025-07-27 18:08:40');

-- --------------------------------------------------------

--
-- Table structure for table `subjects`
--

CREATE TABLE `subjects` (
  `id` int(10) UNSIGNED NOT NULL,
  `name` varchar(100) NOT NULL,
  `code` varchar(20) DEFAULT NULL,
  `department_id` int(10) UNSIGNED NOT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `subjects`
--

INSERT INTO `subjects` (`id`, `name`, `code`, `department_id`, `created_at`, `updated_at`) VALUES
(11, 'Literacy', '001', 8, '2025-07-26 10:17:10', '2025-07-26 10:17:10'),
(12, 'Numeracy', '002', 8, '2025-07-26 10:17:53', '2025-07-26 10:17:53'),
(13, 'Mathematics', '003', 5, '2025-07-26 10:18:43', '2025-07-26 10:18:43'),
(14, 'English', '004', 5, '2025-07-26 10:19:07', '2025-07-26 10:19:07'),
(15, 'Mathematics', '005', 6, '2025-07-26 10:19:43', '2025-07-26 10:19:43'),
(16, 'English', '006', 6, '2025-07-26 10:20:11', '2025-07-26 10:20:25');

-- --------------------------------------------------------

--
-- Table structure for table `teachers`
--

CREATE TABLE `teachers` (
  `id` int(10) UNSIGNED NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `department_id` int(10) UNSIGNED NOT NULL,
  `phone` varchar(20) DEFAULT NULL,
  `address` varchar(255) DEFAULT NULL,
  `gender` enum('Male','Female') DEFAULT NULL,
  `qualification` varchar(100) DEFAULT NULL,
  `photo` varchar(255) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `teachers`
--

INSERT INTO `teachers` (`id`, `user_id`, `department_id`, `phone`, `address`, `gender`, `qualification`, `photo`, `created_at`, `updated_at`) VALUES
(10, 3, 5, '0249710432', 'Box 63, Tema', 'Male', 'Degree', '1753341507_92ea9f7b4b4ab1cdd376.jpg', '2025-07-24 07:18:27', '2025-07-24 07:18:27'),
(11, 8, 6, '0249755593', 'Box 59, Dansoman', 'Female', 'Diploma', '1753341582_4b2889f8f989ea28883e.jpg', '2025-07-24 07:19:42', '2025-07-24 07:19:42');

-- --------------------------------------------------------

--
-- Table structure for table `teacher_assignments`
--

CREATE TABLE `teacher_assignments` (
  `id` int(9) UNSIGNED NOT NULL,
  `teacher_id` int(9) UNSIGNED NOT NULL,
  `academic_year_id` int(9) UNSIGNED NOT NULL,
  `term_id` int(9) UNSIGNED NOT NULL,
  `department_id` int(9) UNSIGNED NOT NULL,
  `assigned_date` date DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `teacher_assignments`
--

INSERT INTO `teacher_assignments` (`id`, `teacher_id`, `academic_year_id`, `term_id`, `department_id`, `assigned_date`, `created_at`, `updated_at`) VALUES
(22, 10, 1, 1, 6, '2025-07-08', NULL, NULL),
(23, 11, 1, 1, 5, '2025-07-14', NULL, NULL);

-- --------------------------------------------------------

--
-- Table structure for table `teacher_assignment_class_subject`
--

CREATE TABLE `teacher_assignment_class_subject` (
  `id` int(10) UNSIGNED NOT NULL,
  `teacher_assignment_id` int(10) UNSIGNED NOT NULL,
  `class_id` int(10) UNSIGNED NOT NULL,
  `subject_id` int(10) UNSIGNED NOT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `teacher_assignment_class_subject`
--

INSERT INTO `teacher_assignment_class_subject` (`id`, `teacher_assignment_id`, `class_id`, `subject_id`, `created_at`, `updated_at`) VALUES
(166, 22, 12, 15, NULL, NULL),
(167, 22, 13, 15, NULL, NULL),
(174, 23, 7, 11, NULL, NULL),
(175, 23, 7, 12, NULL, NULL),
(176, 23, 8, 11, NULL, NULL),
(177, 23, 8, 12, NULL, NULL),
(178, 23, 9, 11, NULL, NULL),
(179, 23, 9, 12, NULL, NULL);

-- --------------------------------------------------------

--
-- Table structure for table `terms`
--

CREATE TABLE `terms` (
  `id` int(10) UNSIGNED NOT NULL,
  `academic_year_id` int(10) UNSIGNED NOT NULL,
  `name` varchar(50) NOT NULL,
  `start_date` date NOT NULL,
  `end_date` date NOT NULL,
  `status` enum('active','inactive') NOT NULL DEFAULT 'inactive',
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  `deleted_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `terms`
--

INSERT INTO `terms` (`id`, `academic_year_id`, `name`, `start_date`, `end_date`, `status`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 1, 'First Term', '2025-07-23', '2025-08-10', 'active', '2025-07-01 15:31:16', '2025-07-01 15:31:16', NULL),
(2, 1, 'Second Term', '2025-09-16', '2025-12-25', 'active', '2025-07-01 15:32:26', '2025-07-01 15:32:26', NULL);

-- --------------------------------------------------------

--
-- Table structure for table `timetables`
--

CREATE TABLE `timetables` (
  `id` int(10) UNSIGNED NOT NULL,
  `academic_year_id` int(10) UNSIGNED NOT NULL,
  `term_id` int(10) UNSIGNED DEFAULT NULL,
  `class_id` int(10) UNSIGNED NOT NULL,
  `house_id` int(10) UNSIGNED DEFAULT NULL,
  `day_of_week` varchar(20) NOT NULL,
  `period_number` int(2) NOT NULL,
  `start_time` time NOT NULL,
  `end_time` time NOT NULL,
  `subject_id` int(10) UNSIGNED NOT NULL,
  `teacher_id` int(10) UNSIGNED DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  `deleted_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `user_roles`
--

CREATE TABLE `user_roles` (
  `id` int(10) UNSIGNED NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `role_id` int(10) UNSIGNED NOT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `user_roles`
--

INSERT INTO `user_roles` (`id`, `user_id`, `role_id`, `created_at`, `updated_at`) VALUES
(11, 3, 1, '2025-06-29 13:40:25', '2025-06-29 18:10:46'),
(13, 5, 1, NULL, NULL),
(15, 7, 2, NULL, NULL),
(16, 8, 2, NULL, NULL),
(17, 13, 1, NULL, NULL),
(18, 14, 4, NULL, NULL);

--
-- Indexes for dumped tables
--

--
-- Indexes for table `academic_years`
--
ALTER TABLE `academic_years`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `activity_logs`
--
ALTER TABLE `activity_logs`
  ADD PRIMARY KEY (`id`),
  ADD KEY `activity_logs_user_id_foreign` (`user_id`);

--
-- Indexes for table `assessment_components`
--
ALTER TABLE `assessment_components`
  ADD PRIMARY KEY (`id`),
  ADD KEY `assessment_components_assessment_section_id_foreign` (`assessment_section_id`);

--
-- Indexes for table `assessment_modules`
--
ALTER TABLE `assessment_modules`
  ADD PRIMARY KEY (`id`),
  ADD KEY `assessment_modules_department_id_foreign` (`department_id`);

--
-- Indexes for table `assessment_sections`
--
ALTER TABLE `assessment_sections`
  ADD PRIMARY KEY (`id`),
  ADD KEY `assessment_sections_assessment_module_id_foreign` (`assessment_module_id`);

--
-- Indexes for table `attendance_records`
--
ALTER TABLE `attendance_records`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `student_id_attendance_date` (`student_id`,`attendance_date`),
  ADD KEY `attendance_records_academic_year_id_foreign` (`academic_year_id`),
  ADD KEY `attendance_records_term_id_foreign` (`term_id`),
  ADD KEY `attendance_records_class_id_foreign` (`class_id`),
  ADD KEY `attendance_records_house_id_foreign` (`house_id`);

--
-- Indexes for table `classes`
--
ALTER TABLE `classes`
  ADD PRIMARY KEY (`id`),
  ADD KEY `classes_department_id_foreign` (`department_id`);

--
-- Indexes for table `class_subjects`
--
ALTER TABLE `class_subjects`
  ADD PRIMARY KEY (`id`),
  ADD KEY `class_subjects_class_id_foreign` (`class_id`),
  ADD KEY `class_subjects_subject_id_foreign` (`subject_id`);

--
-- Indexes for table `departments`
--
ALTER TABLE `departments`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `name` (`name`);

--
-- Indexes for table `enrollments`
--
ALTER TABLE `enrollments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `enrollments_student_id_foreign` (`student_id`),
  ADD KEY `enrollments_academic_year_id_foreign` (`academic_year_id`),
  ADD KEY `enrollments_term_id_foreign` (`term_id`),
  ADD KEY `enrollments_department_id_foreign` (`department_id`),
  ADD KEY `enrollments_class_id_foreign` (`class_id`),
  ADD KEY `enrollments_house_id_foreign` (`house_id`);

--
-- Indexes for table `exam_schedules`
--
ALTER TABLE `exam_schedules`
  ADD PRIMARY KEY (`id`),
  ADD KEY `exam_schedules_department_id_foreign` (`department_id`),
  ADD KEY `exam_schedules_academic_year_id_foreign` (`academic_year_id`),
  ADD KEY `exam_schedules_term_id_foreign` (`term_id`),
  ADD KEY `exam_schedules_grading_system_id_foreign` (`grading_system_id`),
  ADD KEY `exam_schedules_score_conversion_id_foreign` (`score_conversion_id`);

--
-- Indexes for table `fees_categories`
--
ALTER TABLE `fees_categories`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `fees_structures`
--
ALTER TABLE `fees_structures`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `academic_year_id_term_id_class_id_fees_category_id` (`academic_year_id`,`term_id`,`class_id`,`fees_category_id`),
  ADD KEY `fees_structures_term_id_foreign` (`term_id`),
  ADD KEY `fees_structures_class_id_foreign` (`class_id`),
  ADD KEY `fees_structures_fees_category_id_foreign` (`fees_category_id`);

--
-- Indexes for table `fee_payments`
--
ALTER TABLE `fee_payments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fee_payments_student_id_foreign` (`student_id`),
  ADD KEY `fee_payments_academic_year_id_foreign` (`academic_year_id`),
  ADD KEY `fee_payments_term_id_foreign` (`term_id`),
  ADD KEY `fee_payments_class_id_foreign` (`class_id`),
  ADD KEY `fee_payments_fees_category_id_foreign` (`fees_category_id`);

--
-- Indexes for table `grading_bands`
--
ALTER TABLE `grading_bands`
  ADD PRIMARY KEY (`id`),
  ADD KEY `grading_bands_grading_system_id_foreign` (`grading_system_id`);

--
-- Indexes for table `grading_systems`
--
ALTER TABLE `grading_systems`
  ADD PRIMARY KEY (`id`),
  ADD KEY `grading_systems_department_id_foreign` (`department_id`);

--
-- Indexes for table `houses`
--
ALTER TABLE `houses`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `migrations`
--
ALTER TABLE `migrations`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `promotion_records`
--
ALTER TABLE `promotion_records`
  ADD PRIMARY KEY (`id`),
  ADD KEY `promotion_records_student_id_foreign` (`student_id`),
  ADD KEY `promotion_records_from_class_id_foreign` (`from_class_id`),
  ADD KEY `promotion_records_to_class_id_foreign` (`to_class_id`),
  ADD KEY `promotion_records_from_academic_year_id_foreign` (`from_academic_year_id`),
  ADD KEY `promotion_records_to_academic_year_id_foreign` (`to_academic_year_id`),
  ADD KEY `promotion_records_from_term_id_foreign` (`from_term_id`),
  ADD KEY `promotion_records_to_term_id_foreign` (`to_term_id`),
  ADD KEY `promotion_records_promoted_by_foreign` (`promoted_by`);

--
-- Indexes for table `results`
--
ALTER TABLE `results`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `result_comments`
--
ALTER TABLE `result_comments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `result_comments_academic_year_id_foreign` (`academic_year_id`),
  ADD KEY `result_comments_term_id_foreign` (`term_id`),
  ADD KEY `result_comments_class_id_foreign` (`class_id`),
  ADD KEY `result_comments_house_id_foreign` (`house_id`),
  ADD KEY `result_comments_student_id_foreign` (`student_id`),
  ADD KEY `result_comments_teacher_id_foreign` (`teacher_id`);

--
-- Indexes for table `roles`
--
ALTER TABLE `roles`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `name` (`name`);

--
-- Indexes for table `score_conversions`
--
ALTER TABLE `score_conversions`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `department_id_class_score_exam_score` (`department_id`,`class_score`,`exam_score`);

--
-- Indexes for table `settings`
--
ALTER TABLE `settings`
  ADD PRIMARY KEY (`id`),
  ADD KEY `settings_current_academic_year_id_foreign` (`current_academic_year_id`),
  ADD KEY `settings_current_term_id_foreign` (`current_term_id`);

--
-- Indexes for table `students`
--
ALTER TABLE `students`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `admission_number` (`admission_number`),
  ADD KEY `students_academic_year_id_foreign` (`academic_year_id`),
  ADD KEY `students_term_id_foreign` (`term_id`),
  ADD KEY `students_department_id_foreign` (`department_id`),
  ADD KEY `students_class_id_foreign` (`class_id`),
  ADD KEY `students_house_id_foreign` (`house_id`);

--
-- Indexes for table `student_parents`
--
ALTER TABLE `student_parents`
  ADD PRIMARY KEY (`id`),
  ADD KEY `student_parents_student_id_foreign` (`student_id`),
  ADD KEY `student_parents_parent_id_foreign` (`parent_id`);

--
-- Indexes for table `subjects`
--
ALTER TABLE `subjects`
  ADD PRIMARY KEY (`id`),
  ADD KEY `subjects_department_id_foreign` (`department_id`);

--
-- Indexes for table `teachers`
--
ALTER TABLE `teachers`
  ADD PRIMARY KEY (`id`),
  ADD KEY `teachers_user_id_foreign` (`user_id`),
  ADD KEY `teachers_department_id_foreign` (`department_id`);

--
-- Indexes for table `teacher_assignments`
--
ALTER TABLE `teacher_assignments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `teacher_assignments_teacher_id_foreign` (`teacher_id`),
  ADD KEY `teacher_assignments_academic_year_id_foreign` (`academic_year_id`),
  ADD KEY `teacher_assignments_term_id_foreign` (`term_id`),
  ADD KEY `teacher_assignments_department_id_foreign` (`department_id`);

--
-- Indexes for table `teacher_assignment_class_subject`
--
ALTER TABLE `teacher_assignment_class_subject`
  ADD PRIMARY KEY (`id`),
  ADD KEY `teacher_assignment_class_subject_teacher_assignment_id_foreign` (`teacher_assignment_id`),
  ADD KEY `teacher_assignment_class_subject_class_id_foreign` (`class_id`),
  ADD KEY `teacher_assignment_class_subject_subject_id_foreign` (`subject_id`);

--
-- Indexes for table `terms`
--
ALTER TABLE `terms`
  ADD PRIMARY KEY (`id`),
  ADD KEY `terms_academic_year_id_foreign` (`academic_year_id`);

--
-- Indexes for table `timetables`
--
ALTER TABLE `timetables`
  ADD PRIMARY KEY (`id`),
  ADD KEY `timetables_academic_year_id_foreign` (`academic_year_id`),
  ADD KEY `timetables_term_id_foreign` (`term_id`),
  ADD KEY `timetables_class_id_foreign` (`class_id`),
  ADD KEY `timetables_house_id_foreign` (`house_id`),
  ADD KEY `timetables_subject_id_foreign` (`subject_id`),
  ADD KEY `timetables_teacher_id_foreign` (`teacher_id`);

--
-- Indexes for table `user_roles`
--
ALTER TABLE `user_roles`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_roles_user_id_foreign` (`user_id`),
  ADD KEY `user_roles_role_id_foreign` (`role_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `academic_years`
--
ALTER TABLE `academic_years`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `activity_logs`
--
ALTER TABLE `activity_logs`
  MODIFY `id` int(9) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `assessment_components`
--
ALTER TABLE `assessment_components`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `assessment_modules`
--
ALTER TABLE `assessment_modules`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `assessment_sections`
--
ALTER TABLE `assessment_sections`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `attendance_records`
--
ALTER TABLE `attendance_records`
  MODIFY `id` int(9) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `classes`
--
ALTER TABLE `classes`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;

--
-- AUTO_INCREMENT for table `class_subjects`
--
ALTER TABLE `class_subjects`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `departments`
--
ALTER TABLE `departments`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;

--
-- AUTO_INCREMENT for table `enrollments`
--
ALTER TABLE `enrollments`
  MODIFY `id` int(9) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `exam_schedules`
--
ALTER TABLE `exam_schedules`
  MODIFY `id` int(9) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `fees_categories`
--
ALTER TABLE `fees_categories`
  MODIFY `id` int(9) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `fees_structures`
--
ALTER TABLE `fees_structures`
  MODIFY `id` int(9) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `fee_payments`
--
ALTER TABLE `fee_payments`
  MODIFY `id` int(9) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `grading_bands`
--
ALTER TABLE `grading_bands`
  MODIFY `id` int(9) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23;

--
-- AUTO_INCREMENT for table `grading_systems`
--
ALTER TABLE `grading_systems`
  MODIFY `id` int(9) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;

--
-- AUTO_INCREMENT for table `houses`
--
ALTER TABLE `houses`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `migrations`
--
ALTER TABLE `migrations`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=48;

--
-- AUTO_INCREMENT for table `promotion_records`
--
ALTER TABLE `promotion_records`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `results`
--
ALTER TABLE `results`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `result_comments`
--
ALTER TABLE `result_comments`
  MODIFY `id` int(9) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `roles`
--
ALTER TABLE `roles`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `score_conversions`
--
ALTER TABLE `score_conversions`
  MODIFY `id` int(9) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=18;

--
-- AUTO_INCREMENT for table `settings`
--
ALTER TABLE `settings`
  MODIFY `id` int(9) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `students`
--
ALTER TABLE `students`
  MODIFY `id` int(9) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=39;

--
-- AUTO_INCREMENT for table `student_parents`
--
ALTER TABLE `student_parents`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=22;

--
-- AUTO_INCREMENT for table `subjects`
--
ALTER TABLE `subjects`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;

--
-- AUTO_INCREMENT for table `teachers`
--
ALTER TABLE `teachers`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;

--
-- AUTO_INCREMENT for table `teacher_assignments`
--
ALTER TABLE `teacher_assignments`
  MODIFY `id` int(9) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=24;

--
-- AUTO_INCREMENT for table `teacher_assignment_class_subject`
--
ALTER TABLE `teacher_assignment_class_subject`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=180;

--
-- AUTO_INCREMENT for table `terms`
--
ALTER TABLE `terms`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `timetables`
--
ALTER TABLE `timetables`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `user_roles`
--
ALTER TABLE `user_roles`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `activity_logs`
--
ALTER TABLE `activity_logs`
  ADD CONSTRAINT `activity_logs_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE SET NULL;

--
-- Constraints for table `assessment_components`
--
ALTER TABLE `assessment_components`
  ADD CONSTRAINT `assessment_components_assessment_section_id_foreign` FOREIGN KEY (`assessment_section_id`) REFERENCES `assessment_sections` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `assessment_modules`
--
ALTER TABLE `assessment_modules`
  ADD CONSTRAINT `assessment_modules_department_id_foreign` FOREIGN KEY (`department_id`) REFERENCES `departments` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `assessment_sections`
--
ALTER TABLE `assessment_sections`
  ADD CONSTRAINT `assessment_sections_assessment_module_id_foreign` FOREIGN KEY (`assessment_module_id`) REFERENCES `assessment_modules` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `attendance_records`
--
ALTER TABLE `attendance_records`
  ADD CONSTRAINT `attendance_records_academic_year_id_foreign` FOREIGN KEY (`academic_year_id`) REFERENCES `academic_years` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `attendance_records_class_id_foreign` FOREIGN KEY (`class_id`) REFERENCES `classes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `attendance_records_house_id_foreign` FOREIGN KEY (`house_id`) REFERENCES `houses` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `attendance_records_student_id_foreign` FOREIGN KEY (`student_id`) REFERENCES `students` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `attendance_records_term_id_foreign` FOREIGN KEY (`term_id`) REFERENCES `terms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `classes`
--
ALTER TABLE `classes`
  ADD CONSTRAINT `classes_department_id_foreign` FOREIGN KEY (`department_id`) REFERENCES `departments` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `class_subjects`
--
ALTER TABLE `class_subjects`
  ADD CONSTRAINT `class_subjects_class_id_foreign` FOREIGN KEY (`class_id`) REFERENCES `classes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `class_subjects_subject_id_foreign` FOREIGN KEY (`subject_id`) REFERENCES `subjects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `enrollments`
--
ALTER TABLE `enrollments`
  ADD CONSTRAINT `enrollments_academic_year_id_foreign` FOREIGN KEY (`academic_year_id`) REFERENCES `academic_years` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `enrollments_class_id_foreign` FOREIGN KEY (`class_id`) REFERENCES `classes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `enrollments_department_id_foreign` FOREIGN KEY (`department_id`) REFERENCES `departments` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `enrollments_house_id_foreign` FOREIGN KEY (`house_id`) REFERENCES `houses` (`id`) ON DELETE CASCADE ON UPDATE SET NULL,
  ADD CONSTRAINT `enrollments_student_id_foreign` FOREIGN KEY (`student_id`) REFERENCES `students` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `enrollments_term_id_foreign` FOREIGN KEY (`term_id`) REFERENCES `terms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `exam_schedules`
--
ALTER TABLE `exam_schedules`
  ADD CONSTRAINT `exam_schedules_academic_year_id_foreign` FOREIGN KEY (`academic_year_id`) REFERENCES `academic_years` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `exam_schedules_department_id_foreign` FOREIGN KEY (`department_id`) REFERENCES `departments` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `exam_schedules_grading_system_id_foreign` FOREIGN KEY (`grading_system_id`) REFERENCES `grading_systems` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `exam_schedules_score_conversion_id_foreign` FOREIGN KEY (`score_conversion_id`) REFERENCES `score_conversions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `exam_schedules_term_id_foreign` FOREIGN KEY (`term_id`) REFERENCES `terms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `fees_structures`
--
ALTER TABLE `fees_structures`
  ADD CONSTRAINT `fees_structures_academic_year_id_foreign` FOREIGN KEY (`academic_year_id`) REFERENCES `academic_years` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fees_structures_class_id_foreign` FOREIGN KEY (`class_id`) REFERENCES `classes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fees_structures_fees_category_id_foreign` FOREIGN KEY (`fees_category_id`) REFERENCES `fees_categories` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fees_structures_term_id_foreign` FOREIGN KEY (`term_id`) REFERENCES `terms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `fee_payments`
--
ALTER TABLE `fee_payments`
  ADD CONSTRAINT `fee_payments_academic_year_id_foreign` FOREIGN KEY (`academic_year_id`) REFERENCES `academic_years` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fee_payments_class_id_foreign` FOREIGN KEY (`class_id`) REFERENCES `classes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fee_payments_fees_category_id_foreign` FOREIGN KEY (`fees_category_id`) REFERENCES `fees_categories` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fee_payments_student_id_foreign` FOREIGN KEY (`student_id`) REFERENCES `students` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fee_payments_term_id_foreign` FOREIGN KEY (`term_id`) REFERENCES `terms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `grading_bands`
--
ALTER TABLE `grading_bands`
  ADD CONSTRAINT `grading_bands_grading_system_id_foreign` FOREIGN KEY (`grading_system_id`) REFERENCES `grading_systems` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `grading_systems`
--
ALTER TABLE `grading_systems`
  ADD CONSTRAINT `grading_systems_department_id_foreign` FOREIGN KEY (`department_id`) REFERENCES `departments` (`id`) ON DELETE CASCADE ON UPDATE SET NULL;

--
-- Constraints for table `promotion_records`
--
ALTER TABLE `promotion_records`
  ADD CONSTRAINT `promotion_records_from_academic_year_id_foreign` FOREIGN KEY (`from_academic_year_id`) REFERENCES `academic_years` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `promotion_records_from_class_id_foreign` FOREIGN KEY (`from_class_id`) REFERENCES `classes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `promotion_records_from_term_id_foreign` FOREIGN KEY (`from_term_id`) REFERENCES `terms` (`id`) ON DELETE CASCADE ON UPDATE SET NULL,
  ADD CONSTRAINT `promotion_records_promoted_by_foreign` FOREIGN KEY (`promoted_by`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE SET NULL,
  ADD CONSTRAINT `promotion_records_student_id_foreign` FOREIGN KEY (`student_id`) REFERENCES `students` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `promotion_records_to_academic_year_id_foreign` FOREIGN KEY (`to_academic_year_id`) REFERENCES `academic_years` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `promotion_records_to_class_id_foreign` FOREIGN KEY (`to_class_id`) REFERENCES `classes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `promotion_records_to_term_id_foreign` FOREIGN KEY (`to_term_id`) REFERENCES `terms` (`id`) ON DELETE CASCADE ON UPDATE SET NULL;

--
-- Constraints for table `result_comments`
--
ALTER TABLE `result_comments`
  ADD CONSTRAINT `result_comments_academic_year_id_foreign` FOREIGN KEY (`academic_year_id`) REFERENCES `academic_years` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `result_comments_class_id_foreign` FOREIGN KEY (`class_id`) REFERENCES `classes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `result_comments_house_id_foreign` FOREIGN KEY (`house_id`) REFERENCES `houses` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `result_comments_student_id_foreign` FOREIGN KEY (`student_id`) REFERENCES `students` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `result_comments_teacher_id_foreign` FOREIGN KEY (`teacher_id`) REFERENCES `teachers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `result_comments_term_id_foreign` FOREIGN KEY (`term_id`) REFERENCES `terms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `score_conversions`
--
ALTER TABLE `score_conversions`
  ADD CONSTRAINT `score_conversions_department_id_foreign` FOREIGN KEY (`department_id`) REFERENCES `departments` (`id`) ON DELETE CASCADE ON UPDATE SET NULL;

--
-- Constraints for table `settings`
--
ALTER TABLE `settings`
  ADD CONSTRAINT `settings_current_academic_year_id_foreign` FOREIGN KEY (`current_academic_year_id`) REFERENCES `academic_years` (`id`) ON DELETE CASCADE ON UPDATE SET NULL,
  ADD CONSTRAINT `settings_current_term_id_foreign` FOREIGN KEY (`current_term_id`) REFERENCES `terms` (`id`) ON DELETE CASCADE ON UPDATE SET NULL;

--
-- Constraints for table `students`
--
ALTER TABLE `students`
  ADD CONSTRAINT `students_academic_year_id_foreign` FOREIGN KEY (`academic_year_id`) REFERENCES `academic_years` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `students_class_id_foreign` FOREIGN KEY (`class_id`) REFERENCES `classes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `students_department_id_foreign` FOREIGN KEY (`department_id`) REFERENCES `departments` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `students_house_id_foreign` FOREIGN KEY (`house_id`) REFERENCES `houses` (`id`) ON DELETE CASCADE ON UPDATE SET NULL,
  ADD CONSTRAINT `students_term_id_foreign` FOREIGN KEY (`term_id`) REFERENCES `terms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `student_parents`
--
ALTER TABLE `student_parents`
  ADD CONSTRAINT `student_parents_parent_id_foreign` FOREIGN KEY (`parent_id`) REFERENCES `parents` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `student_parents_student_id_foreign` FOREIGN KEY (`student_id`) REFERENCES `students` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `subjects`
--
ALTER TABLE `subjects`
  ADD CONSTRAINT `subjects_department_id_foreign` FOREIGN KEY (`department_id`) REFERENCES `departments` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `teachers`
--
ALTER TABLE `teachers`
  ADD CONSTRAINT `teachers_department_id_foreign` FOREIGN KEY (`department_id`) REFERENCES `departments` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `teachers_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `teacher_assignments`
--
ALTER TABLE `teacher_assignments`
  ADD CONSTRAINT `teacher_assignments_academic_year_id_foreign` FOREIGN KEY (`academic_year_id`) REFERENCES `academic_years` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `teacher_assignments_department_id_foreign` FOREIGN KEY (`department_id`) REFERENCES `departments` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `teacher_assignments_teacher_id_foreign` FOREIGN KEY (`teacher_id`) REFERENCES `teachers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `teacher_assignments_term_id_foreign` FOREIGN KEY (`term_id`) REFERENCES `terms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `teacher_assignment_class_subject`
--
ALTER TABLE `teacher_assignment_class_subject`
  ADD CONSTRAINT `teacher_assignment_class_subject_class_id_foreign` FOREIGN KEY (`class_id`) REFERENCES `classes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `teacher_assignment_class_subject_subject_id_foreign` FOREIGN KEY (`subject_id`) REFERENCES `subjects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `teacher_assignment_class_subject_teacher_assignment_id_foreign` FOREIGN KEY (`teacher_assignment_id`) REFERENCES `teacher_assignments` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `terms`
--
ALTER TABLE `terms`
  ADD CONSTRAINT `terms_academic_year_id_foreign` FOREIGN KEY (`academic_year_id`) REFERENCES `academic_years` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `timetables`
--
ALTER TABLE `timetables`
  ADD CONSTRAINT `timetables_academic_year_id_foreign` FOREIGN KEY (`academic_year_id`) REFERENCES `academic_years` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `timetables_class_id_foreign` FOREIGN KEY (`class_id`) REFERENCES `classes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `timetables_house_id_foreign` FOREIGN KEY (`house_id`) REFERENCES `houses` (`id`) ON DELETE CASCADE ON UPDATE SET NULL,
  ADD CONSTRAINT `timetables_subject_id_foreign` FOREIGN KEY (`subject_id`) REFERENCES `subjects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `timetables_teacher_id_foreign` FOREIGN KEY (`teacher_id`) REFERENCES `teachers` (`id`) ON DELETE CASCADE ON UPDATE SET NULL,
  ADD CONSTRAINT `timetables_term_id_foreign` FOREIGN KEY (`term_id`) REFERENCES `terms` (`id`) ON DELETE CASCADE ON UPDATE SET NULL;

--
-- Constraints for table `user_roles`
--
ALTER TABLE `user_roles`
  ADD CONSTRAINT `user_roles_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `user_roles_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;

