-- PhpMyAdmin SQL Dump
-- PhpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: May 25, 2025 at 07:01 AM
-- Server version: 10.4.32-MariaDB
-- PHP Version: 8.0.30
--
-- Database: `onlineexamportal`
--
-- --------------------------------------------------------
--
-- Table structure for table `examiners`
--
--
-- Dumping data for table `examiners`
--
-- --------------------------------------------------------
--
-- Table structure for table `exams`
--
--
-- Dumping data for table `exams`
--
-- --------------------------------------------------------
--
-- Table structure for table `exam_attempts`
--
--
-- Dumping data for table `exam_attempts`
--
--
-- Table structure for table `exam_retake_requests`
--
--
-- Dumping data for table `exam_retake_requests`
--
--
-- Table structure for table `questions`
--
CREATE TABLE `questions` (
`question_id` int(11) NOT NULL,
`exam_id` int(11) NOT NULL,
`question_text` text NOT NULL,
`option_a` varchar(255) NOT NULL,
`option_b` varchar(255) NOT NULL,
`option_c` varchar(255) NOT NULL,
`option_d` varchar(255) NOT NULL,
`correct_answer` char(1) NOT NULL,
`marks` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Dumping data for table `questions`
--
-- --------------------------------------------------------
--
-- Table structure for table `results`
--
--
-- Dumping data for table `results`
--
-- --------------------------------------------------------
--
-- Table structure for table `students`
--
--
-- Dumping data for table `students`
--
-- --------------------------------------------------------
--
-- Table structure for table `student_exam_access`
--
--
--
-- Indexes for dumped tables
--
--
-- Indexes for table `examiners`
--
ALTER TABLE `examiners`
ADD PRIMARY KEY (`E_id`),
ADD UNIQUE KEY `username` (`username`);
--
-- Indexes for table `exams`
--
ALTER TABLE `exams`
ADD PRIMARY KEY (`exam_id`);
--
-- Indexes for table `exam_attempts`
--
ALTER TABLE `exam_attempts`
ADD PRIMARY KEY (`ex_id`),
ADD KEY `fk_exam_attempts_student` (`student_id`),
ADD KEY `fk_exam_attempts_exam` (`exam_id`);
--
-- Indexes for table `exam_retake_requests`
--
ALTER TABLE `exam_retake_requests`
ADD PRIMARY KEY (`request_id`),
ADD UNIQUE KEY `student_id` (`student_id`,`exam_id`),
ADD KEY `exam_id` (`exam_id`);
--
-- Indexes for table `questions`
--
ALTER TABLE `questions`
ADD PRIMARY KEY (`question_id`),
ADD KEY `exam_id` (`exam_id`);
--
-- Indexes for table `results`
--
ALTER TABLE `results`
ADD PRIMARY KEY (`r_id`),
ADD UNIQUE KEY `attempt_id` (`attempt_id`,`question_id`),
ADD KEY `exam_id` (`exam_id`),
ADD KEY `question_id` (`question_id`);
--
-- Indexes for table `students`
--
ALTER TABLE `students`
ADD PRIMARY KEY (`student_id`),
ADD UNIQUE KEY `username` (`username`);
--
-- Indexes for table `student_exam_access`
--
ALTER TABLE `student_exam_access`
ADD PRIMARY KEY (`student_id`,`exam_id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `examiners`
--
ALTER TABLE `examiners`
MODIFY `E_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `exams`
--
ALTER TABLE `exams`
MODIFY `exam_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `exam_attempts`
--
ALTER TABLE `exam_attempts`
MODIFY `ex_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=36;
--
-- AUTO_INCREMENT for table `exam_retake_requests`
--
ALTER TABLE `exam_retake_requests`
MODIFY `request_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;
--
-- AUTO_INCREMENT for table `questions`
--
ALTER TABLE `questions`
MODIFY `question_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `results`
--
ALTER TABLE `results`
MODIFY `r_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=42;
--
-- AUTO_INCREMENT for table `students`
--
ALTER TABLE `students`
MODIFY `student_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `exam_attempts`
--
ALTER TABLE `exam_attempts`
ADD CONSTRAINT `fk_exam_attempts_exam` FOREIGN KEY (`exam_id`) REFERENCES `exams`
(`exam_id`) ON DELETE CASCADE,
ADD CONSTRAINT `fk_exam_attempts_student` FOREIGN KEY (`student_id`) REFERENCES
`students` (`student_id`) ON DELETE CASCADE;
--
-- Constraints for table `exam_retake_requests`
--
ALTER TABLE `exam_retake_requests`
ADD CONSTRAINT `exam_retake_requests_ibfk_1` FOREIGN KEY (`student_id`)
REFERENCES `students` (`student_id`),
ADD CONSTRAINT `exam_retake_requests_ibfk_2` FOREIGN KEY (`exam_id`) REFERENCES
`exams` (`exam_id`);
--
-- Constraints for table `questions`
--
ALTER TABLE `questions`
ADD CONSTRAINT `questions_ibfk_1` FOREIGN KEY (`exam_id`) REFERENCES `exams`
(`exam_id`) ON DELETE CASCADE;
--
-- Constraints for table `results`
--
ALTER TABLE `results`
ADD CONSTRAINT `fk_results_exam_attempts` FOREIGN KEY (`attempt_id`) REFERENCES
`exam_attempts` (`ex_id`) ON DELETE CASCADE,
ADD CONSTRAINT `results_ibfk_1` FOREIGN KEY (`exam_id`) REFERENCES `exams`
(`exam_id`),
ADD CONSTRAINT `results_ibfk_2` FOREIGN KEY (`question_id`) REFERENCES
`questions` (`question_id`);
COMMIT;