-- https://www.phpmyadmin.net/
--

START TRANSACTION;



--
-- Database: `huangac_schedule`
--

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

--
-- Table structure for table `classes`
--

CREATE TABLE `classes` (
  `class_id` int(11) NOT NULL,
  `class` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `classes`
--

INSERT INTO `classes` (`class_id`, `class`) VALUES
(1, 'The Practice of Design'),
(2, 'Dev II'),
(3, 'Applied Python'),
(4, 'Materials: Denim to Nanotubes'),
(5, 'Basics of Artificial Intelligence');

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

--
-- Table structure for table `rooms`
--

CREATE TABLE `rooms` (
  `room_id` int(11) NOT NULL,
  `room` varchar(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `rooms`
--

INSERT INTO `rooms` (`room_id`, `room`) VALUES
(1, 'IYH210/211'),
(2, 'IYH212/213'),
(3, 'KAP145'),
(4, 'GFS101');

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

--
-- Table structure for table `schedule`
--

CREATE TABLE `schedule` (
  `class_instance_id` int(11) NOT NULL,
  `date` date NOT NULL,
  `start_time` time NOT NULL,
  `end_time` time NOT NULL,
  `room_id` int(11) NOT NULL,
  `type_id` int(11) NOT NULL,
  `class_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `schedule`
--

INSERT INTO `schedule` (`class_instance_id`, `date`, `start_time`, `end_time`, `room_id`, `type_id`, `class_id`) VALUES
(1, '2023-08-21', '09:00:00', '11:50:00', 2, 1, 1),
(3, '2023-08-22', '12:00:00', '13:50:00', 3, 1, 5),
(4, '2023-08-22', '14:00:00', '16:50:00', 1, 1, 2),
(5, '2023-08-22', '18:00:00', '19:50:00', 2, 1, 4),
(6, '2023-08-23', '09:00:00', '11:50:00', 2, 1, 1),
(7, '2023-08-23', '18:00:00', '19:50:00', 4, 3, 3),
(8, '2023-08-24', '12:00:00', '13:50:00', 3, 1, 5),
(9, '2023-08-24', '14:00:00', '16:50:00', 2, 1, 2),
(10, '2023-08-24', '18:00:00', '19:50:00', 2, 1, 4),
(19, '2023-08-28', '09:00:00', '11:50:00', 2, 1, 1),
(20, '2023-08-29', '12:00:00', '13:50:00', 3, 1, 5),
(21, '2023-08-29', '14:00:00', '16:50:00', 1, 1, 2),
(22, '2023-08-29', '18:00:00', '19:50:00', 2, 1, 4),
(23, '2023-08-30', '09:00:00', '11:50:00', 2, 1, 1),
(24, '2023-08-30', '18:00:00', '19:50:00', 4, 3, 3),
(25, '2023-08-31', '12:00:00', '13:50:00', 3, 1, 5),
(26, '2023-08-31', '14:00:00', '16:50:00', 2, 1, 2),
(27, '2023-08-31', '18:00:00', '19:50:00', 2, 1, 4),
(28, '2023-09-04', '09:00:00', '11:50:00', 2, 1, 1),
(29, '2023-09-05', '12:00:00', '13:50:00', 3, 1, 5),
(30, '2023-09-05', '14:00:00', '16:50:00', 1, 1, 2),
(31, '2023-09-05', '18:00:00', '19:50:00', 2, 1, 4),
(32, '2023-09-06', '09:00:00', '11:50:00', 2, 1, 1),
(33, '2023-09-06', '18:00:00', '19:50:00', 4, 3, 3),
(34, '2023-09-07', '12:00:00', '13:50:00', 3, 1, 5),
(35, '2023-09-07', '14:00:00', '16:50:00', 2, 1, 2),
(36, '2023-09-07', '18:00:00', '19:50:00', 2, 1, 4),
(47, '2023-09-11', '09:00:00', '11:50:00', 2, 1, 1),
(48, '2023-09-12', '12:00:00', '13:50:00', 3, 1, 5),
(49, '2023-09-12', '14:00:00', '16:50:00', 1, 1, 2),
(50, '2023-09-12', '18:00:00', '19:50:00', 2, 1, 4),
(51, '2023-09-13', '09:00:00', '11:50:00', 2, 1, 1),
(52, '2023-09-13', '18:00:00', '19:50:00', 4, 3, 3),
(53, '2023-09-14', '12:00:00', '13:50:00', 3, 1, 5),
(54, '2023-09-14', '14:00:00', '16:50:00', 2, 1, 2),
(55, '2023-09-14', '18:00:00', '19:50:00', 2, 1, 4);

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

--
-- Stand-in structure for view `schedule_view`
-- (See below for the actual view)
--
CREATE TABLE `schedule_view` (
`date` date
,`start_time` time
,`end_time` time
,`room` varchar(11)
,`type` varchar(25)
,`class` varchar(50)
);

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

--
-- Table structure for table `types`
--

CREATE TABLE `types` (
  `type_id` int(11) NOT NULL,
  `type` varchar(25) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `types`
--

INSERT INTO `types` (`type_id`, `type`) VALUES
(1, 'Lecture'),
(2, 'Lab'),
(3, 'Lecture/Lab');

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

--
-- Structure for view `schedule_view`
--

CREATE ALGORITHM=UNDEFINED DEFINER=`huangac`@`%` SQL SECURITY DEFINER VIEW `schedule_view`  AS SELECT `schedule`.`date` AS `date`, `schedule`.`start_time` AS `start_time`, `schedule`.`end_time` AS `end_time`, `rooms`.`room` AS `room`, `types`.`type` AS `type`, `classes`.`class` AS `class` FROM (((`schedule` join `rooms`) join `types`) join `classes`) WHERE ((`schedule`.`room_id` = `rooms`.`room_id`) AND (`schedule`.`type_id` = `types`.`type_id`) AND (`schedule`.`class_id` = `classes`.`class_id`)) ;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `classes`
--
ALTER TABLE `classes`
  ADD PRIMARY KEY (`class_id`);

--
-- Indexes for table `rooms`
--
ALTER TABLE `rooms`
  ADD PRIMARY KEY (`room_id`);

--
-- Indexes for table `schedule`
--
ALTER TABLE `schedule`
  ADD PRIMARY KEY (`class_instance_id`),
  ADD KEY `class_id` (`class_id`),
  ADD KEY `room_id` (`room_id`),
  ADD KEY `type_id` (`type_id`);

--
-- Indexes for table `types`
--
ALTER TABLE `types`
  ADD PRIMARY KEY (`type_id`);

--
-- AUTO_INCREMENT for dumped tables
--

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

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

--
-- AUTO_INCREMENT for table `schedule`
--
ALTER TABLE `schedule`
  MODIFY `class_instance_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=56;

--
-- AUTO_INCREMENT for table `types`
--
ALTER TABLE `types`
  MODIFY `type_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `schedule`
--
ALTER TABLE `schedule`
  ADD CONSTRAINT `schedule_ibfk_1` FOREIGN KEY (`class_id`) REFERENCES `classes` (`class_id`),
  ADD CONSTRAINT `schedule_ibfk_2` FOREIGN KEY (`room_id`) REFERENCES `rooms` (`room_id`),
  ADD CONSTRAINT `schedule_ibfk_3` FOREIGN KEY (`type_id`) REFERENCES `types` (`type_id`);
COMMIT;

