text: -- phpMyAdmin SQL Dump
  -- version 5.0.3
  -- https://www.phpmyadmin.net/
  --
  -- Host: 127.0.0.1
  -- Generation Time: Jul 05, 2021 at 04:52 AM
  -- Server version: 10.4.14-MariaDB
  -- PHP Version: 7.2.34
  
  SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
  START TRANSACTION;
  SET time_zone = "+00:00";
  
  
  /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
  /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
  /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
  /*!40101 SET NAMES utf8mb4 */;
  
  --
  -- Database: `wdt_db`
  --
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `classes_tbl`
  --
  
  CREATE TABLE `classes_tbl` (
    `id` int(11) NOT NULL,
    `class_name` varchar(150) NOT NULL,
    `total_subjects_assigned` int(11) NOT NULL DEFAULT 0,
    `total_pupils_enrolled` int(11) NOT NULL DEFAULT 0
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  
  --
  -- Dumping data for table `classes_tbl`
  --
  
  INSERT INTO `classes_tbl` (`id`, `class_name`, `total_subjects_assigned`, `total_pupils_enrolled`) VALUES
  (1, 'Class-1', 0, 0),
  (4, 'Class-5', 0, 0);
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `keys`
  --
  
  CREATE TABLE `keys` (
    `id` int(11) NOT NULL,
    `user_id` int(11) NOT NULL,
    `key` varchar(40) NOT NULL,
    `level` int(2) NOT NULL,
    `ignore_limits` tinyint(1) NOT NULL DEFAULT 0,
    `is_private_key` tinyint(1) NOT NULL DEFAULT 0,
    `ip_addresses` text DEFAULT NULL,
    `date_created` datetime NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  
  --
  -- Dumping data for table `keys`
  --
  
  INSERT INTO `keys` (`id`, `user_id`, `key`, `level`, `ignore_limits`, `is_private_key`, `ip_addresses`, `date_created`) VALUES
  (1, 1, 'wdt@123', 0, 0, 0, NULL, '2021-06-06 13:34:33');
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `message_tbl`
  --
  
  CREATE TABLE `message_tbl` (
    `id` int(11) NOT NULL,
    `from_id` int(11) NOT NULL,
    `to_id` int(11) NOT NULL,
    `message` text NOT NULL,
    `message_date` date NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  
  --
  -- Dumping data for table `message_tbl`
  --
  
  INSERT INTO `message_tbl` (`id`, `from_id`, `to_id`, `message`, `message_date`) VALUES
  (1, 1, 9, 'A message from admin to Hussnain.', '2021-07-04'),
  (17, 1, 5, 'Hello ALL...', '2021-07-04'),
  (18, 1, 17, 'Hello ALL...', '2021-07-04'),
  (19, 1, 16, 'Hello ALL...', '2021-07-04'),
  (21, 2, 17, 'Hello Sozan', '2021-07-04'),
  (22, 2, 5, 'Hello Ismail', '2021-07-04'),
  (23, 2, 5, 'Hello Class', '2021-07-04'),
  (24, 2, 17, 'Hello Class', '2021-07-04'),
  (25, 2, 16, 'Hello Class', '2021-07-04'),
  (26, 1, 2, 'Hello Saad', '2021-07-04'),
  (27, 17, 5, 'Hello Ismail from Sozan', '2021-07-04'),
  (28, 5, 5, 'Hello SSE From Ismail!', '2021-07-04'),
  (29, 5, 17, 'Hello SSE From Ismail!', '2021-07-04'),
  (30, 5, 16, 'Hello SSE From Ismail!', '2021-07-04'),
  (31, 1, 17, 'hello sozan from admin', '2021-07-04');
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `pupil_enrollment`
  --
  
  CREATE TABLE `pupil_enrollment` (
    `id` int(11) NOT NULL,
    `class_id` int(11) NOT NULL,
    `user_id` int(11) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  
  --
  -- Dumping data for table `pupil_enrollment`
  --
  
  INSERT INTO `pupil_enrollment` (`id`, `class_id`, `user_id`) VALUES
  (1, 1, 5),
  (8, 1, 17),
  (9, 1, 16);
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `pupil_test_result`
  --
  
  CREATE TABLE `pupil_test_result` (
    `id` int(11) NOT NULL,
    `test_id` int(11) NOT NULL,
    `subject_id` int(11) NOT NULL,
    `student_id` int(11) NOT NULL,
    `marks` int(11) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  
  --
  -- Dumping data for table `pupil_test_result`
  --
  
  INSERT INTO `pupil_test_result` (`id`, `test_id`, `subject_id`, `student_id`, `marks`) VALUES
  (1, 2, 1, 5, 7),
  (2, 2, 1, 17, 4),
  (3, 2, 1, 16, 9),
  (4, 1, 9, 5, 8),
  (5, 1, 9, 17, 9),
  (6, 1, 9, 16, 10),
  (7, 5, 1, 5, 8),
  (8, 5, 1, 17, 4),
  (9, 5, 1, 16, 8);
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `subject_tbl`
  --
  
  CREATE TABLE `subject_tbl` (
    `id` int(11) NOT NULL,
    `subject_name` varchar(255) NOT NULL,
    `subject_teacher` int(11) NOT NULL,
    `class_id` int(11) DEFAULT NULL,
    `is_archived` int(11) NOT NULL DEFAULT 0,
    `dependent_test` int(11) DEFAULT 0
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  
  --
  -- Dumping data for table `subject_tbl`
  --
  
  INSERT INTO `subject_tbl` (`id`, `subject_name`, `subject_teacher`, `class_id`, `is_archived`, `dependent_test`) VALUES
  (1, 'Maths-1', 2, 1, 0, 1),
  (5, 'Urdu-2', 1, NULL, 1, 1),
  (8, 'German A2', 2, NULL, 1, 1),
  (9, 'SSE', 2, 1, 1, 1);
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `subject_test_tbl`
  --
  
  CREATE TABLE `subject_test_tbl` (
    `id` int(11) NOT NULL,
    `test_name` varchar(255) NOT NULL,
    `subject_id` int(11) NOT NULL,
    `test_date` date DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  
  --
  -- Dumping data for table `subject_test_tbl`
  --
  
  INSERT INTO `subject_test_tbl` (`id`, `test_name`, `subject_id`, `test_date`) VALUES
  (1, 'Algebra-2', 9, '2021-07-01'),
  (2, 'Math Tests', 1, '2021-07-02'),
  (3, 'Urdu Test', 5, '2021-07-01'),
  (5, 'Math Monthly Test', 1, '2021-07-03');
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `users_tbl`
  --
  
  CREATE TABLE `users_tbl` (
    `user_id` int(11) NOT NULL,
    `systemID` varchar(8) NOT NULL,
    `user_type_id` int(11) DEFAULT NULL,
    `forename` varchar(100) NOT NULL,
    `surname` varchar(100) DEFAULT NULL,
    `user_name` varchar(100) NOT NULL,
    `password` varchar(256) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  
  --
  -- Dumping data for table `users_tbl`
  --
  
  INSERT INTO `users_tbl` (`user_id`, `systemID`, `user_type_id`, `forename`, `surname`, `user_name`, `password`) VALUES
  (1, 'A1432H87', 1, 'Mr. Admin', 'Admin', 'admin', '21232f297a57a5a743894a0e4a801fc3'),
  (2, 'EBWYLDAM', 2, 'Muhammad Saad', 'Afzal', 'Saad_8385', '81dc9bdb52d04dc20036dbd8313ed055'),
  (5, '6IHZEXUZ', 3, 'Ismail', 'Yaqoobi', 'Ismail_27', '81dc9bdb52d04dc20036dbd8313ed055'),
  (8, 'SLVXOO15', 3, 'Ali', 'Aslam', 'Ali_456', '81dc9bdb52d04dc20036dbd8313ed055'),
  (9, 'DXL97MT2', 3, 'Hussnain', 'Chaudhary', 'Hussnain56', '827ccb0eea8a706c4c34a16891f84e7b'),
  (15, 'TCT3I0S3', 2, 'Hamza', 'Dabeer', 'hamza_12', '81dc9bdb52d04dc20036dbd8313ed055'),
  (16, 'UR3TW8JT', 3, 'David', 'Jones', 'jones_87', '81dc9bdb52d04dc20036dbd8313ed055'),
  (17, 'SBA0HZOZ', 3, 'Sozan', 'Kamaran', 'sozan', '81dc9bdb52d04dc20036dbd8313ed055'),
  (18, 'RPDNDEU3', 3, 'Angela', 'David', 'david_98', '81dc9bdb52d04dc20036dbd8313ed055');
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `users_type`
  --
  
  CREATE TABLE `users_type` (
    `id` int(11) NOT NULL,
    `user_type` varchar(50) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  
  --
  -- Dumping data for table `users_type`
  --
  
  INSERT INTO `users_type` (`id`, `user_type`) VALUES
  (1, 'admin'),
  (2, 'teacher'),
  (3, 'pupil');
  
  --
  -- Indexes for dumped tables
  --
  
  --
  -- Indexes for table `classes_tbl`
  --
  ALTER TABLE `classes_tbl`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `keys`
  --
  ALTER TABLE `keys`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `message_tbl`
  --
  ALTER TABLE `message_tbl`
    ADD PRIMARY KEY (`id`),
    ADD KEY `from_id` (`from_id`),
    ADD KEY `to_id` (`to_id`);
  
  --
  -- Indexes for table `pupil_enrollment`
  --
  ALTER TABLE `pupil_enrollment`
    ADD PRIMARY KEY (`id`),
    ADD KEY `class_id` (`class_id`),
    ADD KEY `user_id` (`user_id`);
  
  --
  -- Indexes for table `pupil_test_result`
  --
  ALTER TABLE `pupil_test_result`
    ADD PRIMARY KEY (`id`),
    ADD KEY `test_id` (`test_id`),
    ADD KEY `subject_id` (`subject_id`),
    ADD KEY `student_id` (`student_id`);
  
  --
  -- Indexes for table `subject_tbl`
  --
  ALTER TABLE `subject_tbl`
    ADD PRIMARY KEY (`id`),
    ADD KEY `subject_teacher` (`subject_teacher`),
    ADD KEY `class_id` (`class_id`);
  
  --
  -- Indexes for table `subject_test_tbl`
  --
  ALTER TABLE `subject_test_tbl`
    ADD PRIMARY KEY (`id`),
    ADD KEY `subject_id` (`subject_id`);
  
  --
  -- Indexes for table `users_tbl`
  --
  ALTER TABLE `users_tbl`
    ADD PRIMARY KEY (`user_id`),
    ADD KEY `user_type_id` (`user_type_id`);
  
  --
  -- Indexes for table `users_type`
  --
  ALTER TABLE `users_type`
    ADD PRIMARY KEY (`id`);
  
  --
  -- AUTO_INCREMENT for dumped tables
  --
  
  --
  -- AUTO_INCREMENT for table `classes_tbl`
  --
  ALTER TABLE `classes_tbl`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
  
  --
  -- AUTO_INCREMENT for table `keys`
  --
  ALTER TABLE `keys`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
  
  --
  -- AUTO_INCREMENT for table `message_tbl`
  --
  ALTER TABLE `message_tbl`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=32;
  
  --
  -- AUTO_INCREMENT for table `pupil_enrollment`
  --
  ALTER TABLE `pupil_enrollment`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
  
  --
  -- AUTO_INCREMENT for table `pupil_test_result`
  --
  ALTER TABLE `pupil_test_result`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
  
  --
  -- AUTO_INCREMENT for table `subject_tbl`
  --
  ALTER TABLE `subject_tbl`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
  
  --
  -- AUTO_INCREMENT for table `subject_test_tbl`
  --
  ALTER TABLE `subject_test_tbl`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
  
  --
  -- AUTO_INCREMENT for table `users_tbl`
  --
  ALTER TABLE `users_tbl`
    MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19;
  
  --
  -- AUTO_INCREMENT for table `users_type`
  --
  ALTER TABLE `users_type`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
  
  --
  -- Constraints for dumped tables
  --
  
  --
  -- Constraints for table `message_tbl`
  --
  ALTER TABLE `message_tbl`
    ADD CONSTRAINT `message_tbl_ibfk_1` FOREIGN KEY (`from_id`) REFERENCES `users_tbl` (`user_id`);
  
  --
  -- Constraints for table `pupil_enrollment`
  --
  ALTER TABLE `pupil_enrollment`
    ADD CONSTRAINT `pupil_enrollment_ibfk_1` FOREIGN KEY (`class_id`) REFERENCES `classes_tbl` (`id`),
    ADD CONSTRAINT `pupil_enrollment_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users_tbl` (`user_id`);
  
  --
  -- Constraints for table `pupil_test_result`
  --
  ALTER TABLE `pupil_test_result`
    ADD CONSTRAINT `pupil_test_result_ibfk_1` FOREIGN KEY (`test_id`) REFERENCES `subject_test_tbl` (`id`);
  
  --
  -- Constraints for table `subject_tbl`
  --
  ALTER TABLE `subject_tbl`
    ADD CONSTRAINT `subject_tbl_ibfk_1` FOREIGN KEY (`subject_teacher`) REFERENCES `users_tbl` (`user_id`);
  
  --
  -- Constraints for table `subject_test_tbl`
  --
  ALTER TABLE `subject_test_tbl`
    ADD CONSTRAINT `subject_test_tbl_ibfk_1` FOREIGN KEY (`subject_id`) REFERENCES `subject_tbl` (`id`);
  
  --
  -- Constraints for table `users_tbl`
  --
  ALTER TABLE `users_tbl`
    ADD CONSTRAINT `users_tbl_ibfk_1` FOREIGN KEY (`user_type_id`) REFERENCES `users_type` (`id`);
  COMMIT;
  
  /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
  /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
  /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
  