-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Aug 31, 2025 at 11:45 AM
-- Server version: 10.4.28-MariaDB
-- PHP Version: 8.2.4
SET FOREIGN_KEY_CHECKS=0;
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
--
-- Database: `deped_sms_db`
--
CREATE DATABASE IF NOT EXISTS `deped_sms_db` DEFAULT CHARACTER SET utf8mb4 COLLATE
utf8mb4_general_ci;
USE `deped_sms_db`;
-- --------------------------------------------------------
--
-- Table structure for table `admins`
--
DROP TABLE IF EXISTS `admins`;
CREATE TABLE `admins` (
`id` int(11) NOT NULL,
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
--
-- Table structure for table `attendance`
-- Source: SF2
--
DROP TABLE IF EXISTS `attendance`;
CREATE TABLE `attendance` (
`id` int(11) NOT NULL,
`learner_id` int(11) NOT NULL,
`attendance_date` date NOT NULL,
`status` varchar(10) NOT NULL COMMENT '''Present'', ''Absent'', ''Late''',
`created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
--
-- Table structure for table `grades`
-- Source: e-Class Record, SF9, SF10
--
DROP TABLE IF EXISTS `grades`;
CREATE TABLE `grades` (
`id` int(11) NOT NULL,
`learner_id` int(11) NOT NULL,
`subject_id` int(11) NOT NULL,
`quarter` int(11) NOT NULL,
`school_year` varchar(10) NOT NULL,
`ww1` decimal(5,2) DEFAULT NULL,
`ww2` decimal(5,2) DEFAULT NULL,
`ww3` decimal(5,2) DEFAULT NULL,
`ww4` decimal(5,2) DEFAULT NULL,
`ww5` decimal(5,2) DEFAULT NULL,
`ww6` decimal(5,2) DEFAULT NULL,
`ww7` decimal(5,2) DEFAULT NULL,
`ww8` decimal(5,2) DEFAULT NULL,
`ww9` decimal(5,2) DEFAULT NULL,
`ww10` decimal(5,2) DEFAULT NULL,
`pt1` decimal(5,2) DEFAULT NULL,
`pt2` decimal(5,2) DEFAULT NULL,
`pt3` decimal(5,2) DEFAULT NULL,
`pt4` decimal(5,2) DEFAULT NULL,
`pt5` decimal(5,2) DEFAULT NULL,
`pt6` decimal(5,2) DEFAULT NULL,
`pt7` decimal(5,2) DEFAULT NULL,
`pt8` decimal(5,2) DEFAULT NULL,
`pt9` decimal(5,2) DEFAULT NULL,
`pt10` decimal(5,2) DEFAULT NULL,
`qa1` decimal(5,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
--
-- Table structure for table `grade_levels`
--
DROP TABLE IF EXISTS `grade_levels`;
CREATE TABLE `grade_levels` (
`id` int(11) NOT NULL,
`grade_name` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
--
-- Table structure for table `health_profiles`
-- Source: SF8
--
DROP TABLE IF EXISTS `health_profiles`;
CREATE TABLE `health_profiles` (
`id` int(11) NOT NULL,
`learner_id` int(11) NOT NULL,
`school_year` varchar(10) NOT NULL,
`measurement_period` varchar(20) NOT NULL COMMENT '''beginning'' or ''end'' of
year',
`weight_kg` decimal(5,2) DEFAULT NULL,
`height_m` decimal(5,2) DEFAULT NULL,
`bmi` decimal(5,2) DEFAULT NULL,
`bmi_category` varchar(20) DEFAULT NULL,
`hfa_category` varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
--
-- Table structure for table `highest_scores`
-- Source: e-Class Record
--
DROP TABLE IF EXISTS `highest_scores`;
CREATE TABLE `highest_scores` (
`id` int(11) NOT NULL,
`subject_id` int(11) NOT NULL,
`section_id` int(11) NOT NULL,
`quarter` int(11) NOT NULL,
`school_year` varchar(10) NOT NULL,
`ww_weight` decimal(5,2) NOT NULL,
`pt_weight` decimal(5,2) NOT NULL,
`qa_weight` decimal(5,2) NOT NULL,
`ww1` int(11) DEFAULT NULL,
`ww2` int(11) DEFAULT NULL,
`ww3` int(11) DEFAULT NULL,
`ww4` int(11) DEFAULT NULL,
`ww5` int(11) DEFAULT NULL,
`ww6` int(11) DEFAULT NULL,
`ww7` int(11) DEFAULT NULL,
`ww8` int(11) DEFAULT NULL,
`ww9` int(11) DEFAULT NULL,
`ww10` int(11) DEFAULT NULL,
`pt1` int(11) DEFAULT NULL,
`pt2` int(11) DEFAULT NULL,
`pt3` int(11) DEFAULT NULL,
`pt4` int(11) DEFAULT NULL,
`pt5` int(11) DEFAULT NULL,
`pt6` int(11) DEFAULT NULL,
`pt7` int(11) DEFAULT NULL,
`pt8` int(11) DEFAULT NULL,
`pt9` int(11) DEFAULT NULL,
`pt10` int(11) DEFAULT NULL,
`qa1` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
--
-- Table structure for table `learners`
-- Source: SF1
--
DROP TABLE IF EXISTS `learners`;
CREATE TABLE `learners` (
`id` int(11) NOT NULL,
`lrn` varchar(12) DEFAULT NULL,
`last_name` varchar(255) NOT NULL,
`first_name` varchar(255) NOT NULL,
`middle_name` varchar(255) DEFAULT NULL,
`name_extension` varchar(10) DEFAULT NULL,
`gender` varchar(10) NOT NULL,
`birth_date` date NOT NULL,
`profile_picture` varchar(255) DEFAULT NULL,
`section_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
--
-- Table structure for table `learner_details`
-- Source: SF1, SF10
--
DROP TABLE IF EXISTS `learner_details`;
CREATE TABLE `learner_details` (
`id` int(11) NOT NULL,
`learner_id` int(11) NOT NULL,
`mother_tongue` varchar(50) DEFAULT NULL,
`ethnic_group` varchar(50) DEFAULT NULL,
`religion` varchar(50) DEFAULT NULL,
`address_street` varchar(255) DEFAULT NULL,
`address_barangay` varchar(255) DEFAULT NULL,
`address_municipality` varchar(255) DEFAULT NULL,
`address_province` varchar(255) DEFAULT NULL,
`father_name` varchar(255) DEFAULT NULL,
`mother_maiden_name` varchar(255) DEFAULT NULL,
`guardian_name` varchar(255) DEFAULT NULL,
`guardian_relationship` varchar(50) DEFAULT NULL,
`guardian_contact_no` varchar(50) DEFAULT NULL,
`elem_school_name` varchar(255) DEFAULT NULL,
`elem_school_id` varchar(20) DEFAULT NULL,
`elem_gen_ave` decimal(5,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
--
-- Table structure for table `observed_values`
-- Source: SF9
--
DROP TABLE IF EXISTS `observed_values`;
CREATE TABLE `observed_values` (
`id` int(11) NOT NULL,
`learner_id` int(11) NOT NULL,
`quarter` int(11) NOT NULL,
`school_year` varchar(10) NOT NULL,
`value_maka_diyos` varchar(2) DEFAULT NULL,
`value_makatao` varchar(2) DEFAULT NULL,
`value_makakalikasan` varchar(2) DEFAULT NULL,
`value_makabansa` varchar(2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
--
-- Table structure for table `sections`
--
DROP TABLE IF EXISTS `sections`;
CREATE TABLE `sections` (
`id` int(11) NOT NULL,
`section_name` varchar(100) NOT NULL,
`grade_level_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
--
-- Table structure for table `subjects`
--
DROP TABLE IF EXISTS `subjects`;
CREATE TABLE `subjects` (
`id` int(11) NOT NULL,
`subject_name` varchar(255) NOT NULL,
`subject_level` varchar(10) NOT NULL COMMENT '''JHS'' or ''SHS''',
`ww_weight` decimal(5,2) NOT NULL DEFAULT 0.25,
`pt_weight` decimal(5,2) NOT NULL DEFAULT 0.45,
`qa_weight` decimal(5,2) NOT NULL DEFAULT 0.30
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
--
-- Table structure for table `teachers`
-- Source: SF7
--
DROP TABLE IF EXISTS `teachers`;
CREATE TABLE `teachers` (
`id` int(11) NOT NULL,
`employee_no` varchar(50) NOT NULL,
`tin` varchar(20) DEFAULT NULL,
`last_name` varchar(255) NOT NULL,
`first_name` varchar(255) NOT NULL,
`middle_name` varchar(255) DEFAULT NULL,
`gender` varchar(10) NOT NULL,
`password` varchar(255) NOT NULL,
`position` varchar(100) DEFAULT NULL,
`fund_source` varchar(50) DEFAULT NULL,
`degree` varchar(255) DEFAULT NULL,
`major` varchar(100) DEFAULT NULL,
`minor` varchar(100) DEFAULT NULL,
`advisory_section_id` int(11) DEFAULT NULL,
`profile_picture` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
--
-- Table structure for table `teacher_advisory`
--
DROP TABLE IF EXISTS `teacher_advisory`;
CREATE TABLE `teacher_advisory` (
`teacher_id` int(11) NOT NULL,
`section_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
--
-- Table structure for table `teacher_subjects`
--
DROP TABLE IF EXISTS `teacher_subjects`;
CREATE TABLE `teacher_subjects` (
`teacher_id` int(11) NOT NULL,
`subject_id` int(11) NOT NULL,
`section_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Indexes for dumped tables
--
ALTER TABLE `admins`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `username` (`username`);
ALTER TABLE `attendance`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `uniq_learner_date` (`learner_id`,`attendance_date`),
ADD KEY `learner_id` (`learner_id`);
ALTER TABLE `grades`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `uniq_learner_subject_quarter_year`
(`learner_id`,`subject_id`,`quarter`,`school_year`),
ADD KEY `subject_id` (`subject_id`);
ALTER TABLE `grade_levels`
ADD PRIMARY KEY (`id`);
ALTER TABLE `health_profiles`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `uniq_learner_year_period`
(`learner_id`,`school_year`,`measurement_period`),
ADD KEY `learner_id` (`learner_id`);
ALTER TABLE `highest_scores`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `uniq_subject_section_quarter_year`
(`subject_id`,`section_id`,`quarter`,`school_year`),
ADD KEY `section_id` (`section_id`);
ALTER TABLE `learners`
ADD PRIMARY KEY (`id`),
ADD KEY `section_id` (`section_id`);
ALTER TABLE `learner_details`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `learner_id` (`learner_id`);
ALTER TABLE `observed_values`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `uniq_learner_quarter_year`
(`learner_id`,`quarter`,`school_year`),
ADD KEY `learner_id` (`learner_id`);
ALTER TABLE `sections`
ADD PRIMARY KEY (`id`),
ADD KEY `grade_level_id` (`grade_level_id`);
ALTER TABLE `subjects`
ADD PRIMARY KEY (`id`);
ALTER TABLE `teachers`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `employee_no` (`employee_no`),
ADD KEY `advisory_section_id` (`advisory_section_id`);
ALTER TABLE `teacher_advisory`
ADD PRIMARY KEY (`teacher_id`,`section_id`),
ADD KEY `section_id` (`section_id`);
ALTER TABLE `teacher_subjects`
ADD PRIMARY KEY (`teacher_id`,`subject_id`,`section_id`),
ADD KEY `subject_id` (`subject_id`),
ADD KEY `section_id` (`section_id`);
--
-- AUTO_INCREMENT for dumped tables
--
ALTER TABLE `admins` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `attendance` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `grades` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `grade_levels` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `health_profiles` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `highest_scores` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `learners` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `learner_details` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `observed_values` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `sections` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `subjects` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `teachers` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- Constraints for dumped tables
--
ALTER TABLE `attendance`
ADD CONSTRAINT `attendance_ibfk_1` FOREIGN KEY (`learner_id`) REFERENCES
`learners` (`id`) ON DELETE CASCADE;
ALTER TABLE `grades`
ADD CONSTRAINT `grades_ibfk_1` FOREIGN KEY (`learner_id`) REFERENCES `learners`
(`id`) ON DELETE CASCADE,
ADD CONSTRAINT `grades_ibfk_2` FOREIGN KEY (`subject_id`) REFERENCES `subjects`
(`id`) ON DELETE CASCADE;
ALTER TABLE `health_profiles`
ADD CONSTRAINT `health_profiles_ibfk_1` FOREIGN KEY (`learner_id`) REFERENCES
`learners` (`id`) ON DELETE CASCADE;
ALTER TABLE `highest_scores`
ADD CONSTRAINT `highest_scores_ibfk_1` FOREIGN KEY (`subject_id`) REFERENCES
`subjects` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `highest_scores_ibfk_2` FOREIGN KEY (`section_id`) REFERENCES
`sections` (`id`) ON DELETE CASCADE;
ALTER TABLE `learners`
ADD CONSTRAINT `learners_ibfk_1` FOREIGN KEY (`section_id`) REFERENCES `sections`
(`id`) ON DELETE SET NULL;
ALTER TABLE `learner_details`
ADD CONSTRAINT `learner_details_ibfk_1` FOREIGN KEY (`learner_id`) REFERENCES
`learners` (`id`) ON DELETE CASCADE;
ALTER TABLE `observed_values`
ADD CONSTRAINT `observed_values_ibfk_1` FOREIGN KEY (`learner_id`) REFERENCES
`learners` (`id`) ON DELETE CASCADE;
ALTER TABLE `sections`
ADD CONSTRAINT `sections_ibfk_1` FOREIGN KEY (`grade_level_id`) REFERENCES
`grade_levels` (`id`) ON DELETE CASCADE;
ALTER TABLE `teachers`
ADD CONSTRAINT `teachers_ibfk_1` FOREIGN KEY (`advisory_section_id`) REFERENCES
`sections` (`id`) ON DELETE SET NULL;
ALTER TABLE `teacher_advisory`
ADD CONSTRAINT `teacher_advisory_ibfk_1` FOREIGN KEY (`teacher_id`) REFERENCES
`teachers` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `teacher_advisory_ibfk_2` FOREIGN KEY (`section_id`) REFERENCES
`sections` (`id`) ON DELETE CASCADE;
ALTER TABLE `teacher_subjects`
ADD CONSTRAINT `teacher_subjects_ibfk_1` FOREIGN KEY (`teacher_id`) REFERENCES
`teachers` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `teacher_subjects_ibfk_2` FOREIGN KEY (`subject_id`) REFERENCES
`subjects` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `teacher_subjects_ibfk_3` FOREIGN KEY (`section_id`) REFERENCES
`sections` (`id`) ON DELETE CASCADE;
COMMIT;
SET FOREIGN_KEY_CHECKS=1;