DB Structure
DB Structure
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Feb 23, 2024 at 01:08 PM
-- Server version: 10.4.32-MariaDB
-- PHP Version: 8.2.12
--
-- Database: `test_portal`
--
-- --------------------------------------------------------
--
-- Table structure for table `assignment_status`
--
--
-- Dumping data for table `assignment_status`
--
-- --------------------------------------------------------
--
-- Table structure for table `course`
--
--
-- Dumping data for table `course`
--
-- --------------------------------------------------------
--
-- Table structure for table `exam`
--
--
-- Dumping data for table `exam`
--
-- --------------------------------------------------------
--
-- Table structure for table `exam_assignment`
--
--
-- Dumping data for table `exam_assignment`
--
-- --------------------------------------------------------
--
-- Table structure for table `exam_status`
--
--
-- Dumping data for table `exam_status`
--
-- --------------------------------------------------------
--
-- Table structure for table `exam_type`
--
--
-- Dumping data for table `exam_type`
--
--
-- Table structure for table `fill_in_question`
--
--
-- Dumping data for table `fill_in_question`
--
-- --------------------------------------------------------
--
-- Table structure for table `fill_in_response`
--
--
-- Dumping data for table `fill_in_response`
--
-- --------------------------------------------------------
--
-- Table structure for table `level`
--
--
-- Dumping data for table `level`
--
INSERT INTO `level` (`level_id`, `value`) VALUES
(1, '100'),
(2, '200'),
(3, '300'),
(4, '400'),
(5, '500');
-- --------------------------------------------------------
--
-- Table structure for table `multi_choice_question`
--
--
-- Dumping data for table `multi_choice_question`
--
-- --------------------------------------------------------
--
-- Table structure for table `multi_choice_response`
--
--
-- Dumping data for table `multi_choice_response`
--
-- --------------------------------------------------------
--
-- Table structure for table `multi_img_choice_question`
--
--
-- Dumping data for table `multi_img_choice_question`
--
-- --------------------------------------------------------
--
-- Table structure for table `notification`
--
--
-- Dumping data for table `notification`
--
-- --------------------------------------------------------
--
-- Table structure for table `notification_status`
--
--
-- Dumping data for table `notification_status`
--
-- --------------------------------------------------------
--
-- Table structure for table `notification_type`
--
--
-- Dumping data for table `notification_type`
--
-- --------------------------------------------------------
--
-- Table structure for table `theory_question`
--
-- --------------------------------------------------------
--
-- Table structure for table `theory_response`
--
CREATE TABLE `theory_response` (
`exam_id` int(11) NOT NULL,
`question_no` int(11) NOT NULL,
`assignee_id` varchar(16) NOT NULL,
`response` varchar(256) DEFAULT NULL,
`score` float DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
-- --------------------------------------------------------
--
-- Table structure for table `three_multi_choice_question`
--
--
-- Dumping data for table `three_multi_choice_question`
--
-- --------------------------------------------------------
--
-- Table structure for table `three_multi_choice_response`
--
--
-- Dumping data for table `three_multi_choice_response`
--
--
-- Table structure for table `user`
--
--
-- Dumping data for table `user`
--
--
-- Indexes for dumped tables
--
--
-- Indexes for table `assignment_status`
--
ALTER TABLE `assignment_status`
ADD PRIMARY KEY (`status_id`),
ADD UNIQUE KEY `assignment_status_value_UNIQUE` (`value`);
--
-- Indexes for table `course`
--
ALTER TABLE `course`
ADD PRIMARY KEY (`course_code`),
ADD UNIQUE KEY `course_name_UNIQUE` (`course_name`);
--
-- Indexes for table `exam`
--
ALTER TABLE `exam`
ADD PRIMARY KEY (`exam_id`),
ADD KEY `exam_course_code_idx` (`course_code`),
ADD KEY `exam_type_id_idx` (`type_id`),
ADD KEY `exam_instructor_id_idx` (`instructor_id`),
ADD KEY `exam_status_id` (`status_id`);
--
-- Indexes for table `exam_assignment`
--
ALTER TABLE `exam_assignment`
ADD PRIMARY KEY (`exam_id`,`assignee_id`),
ADD KEY `assignment_assignee_id_idx` (`assignee_id`),
ADD KEY `assignment_status_id_idx` (`status_id`);
--
-- Indexes for table `exam_status`
--
ALTER TABLE `exam_status`
ADD PRIMARY KEY (`status_id`),
ADD UNIQUE KEY `exam_status_value_UNIQUE` (`value`);
--
-- Indexes for table `exam_type`
--
ALTER TABLE `exam_type`
ADD PRIMARY KEY (`type_id`),
ADD UNIQUE KEY `exam_type_value_UNIQUE` (`value`);
--
-- Indexes for table `fill_in_question`
--
ALTER TABLE `fill_in_question`
ADD PRIMARY KEY (`exam_id`,`question_no`);
--
-- Indexes for table `fill_in_response`
--
ALTER TABLE `fill_in_response`
ADD PRIMARY KEY (`exam_id`,`question_no`,`assignee_id`),
ADD KEY `fill_in_response_assignee_id_idx` (`assignee_id`);
--
-- Indexes for table `level`
--
ALTER TABLE `level`
ADD PRIMARY KEY (`level_id`),
ADD UNIQUE KEY `level_value_UNIQUE` (`value`);
--
-- Indexes for table `multi_choice_question`
--
ALTER TABLE `multi_choice_question`
ADD PRIMARY KEY (`exam_id`,`question_no`);
--
-- Indexes for table `multi_choice_response`
--
ALTER TABLE `multi_choice_response`
ADD PRIMARY KEY (`exam_id`,`question_no`,`assignee_id`),
ADD KEY `multi_choice_response_assignee_id_idx` (`assignee_id`);
--
-- Indexes for table `multi_img_choice_question`
--
ALTER TABLE `multi_img_choice_question`
ADD PRIMARY KEY (`exam_id`,`question_no`);
--
-- Indexes for table `notification`
--
ALTER TABLE `notification`
ADD PRIMARY KEY (`notification_id`),
ADD KEY `notification_status_id` (`status_id`),
ADD KEY `notification_sender_id` (`sender_id`),
ADD KEY `notification_type_id` (`type_id`),
ADD KEY `notification_recipient_id` (`recipient_id`),
ADD KEY `exam_id` (`exam_id`);
--
-- Indexes for table `notification_status`
--
ALTER TABLE `notification_status`
ADD PRIMARY KEY (`status_id`);
--
-- Indexes for table `notification_type`
--
ALTER TABLE `notification_type`
ADD PRIMARY KEY (`type_id`),
ADD UNIQUE KEY `msg_template_UNIQUE` (`msg_template`);
--
-- Indexes for table `theory_question`
--
ALTER TABLE `theory_question`
ADD PRIMARY KEY (`exam_id`,`question_no`);
--
-- Indexes for table `theory_response`
--
ALTER TABLE `theory_response`
ADD PRIMARY KEY (`exam_id`,`question_no`,`assignee_id`),
ADD KEY `theory_response_assignee_id_idx` (`assignee_id`);
--
-- Indexes for table `three_multi_choice_question`
--
ALTER TABLE `three_multi_choice_question`
ADD PRIMARY KEY (`exam_id`,`question_no`);
--
-- Indexes for table `three_multi_choice_response`
--
ALTER TABLE `three_multi_choice_response`
ADD PRIMARY KEY (`exam_id`,`question_no`,`assignee_id`);
--
-- Indexes for table `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`user_id`),
ADD UNIQUE KEY `email_UNIQUE` (`email`) USING BTREE,
ADD KEY `user_level_id_idx` (`level_id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `assignment_status`
--
ALTER TABLE `assignment_status`
MODIFY `status_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `exam`
--
ALTER TABLE `exam`
MODIFY `exam_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;
--
-- AUTO_INCREMENT for table `exam_status`
--
ALTER TABLE `exam_status`
MODIFY `status_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `exam_type`
--
ALTER TABLE `exam_type`
MODIFY `type_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `level`
--
ALTER TABLE `level`
MODIFY `level_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `notification`
--
ALTER TABLE `notification`
MODIFY `notification_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
AUTO_INCREMENT=32;
--
-- AUTO_INCREMENT for table `notification_status`
--
ALTER TABLE `notification_status`
MODIFY `status_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `notification_type`
--
ALTER TABLE `notification_type`
MODIFY `type_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `exam`
--
ALTER TABLE `exam`
ADD CONSTRAINT `exam_course_code` FOREIGN KEY (`course_code`) REFERENCES `course`
(`course_code`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `exam_instructor_id` FOREIGN KEY (`instructor_id`) REFERENCES
`user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `exam_status_id` FOREIGN KEY (`status_id`) REFERENCES
`exam_status` (`status_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `exam_type_id` FOREIGN KEY (`type_id`) REFERENCES `exam_type`
(`type_id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `exam_assignment`
--
ALTER TABLE `exam_assignment`
ADD CONSTRAINT `assignment_assignee_id` FOREIGN KEY (`assignee_id`) REFERENCES
`user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `assignment_exam_id` FOREIGN KEY (`exam_id`) REFERENCES `exam`
(`exam_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `assignment_status_id` FOREIGN KEY (`status_id`) REFERENCES
`assignment_status` (`status_id`) ON UPDATE CASCADE;
--
-- Constraints for table `fill_in_question`
--
ALTER TABLE `fill_in_question`
ADD CONSTRAINT `fill_in_question_exam_id` FOREIGN KEY (`exam_id`) REFERENCES
`exam` (`exam_id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `fill_in_response`
--
ALTER TABLE `fill_in_response`
ADD CONSTRAINT `fill_in_response_assignee_id` FOREIGN KEY (`assignee_id`)
REFERENCES `user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `fill_in_response_id` FOREIGN KEY (`exam_id`,`question_no`)
REFERENCES `fill_in_question` (`exam_id`, `question_no`) ON DELETE CASCADE;
--
-- Constraints for table `multi_choice_question`
--
ALTER TABLE `multi_choice_question`
ADD CONSTRAINT `multi_choice_question_exam_id` FOREIGN KEY (`exam_id`) REFERENCES
`exam` (`exam_id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `multi_choice_response`
--
ALTER TABLE `multi_choice_response`
ADD CONSTRAINT `multi_choice_response_assignee_id` FOREIGN KEY (`assignee_id`)
REFERENCES `user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `multi_choice_response_id` FOREIGN KEY (`exam_id`,`question_no`)
REFERENCES `multi_choice_question` (`exam_id`, `question_no`) ON DELETE CASCADE;
--
-- Constraints for table `notification`
--
ALTER TABLE `notification`
ADD CONSTRAINT `notification_ibfk_1` FOREIGN KEY (`exam_id`) REFERENCES `exam`
(`exam_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `notification_recipient_id` FOREIGN KEY (`recipient_id`)
REFERENCES `user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `notification_sender_id` FOREIGN KEY (`sender_id`) REFERENCES
`user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `notification_status_id` FOREIGN KEY (`status_id`) REFERENCES
`notification_status` (`status_id`),
ADD CONSTRAINT `notification_type_id` FOREIGN KEY (`type_id`) REFERENCES
`notification_type` (`type_id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `theory_question`
--
ALTER TABLE `theory_question`
ADD CONSTRAINT `theory_question_exam_id` FOREIGN KEY (`exam_id`) REFERENCES
`exam` (`exam_id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `theory_response`
--
ALTER TABLE `theory_response`
ADD CONSTRAINT `theory_response_assignee_id` FOREIGN KEY (`assignee_id`)
REFERENCES `user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `theory_response_id` FOREIGN KEY (`exam_id`,`question_no`)
REFERENCES `theory_question` (`exam_id`, `question_no`) ON DELETE CASCADE;
--
-- Constraints for table `three_multi_choice_question`
--
ALTER TABLE `three_multi_choice_question`
ADD CONSTRAINT `three_multi_choice_question_exam_id` FOREIGN KEY (`exam_id`)
REFERENCES `exam` (`exam_id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `three_multi_choice_response`
--
ALTER TABLE `three_multi_choice_response`
ADD CONSTRAINT `three_multi_choice_response_id` FOREIGN KEY
(`exam_id`,`question_no`) REFERENCES `three_multi_choice_question` (`exam_id`,
`question_no`) ON DELETE CASCADE;
--
-- Constraints for table `user`
--
ALTER TABLE `user`
ADD CONSTRAINT `user_level_id` FOREIGN KEY (`level_id`) REFERENCES `level`
(`level_id`) ON DELETE CASCADE ON UPDATE SET NULL;
COMMIT;