-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Generation Time: Sep 25, 2025 at 03:08 PM
-- Server version: 5.7.44
-- PHP Version: 8.1.31

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: `dhreid_class_schedule`
--

-- --------------------------------------------------------

--
-- Table structure for table `class_meetings`
--

CREATE TABLE `class_meetings` (
  `meeting_id` bigint(20) NOT NULL,
  `meeting_date` date NOT NULL,
  `start_time` time NOT NULL,
  `end_time` time NOT NULL,
  `course_id` int(11) NOT NULL,
  `location_id` int(11) NOT NULL,
  `meeting_type_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `class_meetings`
--

INSERT INTO `class_meetings` (`meeting_id`, `meeting_date`, `start_time`, `end_time`, `course_id`, `location_id`, `meeting_type_id`) VALUES
(1, '2025-09-15', '10:00:00', '11:50:00', 1, 1, 1),
(2, '2025-09-16', '11:00:00', '12:50:00', 2, 2, 1),
(3, '2025-09-16', '14:00:00', '15:50:00', 3, 1, 1),
(4, '2025-09-16', '17:00:00', '19:50:00', 5, 4, 1),
(5, '2025-09-17', '10:00:00', '11:50:00', 1, 1, 1),
(6, '2025-09-17', '12:00:00', '12:50:00', 2, 2, 4),
(7, '2025-09-17', '14:00:00', '15:50:00', 4, 3, 1),
(8, '2025-09-18', '11:00:00', '12:50:00', 2, 2, 1),
(9, '2025-09-18', '14:00:00', '15:50:00', 3, 1, 1),
(10, '2025-09-22', '10:00:00', '11:50:00', 1, 1, 1),
(11, '2025-09-23', '11:00:00', '12:50:00', 2, 2, 1),
(12, '2025-09-23', '14:00:00', '15:50:00', 3, 1, 1),
(13, '2025-09-23', '17:00:00', '19:50:00', 5, 4, 1),
(14, '2025-09-24', '10:00:00', '11:50:00', 1, 1, 1),
(15, '2025-09-24', '12:00:00', '12:50:00', 2, 2, 4),
(16, '2025-09-24', '14:00:00', '15:50:00', 4, 3, 1),
(17, '2025-09-25', '11:00:00', '12:50:00', 2, 2, 1),
(18, '2025-09-25', '14:00:00', '15:50:00', 3, 1, 1),
(19, '2025-09-29', '10:00:00', '11:50:00', 1, 1, 1),
(20, '2025-09-30', '11:00:00', '12:50:00', 2, 2, 1),
(21, '2025-09-30', '14:00:00', '15:50:00', 3, 1, 1),
(22, '2025-09-30', '17:00:00', '19:50:00', 5, 4, 1),
(23, '2025-10-01', '10:00:00', '11:50:00', 1, 1, 1),
(24, '2025-10-01', '12:00:00', '12:50:00', 2, 2, 4),
(25, '2025-10-01', '14:00:00', '15:50:00', 4, 3, 1),
(26, '2025-10-02', '11:00:00', '12:50:00', 2, 2, 1),
(27, '2025-10-02', '14:00:00', '15:50:00', 3, 1, 1),
(28, '2025-10-06', '10:00:00', '11:50:00', 1, 1, 1),
(29, '2025-10-07', '11:00:00', '12:50:00', 2, 2, 1),
(30, '2025-10-07', '14:00:00', '15:50:00', 3, 1, 1),
(31, '2025-10-07', '17:00:00', '19:50:00', 5, 4, 1),
(32, '2025-10-08', '10:00:00', '11:50:00', 1, 1, 1),
(33, '2025-10-08', '12:00:00', '12:50:00', 2, 2, 4),
(34, '2025-10-08', '14:00:00', '15:50:00', 4, 3, 1),
(35, '2025-10-09', '11:00:00', '12:50:00', 2, 2, 1),
(36, '2025-10-09', '14:00:00', '15:50:00', 3, 1, 1);

-- --------------------------------------------------------

--
-- Table structure for table `courses`
--

CREATE TABLE `courses` (
  `course_id` int(11) NOT NULL,
  `course_code` varchar(32) NOT NULL,
  `course_title` varchar(128) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `courses`
--

INSERT INTO `courses` (`course_id`, `course_code`, `course_title`) VALUES
(3, 'ACAD 276', 'Dev 2'),
(1, 'ACAD 324', 'Practice of Design'),
(2, 'CSCI 100', 'Intro to CS'),
(5, 'IDSN 524', 'Product Design'),
(4, 'IDSN 599', 'Social Media');

-- --------------------------------------------------------

--
-- Table structure for table `locations`
--

CREATE TABLE `locations` (
  `location_id` int(11) NOT NULL,
  `building_code` varchar(32) NOT NULL,
  `room` varchar(32) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `locations`
--

INSERT INTO `locations` (`location_id`, `building_code`, `room`) VALUES
(4, 'IYH', '110'),
(1, 'IYH', '210'),
(3, 'IYH', '212'),
(2, 'ZHS', '352');

-- --------------------------------------------------------

--
-- Table structure for table `meeting_types`
--

CREATE TABLE `meeting_types` (
  `meeting_type_id` int(11) NOT NULL,
  `meeting_type` varchar(32) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `meeting_types`
--

INSERT INTO `meeting_types` (`meeting_type_id`, `meeting_type`) VALUES
(4, 'Discussion'),
(2, 'Lab'),
(1, 'Lecture'),
(3, 'Lecture/Lab');

-- --------------------------------------------------------

--
-- Stand-in structure for view `v_schedule_basic`
-- (See below for the actual view)
--
CREATE TABLE `v_schedule_basic` (
`meeting_id` bigint(20)
,`meeting_date` date
,`start_time` time
,`end_time` time
,`course_id` int(11)
,`location_id` int(11)
,`meeting_type_id` int(11)
,`course_code` varchar(32)
,`course_title` varchar(128)
,`building_code` varchar(32)
,`room` varchar(32)
,`meeting_type` varchar(32)
);

-- --------------------------------------------------------

--
-- Stand-in structure for view `v_schedule_readable`
-- (See below for the actual view)
--
CREATE TABLE `v_schedule_readable` (
`meeting_id` bigint(20)
,`meeting_date` date
,`start_time` varchar(10)
,`end_time` varchar(10)
,`location` varchar(65)
,`meeting_type` varchar(32)
,`course` varchar(162)
);

-- --------------------------------------------------------

--
-- Structure for view `v_schedule_basic`
--
DROP TABLE IF EXISTS `v_schedule_basic`;

CREATE ALGORITHM=UNDEFINED DEFINER=`dhreid`@`localhost` SQL SECURITY DEFINER VIEW `v_schedule_basic`  AS SELECT `cm`.`meeting_id` AS `meeting_id`, `cm`.`meeting_date` AS `meeting_date`, `cm`.`start_time` AS `start_time`, `cm`.`end_time` AS `end_time`, `cm`.`course_id` AS `course_id`, `cm`.`location_id` AS `location_id`, `cm`.`meeting_type_id` AS `meeting_type_id`, `c`.`course_code` AS `course_code`, `c`.`course_title` AS `course_title`, `l`.`building_code` AS `building_code`, `l`.`room` AS `room`, `mt`.`meeting_type` AS `meeting_type` FROM (((`class_meetings` `cm` join `courses` `c` on((`c`.`course_id` = `cm`.`course_id`))) join `locations` `l` on((`l`.`location_id` = `cm`.`location_id`))) join `meeting_types` `mt` on((`mt`.`meeting_type_id` = `cm`.`meeting_type_id`))) ;

-- --------------------------------------------------------

--
-- Structure for view `v_schedule_readable`
--
DROP TABLE IF EXISTS `v_schedule_readable`;

CREATE ALGORITHM=UNDEFINED DEFINER=`dhreid`@`localhost` SQL SECURITY DEFINER VIEW `v_schedule_readable`  AS SELECT `cm`.`meeting_id` AS `meeting_id`, `cm`.`meeting_date` AS `meeting_date`, time_format(`cm`.`start_time`,'%H:%i') AS `start_time`, time_format(`cm`.`end_time`,'%H:%i') AS `end_time`, concat(`l`.`building_code`,' ',`l`.`room`) AS `location`, `mt`.`meeting_type` AS `meeting_type`, concat(`c`.`course_code`,': ',`c`.`course_title`) AS `course` FROM (((`class_meetings` `cm` join `courses` `c` on((`c`.`course_id` = `cm`.`course_id`))) join `locations` `l` on((`l`.`location_id` = `cm`.`location_id`))) join `meeting_types` `mt` on((`mt`.`meeting_type_id` = `cm`.`meeting_type_id`))) ORDER BY `cm`.`meeting_date` ASC, `cm`.`start_time` ASC, concat(`c`.`course_code`,': ',`c`.`course_title`) ASC ;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `class_meetings`
--
ALTER TABLE `class_meetings`
  ADD PRIMARY KEY (`meeting_id`),
  ADD KEY `fk_meeting_location` (`location_id`),
  ADD KEY `fk_meeting_type` (`meeting_type_id`),
  ADD KEY `idx_meeting_date` (`meeting_date`),
  ADD KEY `idx_course_date` (`course_id`,`meeting_date`);

--
-- Indexes for table `courses`
--
ALTER TABLE `courses`
  ADD PRIMARY KEY (`course_id`),
  ADD UNIQUE KEY `uq_course_code_title` (`course_code`,`course_title`);

--
-- Indexes for table `locations`
--
ALTER TABLE `locations`
  ADD PRIMARY KEY (`location_id`),
  ADD UNIQUE KEY `uq_building_room` (`building_code`,`room`);

--
-- Indexes for table `meeting_types`
--
ALTER TABLE `meeting_types`
  ADD PRIMARY KEY (`meeting_type_id`),
  ADD UNIQUE KEY `meeting_type` (`meeting_type`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `class_meetings`
--
ALTER TABLE `class_meetings`
  MODIFY `meeting_id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=37;

--
-- AUTO_INCREMENT for table `courses`
--
ALTER TABLE `courses`
  MODIFY `course_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `locations`
--
ALTER TABLE `locations`
  MODIFY `location_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `meeting_types`
--
ALTER TABLE `meeting_types`
  MODIFY `meeting_type_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `class_meetings`
--
ALTER TABLE `class_meetings`
  ADD CONSTRAINT `fk_meeting_course` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_meeting_location` FOREIGN KEY (`location_id`) REFERENCES `locations` (`location_id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_meeting_type` FOREIGN KEY (`meeting_type_id`) REFERENCES `meeting_types` (`meeting_type_id`) ON UPDATE CASCADE;
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 */;
