/*
 Navicat MySQL Dump SQL

 Source Server         : localhost_3306
 Source Server Type    : MySQL
 Source Server Version : 100432 (10.4.32-MariaDB)
 Source Host           : localhost:3306
 Source Schema         : attendance_system

 Target Server Type    : MySQL
 Target Server Version : 100432 (10.4.32-MariaDB)
 File Encoding         : 65001

 Date: 14/12/2025 12:46:51
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for activities
-- ----------------------------
DROP TABLE IF EXISTS `activities`;
CREATE TABLE `activities`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `date` date NOT NULL,
  `time_in` time NOT NULL,
  `time_out` time NOT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,
  `location` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `required_students` enum('all','specific_course','specific_department') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'all',
  `course_id` int NULL DEFAULT NULL,
  `department_id` int NULL DEFAULT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP,
  `status` tinyint NULL DEFAULT 1 COMMENT '1=Active, 0=Inactive',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_date`(`date` ASC) USING BTREE,
  INDEX `idx_created_by`(`created_by` ASC) USING BTREE,
  INDEX `idx_status`(`status` ASC) USING BTREE,
  INDEX `idx_course_id`(`course_id` ASC) USING BTREE,
  INDEX `idx_department_id`(`department_id` ASC) USING BTREE,
  CONSTRAINT `activities_ibfk_1` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE,
  CONSTRAINT `activities_ibfk_2` FOREIGN KEY (`course_id`) REFERENCES `courses` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `activities_ibfk_3` FOREIGN KEY (`department_id`) REFERENCES `departments` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of activities
-- ----------------------------
INSERT INTO `activities` VALUES (3, 'JPCS Week', '2025-11-20', '08:00:00', '17:00:00', 'Cybersecurity Seminar, Recognition, and Opening Ceremony of JPCS Week with the theme \"Think I.T. DO. I.T. BE IT\".', 'AVR1', 'specific_course', 1, 1, 1, '2025-11-30 00:34:27', '2025-11-30 00:34:27', 1);
INSERT INTO `activities` VALUES (4, 'Morning Class Nov 30', '2025-11-30', '08:00:00', '10:00:00', 'Regular class session', 'Room 101', 'all', NULL, NULL, 1, '2025-11-30 17:27:14', '2025-11-30 17:27:14', 1);
INSERT INTO `activities` VALUES (5, 'Christmas Party', '2025-12-07', '21:40:00', '23:00:00', '', 'AVR1', 'all', NULL, NULL, 1, '2025-12-07 21:36:33', '2025-12-07 21:36:33', 1);
INSERT INTO `activities` VALUES (7, 'Philhealth Yakap Orientation Program', '2025-12-09', '16:00:00', '17:00:00', '', 'AVR1', 'specific_course', 1, NULL, 1, '2025-12-09 15:08:41', '2025-12-09 15:08:41', 1);

-- ----------------------------
-- Table structure for attendance
-- ----------------------------
DROP TABLE IF EXISTS `attendance`;
CREATE TABLE `attendance`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `student_id` int NOT NULL,
  `activity_id` int NOT NULL,
  `time_in` timestamp NULL DEFAULT NULL,
  `time_out` timestamp NULL DEFAULT NULL,
  `status` enum('present','absent','late','excused') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'present',
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `unique_student_activity`(`student_id` ASC, `activity_id` ASC) USING BTREE,
  INDEX `idx_student_id`(`student_id` ASC) USING BTREE,
  INDEX `idx_activity_id`(`activity_id` ASC) USING BTREE,
  INDEX `idx_time_in`(`time_in` ASC) USING BTREE,
  INDEX `idx_status`(`status` ASC) USING BTREE,
  INDEX `idx_created_at`(`created_at` ASC) USING BTREE,
  CONSTRAINT `attendance_ibfk_1` FOREIGN KEY (`student_id`) REFERENCES `students` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `attendance_ibfk_2` FOREIGN KEY (`activity_id`) REFERENCES `activities` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB AUTO_INCREMENT = 23 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of attendance
-- ----------------------------
INSERT INTO `attendance` VALUES (1, 1, 3, '2025-11-29 17:38:16', NULL, NULL, NULL, '2025-11-30 00:38:16', '2025-11-30 00:38:16');
INSERT INTO `attendance` VALUES (2, 1, 5, '2025-12-07 21:38:06', '2025-12-07 21:56:47', 'present', NULL, '2025-12-07 21:38:06', '2025-12-07 21:56:47');
INSERT INTO `attendance` VALUES (3, 4, 5, '2025-12-07 21:38:17', NULL, 'present', NULL, '2025-12-07 21:38:17', '2025-12-07 21:38:17');
INSERT INTO `attendance` VALUES (4, 3, 5, '2025-12-07 21:38:27', NULL, 'present', NULL, '2025-12-07 21:38:27', '2025-12-07 21:38:27');
INSERT INTO `attendance` VALUES (5, 2, 5, '2025-12-07 21:39:44', '2025-12-07 21:39:52', 'present', NULL, '2025-12-07 21:39:44', '2025-12-07 21:39:52');
INSERT INTO `attendance` VALUES (6, 19, 5, '2025-12-07 21:51:04', NULL, 'present', NULL, '2025-12-07 21:51:04', '2025-12-07 21:51:04');
INSERT INTO `attendance` VALUES (7, 17, 5, '2025-12-07 21:51:17', NULL, 'present', NULL, '2025-12-07 21:51:17', '2025-12-07 21:51:17');
INSERT INTO `attendance` VALUES (8, 11, 5, '2025-12-07 21:51:30', NULL, 'present', NULL, '2025-12-07 21:51:30', '2025-12-07 21:51:30');
INSERT INTO `attendance` VALUES (12, 4, 7, '2025-12-09 15:09:51', '2025-12-09 15:19:03', 'present', NULL, '2025-12-09 15:09:51', '2025-12-09 15:19:03');
INSERT INTO `attendance` VALUES (13, 3, 7, '2025-12-09 15:12:04', '2025-12-09 15:18:15', 'present', NULL, '2025-12-09 15:12:04', '2025-12-09 15:18:15');
INSERT INTO `attendance` VALUES (14, 9, 7, '2025-12-09 15:12:31', NULL, 'present', NULL, '2025-12-09 15:12:31', '2025-12-09 15:12:31');
INSERT INTO `attendance` VALUES (15, 18, 7, '2025-12-09 15:12:48', NULL, 'present', NULL, '2025-12-09 15:12:48', '2025-12-09 15:12:48');
INSERT INTO `attendance` VALUES (16, 5, 7, '2025-12-09 15:13:11', '2025-12-09 15:20:12', 'present', NULL, '2025-12-09 15:13:11', '2025-12-09 15:20:12');
INSERT INTO `attendance` VALUES (17, 8, 7, '2025-12-09 15:13:34', '2025-12-09 15:20:57', 'present', NULL, '2025-12-09 15:13:34', '2025-12-09 15:20:57');
INSERT INTO `attendance` VALUES (18, 15, 7, '2025-12-09 15:14:01', '2025-12-09 15:23:54', 'present', NULL, '2025-12-09 15:14:01', '2025-12-09 15:23:54');
INSERT INTO `attendance` VALUES (19, 11, 7, '2025-12-09 15:14:22', '2025-12-09 15:18:18', 'present', NULL, '2025-12-09 15:14:22', '2025-12-09 15:18:18');
INSERT INTO `attendance` VALUES (20, 1, 7, '2025-12-09 15:17:18', '2025-12-09 15:18:11', 'present', NULL, '2025-12-09 15:17:18', '2025-12-09 15:18:11');
INSERT INTO `attendance` VALUES (21, 2, 7, '2025-12-09 15:18:23', NULL, 'present', NULL, '2025-12-09 15:18:23', '2025-12-09 15:18:23');
INSERT INTO `attendance` VALUES (22, 6, 7, '2025-12-09 15:19:49', NULL, 'present', NULL, '2025-12-09 15:19:49', '2025-12-09 15:19:49');

-- ----------------------------
-- Table structure for attendance_logs
-- ----------------------------
DROP TABLE IF EXISTS `attendance_logs`;
CREATE TABLE `attendance_logs`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `attendance_id` int NOT NULL,
  `action` enum('time_in','time_out','status_change','manual_entry') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `old_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `new_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `changed_by` int NOT NULL,
  `changed_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_attendance_id`(`attendance_id` ASC) USING BTREE,
  INDEX `idx_changed_by`(`changed_by` ASC) USING BTREE,
  INDEX `idx_changed_at`(`changed_at` ASC) USING BTREE,
  INDEX `idx_action`(`action` ASC) USING BTREE,
  CONSTRAINT `attendance_logs_ibfk_1` FOREIGN KEY (`attendance_id`) REFERENCES `attendance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `attendance_logs_ibfk_2` FOREIGN KEY (`changed_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE = InnoDB AUTO_INCREMENT = 32 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of attendance_logs
-- ----------------------------
INSERT INTO `attendance_logs` VALUES (1, 2, 'time_in', NULL, '2025-12-07 21:38:06', 1, '2025-12-07 21:38:06', 'Manual entry - time in');
INSERT INTO `attendance_logs` VALUES (2, 3, 'time_in', NULL, '2025-12-07 21:38:17', 1, '2025-12-07 21:38:17', 'Manual entry - time in');
INSERT INTO `attendance_logs` VALUES (3, 4, 'time_in', NULL, '2025-12-07 21:38:27', 1, '2025-12-07 21:38:27', 'Manual entry - time in');
INSERT INTO `attendance_logs` VALUES (4, 5, 'time_in', NULL, '2025-12-07 21:39:44', 1, '2025-12-07 21:39:44', 'Manual entry - time in');
INSERT INTO `attendance_logs` VALUES (5, 5, 'time_out', NULL, '2025-12-07 21:39:52', 1, '2025-12-07 21:39:52', 'Manual entry - time out');
INSERT INTO `attendance_logs` VALUES (6, 6, 'time_in', NULL, '2025-12-07 21:51:04', 1, '2025-12-07 21:51:04', 'Manual entry - time in');
INSERT INTO `attendance_logs` VALUES (7, 7, 'time_in', NULL, '2025-12-07 21:51:17', 1, '2025-12-07 21:51:17', 'Manual entry - time in');
INSERT INTO `attendance_logs` VALUES (8, 8, 'time_in', NULL, '2025-12-07 21:51:30', 1, '2025-12-07 21:51:30', 'Manual entry - time in');
INSERT INTO `attendance_logs` VALUES (9, 2, 'time_out', NULL, '2025-12-07 21:56:47', 1, '2025-12-07 21:56:47', 'Manual entry - time out');
INSERT INTO `attendance_logs` VALUES (14, 12, 'time_in', NULL, '2025-12-09 15:09:51', 1, '2025-12-09 15:09:51', 'Manual entry - time in');
INSERT INTO `attendance_logs` VALUES (15, 13, 'time_in', NULL, '2025-12-09 15:12:04', 1, '2025-12-09 15:12:04', 'Manual entry - time in');
INSERT INTO `attendance_logs` VALUES (16, 14, 'time_in', NULL, '2025-12-09 15:12:31', 1, '2025-12-09 15:12:31', 'Manual entry - time in');
INSERT INTO `attendance_logs` VALUES (17, 15, 'time_in', NULL, '2025-12-09 15:12:48', 1, '2025-12-09 15:12:48', 'Manual entry - time in');
INSERT INTO `attendance_logs` VALUES (18, 16, 'time_in', NULL, '2025-12-09 15:13:11', 1, '2025-12-09 15:13:11', 'Manual entry - time in');
INSERT INTO `attendance_logs` VALUES (19, 17, 'time_in', NULL, '2025-12-09 15:13:34', 1, '2025-12-09 15:13:34', 'Manual entry - time in');
INSERT INTO `attendance_logs` VALUES (20, 18, 'time_in', NULL, '2025-12-09 15:14:01', 1, '2025-12-09 15:14:01', 'Manual entry - time in');
INSERT INTO `attendance_logs` VALUES (21, 19, 'time_in', NULL, '2025-12-09 15:14:22', 1, '2025-12-09 15:14:22', 'Manual entry - time in');
INSERT INTO `attendance_logs` VALUES (22, 20, 'time_in', NULL, '2025-12-09 15:17:18', 1, '2025-12-09 15:17:18', 'Manual entry - time in');
INSERT INTO `attendance_logs` VALUES (23, 20, 'time_out', NULL, '2025-12-09 15:18:11', 1, '2025-12-09 15:18:11', 'Manual entry - time out');
INSERT INTO `attendance_logs` VALUES (24, 13, 'time_out', NULL, '2025-12-09 15:18:15', 1, '2025-12-09 15:18:15', 'Manual entry - time out');
INSERT INTO `attendance_logs` VALUES (25, 19, 'time_out', NULL, '2025-12-09 15:18:18', 1, '2025-12-09 15:18:18', 'Manual entry - time out');
INSERT INTO `attendance_logs` VALUES (26, 21, 'time_in', NULL, '2025-12-09 15:18:23', 1, '2025-12-09 15:18:23', 'Manual entry - time in');
INSERT INTO `attendance_logs` VALUES (27, 12, 'time_out', NULL, '2025-12-09 15:19:03', 1, '2025-12-09 15:19:03', 'Manual entry - time out');
INSERT INTO `attendance_logs` VALUES (28, 22, 'time_in', NULL, '2025-12-09 15:19:49', 1, '2025-12-09 15:19:49', 'Manual entry - time in');
INSERT INTO `attendance_logs` VALUES (29, 16, 'time_out', NULL, '2025-12-09 15:20:12', 1, '2025-12-09 15:20:12', 'Manual entry - time out');
INSERT INTO `attendance_logs` VALUES (30, 17, 'time_out', NULL, '2025-12-09 15:20:57', 1, '2025-12-09 15:20:57', 'Manual entry - time out');
INSERT INTO `attendance_logs` VALUES (31, 18, 'time_out', NULL, '2025-12-09 15:23:54', 1, '2025-12-09 15:23:54', 'Manual entry - time out');

-- ----------------------------
-- Table structure for attendance_records
-- ----------------------------
DROP TABLE IF EXISTS `attendance_records`;
CREATE TABLE `attendance_records`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `student_id` int NOT NULL,
  `course_id` int NOT NULL,
  `status` enum('present','late','absent') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'present',
  `date_recorded` datetime NULL DEFAULT current_timestamp(),
  `created_by` int NULL DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `student_id`(`student_id` ASC) USING BTREE,
  INDEX `course_id`(`course_id` ASC) USING BTREE,
  INDEX `created_by`(`created_by` ASC) USING BTREE,
  CONSTRAINT `attendance_records_ibfk_1` FOREIGN KEY (`student_id`) REFERENCES `students` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `attendance_records_ibfk_2` FOREIGN KEY (`course_id`) REFERENCES `courses` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `attendance_records_ibfk_3` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of attendance_records
-- ----------------------------
INSERT INTO `attendance_records` VALUES (1, 3, 1, 'present', '2025-12-01 08:39:10', 1, '2025-12-01 08:39:10');
INSERT INTO `attendance_records` VALUES (2, 4, 1, 'present', '2025-12-01 08:40:49', 1, '2025-12-01 08:40:49');

-- ----------------------------
-- Table structure for courses
-- ----------------------------
DROP TABLE IF EXISTS `courses`;
CREATE TABLE `courses`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,
  `department_id` int NOT NULL,
  `duration_years` int NULL DEFAULT 4,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP,
  `status` tinyint NULL DEFAULT 1 COMMENT '1=Active, 0=Inactive',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `code`(`code` ASC) USING BTREE,
  INDEX `idx_code`(`code` ASC) USING BTREE,
  INDEX `idx_department_id`(`department_id` ASC) USING BTREE,
  INDEX `idx_status`(`status` ASC) USING BTREE,
  CONSTRAINT `courses_ibfk_1` FOREIGN KEY (`department_id`) REFERENCES `departments` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE = InnoDB AUTO_INCREMENT = 10 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of courses
-- ----------------------------
INSERT INTO `courses` VALUES (1, 'BSIT', 'Bachelor of Science in Information Technology', 'Information Technology Program', 1, 4, '2025-11-28 14:43:00', '2025-11-29 23:16:51', 1);
INSERT INTO `courses` VALUES (2, 'BSCS', 'Bachelor of Science in Computer Science', 'Computer Science Program', 1, 4, '2025-11-28 14:43:00', '2025-11-28 14:43:00', 1);
INSERT INTO `courses` VALUES (3, 'BSACC', 'Bachelor of Science in Accountancy', 'Accountancy Program', 2, 4, '2025-11-28 14:43:00', '2025-11-28 14:43:00', 1);
INSERT INTO `courses` VALUES (4, 'BSA', 'Bachelor of Science in Business Administration', 'Business Administration Program', 2, 4, '2025-11-28 14:43:00', '2025-11-28 14:43:00', 1);
INSERT INTO `courses` VALUES (5, 'BSHM', 'Bachelor of Science in Hospitality Management', 'Hospitality Management Program', 2, 4, '2025-11-28 14:43:00', '2025-11-28 14:43:00', 1);
INSERT INTO `courses` VALUES (6, 'BSTM', 'Bachelor of Science in Tourism Management', 'Tourism Management Program', 2, 4, '2025-11-28 14:43:00', '2025-11-28 14:43:00', 1);
INSERT INTO `courses` VALUES (7, 'BSCE', 'Bachelor of Science in Civil Engineering', 'Civil Engineering Program', 4, 5, '2025-11-28 14:43:00', '2025-11-28 14:43:00', 1);
INSERT INTO `courses` VALUES (8, 'BSEE', 'Bachelor of Science in Electrical Engineering', 'Electrical Engineering Program', 4, 5, '2025-11-28 14:43:00', '2025-11-28 14:43:00', 1);
INSERT INTO `courses` VALUES (9, 'BSCRIM', 'Bachelor of Science in Criminology', 'Criminology Program', 5, 4, '2025-11-28 14:43:00', '2025-11-28 14:43:00', 1);

-- ----------------------------
-- Table structure for departments
-- ----------------------------
DROP TABLE IF EXISTS `departments`;
CREATE TABLE `departments`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,
  `school_id` int NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP,
  `status` tinyint NULL DEFAULT 1 COMMENT '1=Active, 0=Inactive',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `code`(`code` ASC) USING BTREE,
  INDEX `idx_code`(`code` ASC) USING BTREE,
  INDEX `idx_school_id`(`school_id` ASC) USING BTREE,
  INDEX `idx_status`(`status` ASC) USING BTREE,
  CONSTRAINT `departments_ibfk_1` FOREIGN KEY (`school_id`) REFERENCES `schools` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of departments
-- ----------------------------
INSERT INTO `departments` VALUES (1, 'CASE', 'College of Arts, Sciences, Education & Information Technology', 'CASE Department', 1, '2025-11-28 14:43:00', '2025-11-28 14:43:00', 1);
INSERT INTO `departments` VALUES (2, 'CBMA', 'College of Business, Management, and Accountancy', 'CBMA Department', 1, '2025-11-28 14:43:00', '2025-11-28 14:43:00', 1);
INSERT INTO `departments` VALUES (3, 'SMS', 'School of Medical Sciences', 'Medical Sciences Department', 1, '2025-11-28 14:43:00', '2025-11-28 14:43:00', 1);
INSERT INTO `departments` VALUES (4, 'CET', 'College of Engineering and Technology', 'Engineering Department', 1, '2025-11-28 14:43:00', '2025-11-28 14:43:00', 1);
INSERT INTO `departments` VALUES (5, 'SOC', 'School of Criminology', 'Criminology Department', 1, '2025-11-28 14:43:00', '2025-11-28 14:43:00', 1);

-- ----------------------------
-- Table structure for genders
-- ----------------------------
DROP TABLE IF EXISTS `genders`;
CREATE TABLE `genders`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `code` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `name` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `code`(`code` ASC) USING BTREE,
  INDEX `idx_code`(`code` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of genders
-- ----------------------------
INSERT INTO `genders` VALUES (1, 'M', 'Male', '2025-11-28 14:43:00');
INSERT INTO `genders` VALUES (2, 'F', 'Female', '2025-11-28 14:43:00');
INSERT INTO `genders` VALUES (3, 'O', 'Others', '2025-11-28 14:43:00');

-- ----------------------------
-- Table structure for schools
-- ----------------------------
DROP TABLE IF EXISTS `schools`;
CREATE TABLE `schools`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `address` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,
  `contact_number` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `email` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP,
  `status` tinyint NULL DEFAULT 1 COMMENT '1=Active, 0=Inactive',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `code`(`code` ASC) USING BTREE,
  INDEX `idx_code`(`code` ASC) USING BTREE,
  INDEX `idx_status`(`status` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of schools
-- ----------------------------
INSERT INTO `schools` VALUES (1, 'AC', 'Aldersgate College', 'Burgos St., Brgy. Quirino, Solano, Nueva Vizcaya', '0912-345-6789', 'info@aldersgate.edu.ph', '2025-11-28 14:43:00', '2025-11-28 14:43:00', 1);

-- ----------------------------
-- Table structure for students
-- ----------------------------
DROP TABLE IF EXISTS `students`;
CREATE TABLE `students`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `student_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `qr_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `qr_code_image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `picture_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `full_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `gender_id` int NOT NULL,
  `year_level` int NOT NULL,
  `course_id` int NOT NULL,
  `department_id` int NOT NULL,
  `school_id` int NOT NULL,
  `birth_date` date NULL DEFAULT NULL,
  `contact_number` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `email` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `address` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP,
  `status` tinyint NULL DEFAULT 1 COMMENT '1=Active, 0=Inactive',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `student_id`(`student_id` ASC) USING BTREE,
  UNIQUE INDEX `qr_code`(`qr_code` ASC) USING BTREE,
  INDEX `gender_id`(`gender_id` ASC) USING BTREE,
  INDEX `idx_student_id`(`student_id` ASC) USING BTREE,
  INDEX `idx_qr_code`(`qr_code` ASC) USING BTREE,
  INDEX `idx_course_id`(`course_id` ASC) USING BTREE,
  INDEX `idx_department_id`(`department_id` ASC) USING BTREE,
  INDEX `idx_school_id`(`school_id` ASC) USING BTREE,
  INDEX `idx_year_level`(`year_level` ASC) USING BTREE,
  INDEX `idx_status`(`status` ASC) USING BTREE,
  INDEX `idx_full_name`(`full_name` ASC) USING BTREE,
  CONSTRAINT `students_ibfk_1` FOREIGN KEY (`gender_id`) REFERENCES `genders` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE,
  CONSTRAINT `students_ibfk_2` FOREIGN KEY (`course_id`) REFERENCES `courses` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE,
  CONSTRAINT `students_ibfk_3` FOREIGN KEY (`department_id`) REFERENCES `departments` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE,
  CONSTRAINT `students_ibfk_4` FOREIGN KEY (`school_id`) REFERENCES `schools` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE = InnoDB AUTO_INCREMENT = 21 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of students
-- ----------------------------
INSERT INTO `students` VALUES (1, '23-0217', 'STU_23-0217_692b07dd55c31', NULL, '', 'John Lloyd Sumawang', 1, 3, 1, 1, 1, '2004-12-26', '095691555892', 'johnlloydsumawang@gmail.com', 'Bascaran, Solano, Nueva Vizcaya', '2025-11-29 22:49:01', '2025-12-08 19:27:18', 1);
INSERT INTO `students` VALUES (2, '23-0403', 'STU_23-0403_692c3532235bc', NULL, '', 'Delight Grace Yogyog', 2, 3, 1, 1, 1, '2005-08-16', '', 'delightyogyog@gmail.com', '', '2025-11-30 20:14:42', '2025-12-08 19:27:55', 1);
INSERT INTO `students` VALUES (3, '23-0072', 'STU_23-0072_692c356aef39a', NULL, '', 'Rozalia Jane Dekket', 2, 3, 1, 1, 1, '2004-10-17', '', 'RozaliaJaneDekket@gmail.com', 'Poblacion South, Solano, N.V', '2025-11-30 20:15:38', '2025-12-08 19:28:00', 1);
INSERT INTO `students` VALUES (4, '23-0147', 'STU_23-0147_692ce2ea80975', NULL, '', 'Jelyn Marcos Monte', 2, 3, 1, 1, 1, '2004-01-21', '0967126375', 'jelynmonte@gmail.com', 'Solano, Nueva Vizcaya', '2025-12-01 08:35:54', '2025-12-08 19:28:05', 1);
INSERT INTO `students` VALUES (5, '15-10187', 'STU_15-10187_692e9a3234f87', 'student_15-10187_1764693277.html', NULL, 'Jayster Rey Cabay', 1, 3, 1, 1, 1, '0000-00-00', '', '', '', '2025-12-02 15:50:10', '2025-12-03 00:34:37', 1);
INSERT INTO `students` VALUES (6, '016-0097', 'STU_016-0097_692e9a9774dcc', NULL, NULL, 'John Learry Castro', 1, 3, 1, 1, 1, '0000-00-00', '', '', '', '2025-12-02 15:51:51', '2025-12-02 15:51:51', 1);
INSERT INTO `students` VALUES (7, '22-0278', 'STU_22-0278_692e9ad319f7d', NULL, NULL, 'Mark Edrian Garica', 1, 3, 1, 1, 1, '0000-00-00', '', '', '', '2025-12-02 15:52:51', '2025-12-02 15:52:51', 1);
INSERT INTO `students` VALUES (8, '22-20099', 'STU_22-20099_692e9b145d566', NULL, NULL, 'Jeon Jeon Jac', 1, 3, 1, 1, 1, '0000-00-00', '', '', '', '2025-12-02 15:53:56', '2025-12-02 15:53:56', 1);
INSERT INTO `students` VALUES (9, '23-0241', 'STU_23-0241_692e9b5e33af7', NULL, NULL, 'Hercules Jon Honrales', 1, 3, 1, 1, 1, '0000-00-00', '', '', '', '2025-12-02 15:55:10', '2025-12-02 15:55:10', 1);
INSERT INTO `students` VALUES (10, '20-10056', 'STU_20-10056_692e9be0ed5d2', NULL, NULL, 'Jan Mark Manuel', 1, 3, 1, 1, 1, '0000-00-00', '', '', '', '2025-12-02 15:57:20', '2025-12-02 15:57:20', 1);
INSERT INTO `students` VALUES (11, '23-0250', 'STU_23-0250_692e9c361c836', NULL, NULL, 'John Carlo Marcelino', 1, 3, 1, 1, 1, '0000-00-00', '', '', '', '2025-12-02 15:58:46', '2025-12-02 15:58:46', 1);
INSERT INTO `students` VALUES (12, '22-0496', 'STU_22-0496_692e9c71591fd', NULL, NULL, 'Kenn Charlee Martinez', 1, 3, 1, 1, 1, '0000-00-00', '', '', '', '2025-12-02 15:59:45', '2025-12-02 15:59:45', 1);
INSERT INTO `students` VALUES (13, '23-0433', 'STU_23-0433_692e9cfe5cd6d', NULL, NULL, 'Melchor Paculla Jr.', 1, 3, 1, 1, 1, '0000-00-00', '', '', '', '2025-12-02 16:02:06', '2025-12-02 16:02:06', 1);
INSERT INTO `students` VALUES (14, '016-0128', 'STU_016-0128_692e9d728aa84', NULL, NULL, 'Gregorio Ragasa', 1, 3, 1, 1, 1, '0000-00-00', '', '', '', '2025-12-02 16:04:02', '2025-12-02 16:04:02', 1);
INSERT INTO `students` VALUES (15, '23-0203', 'STU_23-0203_692e9db4c726c', NULL, NULL, 'Cyruz Sibug', 1, 3, 1, 1, 1, '0000-00-00', '', '', '', '2025-12-02 16:05:08', '2025-12-02 16:05:08', 1);
INSERT INTO `students` VALUES (16, '20-10492', 'STU_20-10492_692e9df4a5c5a', NULL, NULL, 'Jerald Solis', 1, 3, 1, 1, 1, '0000-00-00', '', '', '', '2025-12-02 16:06:12', '2025-12-02 16:06:12', 1);
INSERT INTO `students` VALUES (17, '15-10131', 'STU_15-10131_692e9e2135b6a', 'student_15-10131_1764693193.html', NULL, 'Jolas Tucli', 1, 3, 1, 1, 1, '0000-00-00', '', '', '', '2025-12-02 16:06:57', '2025-12-03 00:33:13', 1);
INSERT INTO `students` VALUES (18, '017-0104', 'STU_017-0104_692e9e4f41721', 'student_017-0104_1764692828.html', NULL, 'Jose Victor Uy', 1, 3, 1, 1, 1, '0000-00-00', '', '', '', '2025-12-02 16:07:43', '2025-12-03 00:27:08', 1);
INSERT INTO `students` VALUES (19, '18-10147', 'STU_18-10147_692e9e91c98eb', 'student_18-10147_1764692769.html', NULL, 'Jameson Valera', 1, 3, 1, 1, 1, '0000-00-00', '', '', '', '2025-12-02 16:08:49', '2025-12-03 00:26:09', 1);

-- ----------------------------
-- Table structure for system_settings
-- ----------------------------
DROP TABLE IF EXISTS `system_settings`;
CREATE TABLE `system_settings`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `setting_key` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `setting_value` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,
  `updated_by` int NULL DEFAULT NULL,
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `setting_key`(`setting_key` ASC) USING BTREE,
  INDEX `updated_by`(`updated_by` ASC) USING BTREE,
  INDEX `idx_setting_key`(`setting_key` ASC) USING BTREE,
  CONSTRAINT `system_settings_ibfk_1` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of system_settings
-- ----------------------------

-- ----------------------------
-- Table structure for users
-- ----------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `role` enum('admin','teacher') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `full_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `email` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP,
  `status` tinyint NULL DEFAULT 1 COMMENT '1=Active, 0=Inactive',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `username`(`username` ASC) USING BTREE,
  INDEX `idx_username`(`username` ASC) USING BTREE,
  INDEX `idx_role`(`role` ASC) USING BTREE,
  INDEX `idx_status`(`status` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of users
-- ----------------------------
INSERT INTO `users` VALUES (1, 'johnlloydsumawang26', '$2y$10$cH0FJuPLd467oX0q01ZADu6v2lh0kmfNob0HOyO5tuRstcdXBbIuS', 'admin', 'John Lloyd Sumawang', 'johnlloydsumawang@gmail.com', '2025-11-28 14:43:00', '2025-12-13 20:57:06', 1);
INSERT INTO `users` VALUES (10, 'SPayDigong', '$2y$10$r02pNIERlJKRmrT6haCP8.YLpEAAEM0hTYRQnWpJ7ktZ6E6GRjQNq', 'admin', 'RODRIGO JR AMORIN', 'redgie@simc.gov.ph', '2025-12-13 20:35:31', '2025-12-13 20:35:40', 1);

SET FOREIGN_KEY_CHECKS = 1;
