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

START TRANSACTION;



--
-- Database: `hlhsiao_schedule`
--

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

--
-- Table structure for table `coursenames`
--

CREATE TABLE `coursenames` (
  `coursename_id` int(11) NOT NULL,
  `coursename` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `coursenames`
--

INSERT INTO `coursenames` (`coursename_id`, `coursename`) VALUES
(1, 'ACAD324'),
(2, 'ITP155'),
(3, 'HIST266'),
(4, 'ACAD276'),
(5, 'ACAD240'),
(6, 'ACAD324'),
(7, 'ITP155'),
(8, 'HIST266'),
(9, 'ACAD276'),
(10, 'ACAD240'),
(11, 'HIST266'),
(12, 'ACAD324'),
(13, 'ITP155'),
(14, 'HIST266'),
(15, 'ACAD276'),
(16, 'ACAD240'),
(17, 'ACAD324'),
(18, 'ITP155'),
(19, 'HIST266'),
(20, 'ACAD276'),
(21, 'ACAD240'),
(22, 'HIST266'),
(23, 'ACAD324'),
(24, 'ITP155'),
(25, 'HIST266'),
(26, 'ACAD276'),
(27, 'ACAD240'),
(28, 'ACAD324'),
(29, 'ITP155'),
(30, 'HIST266'),
(31, 'ACAD276'),
(32, 'ACAD240'),
(33, 'HIST266'),
(34, 'ACAD324'),
(35, 'ITP155'),
(36, 'HIST266'),
(37, 'ACAD276'),
(38, 'ACAD240'),
(39, 'ACAD324'),
(40, 'ITP155'),
(41, 'HIST266'),
(42, 'ACAD276'),
(43, 'ACAD240'),
(44, 'HIST266');

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

--
-- Table structure for table `mainschedule`
--

CREATE TABLE `mainschedule` (
  `date` date NOT NULL,
  `starttime` time NOT NULL,
  `endtime` time NOT NULL,
  `roomnumber_id` int(11) NOT NULL,
  `type_id` int(11) NOT NULL,
  `coursename_id` int(11) NOT NULL,
  `mainschedule_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `mainschedule`
--

INSERT INTO `mainschedule` (`date`, `starttime`, `endtime`, `roomnumber_id`, `type_id`, `coursename_id`, `mainschedule_id`) VALUES
('2023-09-11', '09:00:00', '11:50:00', 1, 1, 1, 1),
('2023-09-12', '11:00:00', '11:50:00', 2, 2, 2, 2),
('2023-09-12', '12:30:00', '01:50:00', 3, 3, 3, 3),
('2023-09-12', '02:00:00', '04:50:00', 4, 4, 4, 4),
('2023-09-12', '06:00:00', '07:50:00', 5, 5, 5, 5),
('2023-09-13', '09:00:00', '11:50:00', 6, 6, 6, 6),
('2023-09-14', '11:00:00', '11:50:00', 7, 7, 7, 7),
('2023-09-14', '12:30:00', '01:50:00', 8, 8, 8, 8),
('2023-09-14', '02:00:00', '04:50:00', 9, 9, 9, 9),
('2023-09-14', '06:00:00', '07:50:00', 10, 10, 10, 10),
('2023-09-15', '11:00:00', '11:50:00', 11, 11, 11, 11),
('2023-09-18', '09:00:00', '11:50:00', 12, 12, 12, 12),
('2023-09-19', '11:00:00', '11:50:00', 13, 13, 13, 13),
('2023-09-19', '12:30:00', '01:50:00', 14, 14, 14, 14),
('2023-09-19', '02:00:00', '04:50:00', 15, 15, 15, 15),
('2023-09-19', '06:00:00', '07:50:00', 16, 16, 16, 16),
('2023-09-20', '09:00:00', '11:50:00', 17, 17, 17, 17),
('2023-09-21', '11:00:00', '11:50:00', 18, 18, 18, 18),
('2023-09-21', '12:30:00', '01:50:00', 19, 19, 19, 19),
('2023-09-21', '02:00:00', '04:50:00', 20, 20, 20, 20),
('2023-09-21', '06:00:00', '07:50:00', 21, 21, 21, 21),
('2023-09-22', '11:00:00', '11:50:00', 22, 22, 22, 22),
('2023-09-25', '09:00:00', '11:50:00', 23, 23, 23, 23),
('2023-09-26', '11:00:00', '11:50:00', 24, 24, 24, 24),
('2023-09-26', '12:30:00', '01:50:00', 25, 25, 25, 25),
('2023-09-26', '02:00:00', '04:50:00', 26, 26, 26, 26),
('2023-09-26', '06:00:00', '07:50:00', 27, 27, 27, 27),
('2023-09-27', '09:00:00', '11:50:00', 28, 28, 28, 28),
('2023-09-28', '11:00:00', '11:50:00', 29, 29, 29, 29),
('2023-09-28', '12:30:00', '01:50:00', 30, 30, 30, 30),
('2023-09-28', '02:00:00', '04:50:00', 31, 31, 31, 31),
('2023-09-28', '06:00:00', '07:50:00', 32, 32, 32, 32),
('2023-09-29', '11:00:00', '11:50:00', 33, 33, 33, 33),
('2023-10-02', '09:00:00', '11:50:00', 34, 34, 34, 34),
('2023-10-03', '11:00:00', '11:50:00', 35, 35, 35, 35),
('2023-10-03', '12:30:00', '01:50:00', 36, 36, 36, 36),
('2023-10-03', '02:00:00', '04:50:00', 37, 37, 37, 37),
('2023-10-03', '06:00:00', '07:50:00', 38, 38, 38, 38),
('2023-10-04', '09:00:00', '11:50:00', 39, 39, 39, 39),
('2023-10-05', '11:00:00', '11:50:00', 40, 40, 40, 40),
('2023-10-05', '12:30:00', '01:50:00', 41, 41, 41, 41),
('2023-10-05', '02:00:00', '04:50:00', 42, 42, 42, 42),
('2023-10-05', '06:00:00', '07:50:00', 43, 43, 43, 43),
('2023-10-06', '11:00:00', '11:50:00', 44, 44, 44, 44);

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

--
-- Table structure for table `roomnumbers`
--

CREATE TABLE `roomnumbers` (
  `roomnumber_id` int(11) NOT NULL,
  `roomnumber` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `roomnumbers`
--

INSERT INTO `roomnumbers` (`roomnumber_id`, `roomnumber`) VALUES
(1, 'IYA212'),
(2, 'Zoom'),
(3, 'THH301'),
(4, 'IYH210'),
(5, 'IYA212'),
(6, 'IYA212'),
(7, 'Zoom'),
(8, 'THH301'),
(9, 'IYH210'),
(10, 'IYA212'),
(11, 'KAP165'),
(12, 'IYA212'),
(13, 'Zoom'),
(14, 'THH301'),
(15, 'IYH210'),
(16, 'IYA212'),
(17, 'IYA212'),
(18, 'Zoom'),
(19, 'THH301'),
(20, 'IYH210'),
(21, 'IYA212'),
(22, 'KAP165'),
(23, 'IYA212'),
(24, 'Zoom'),
(25, 'THH301'),
(26, 'IYH210'),
(27, 'IYA212'),
(28, 'IYA212'),
(29, 'Zoom'),
(30, 'THH301'),
(31, 'IYH210'),
(32, 'IYA212'),
(33, 'KAP165'),
(34, 'IYA212'),
(35, 'Zoom'),
(36, 'THH301'),
(37, 'IYH210'),
(38, 'IYA212'),
(39, 'IYA212'),
(40, 'Zoom'),
(41, 'THH301'),
(42, 'IYH210'),
(43, 'IYA212'),
(44, 'KAP165');

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

--
-- Stand-in structure for view `schedule_view`
-- (See below for the actual view)
--
CREATE TABLE `schedule_view` (
`date` date
,`starttime` varchar(8)
,`endtime` varchar(8)
,`coursename` varchar(30)
,`roomnumber` varchar(30)
,`type` varchar(11)
);

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

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

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

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

INSERT INTO `types` (`type_id`, `type`) VALUES
(1, 'LECTURE'),
(2, 'ONLINE'),
(3, 'LECTURE'),
(4, 'LECTURE'),
(5, 'LECTURE'),
(6, 'LECTURE'),
(7, 'ONLINE'),
(8, 'LECTURE'),
(9, 'LECTURE'),
(10, 'LECTURE'),
(11, 'DISCUSSION'),
(12, 'LECTURE'),
(13, 'ONLINE'),
(14, 'LECTURE'),
(15, 'LECTURE'),
(16, 'LECTURE'),
(17, 'LECTURE'),
(18, 'ONLINE'),
(19, 'LECTURE'),
(20, 'LECTURE'),
(21, 'LECTURE'),
(22, 'DISCUSSION'),
(23, 'LECTURE'),
(24, 'ONLINE'),
(25, 'LECTURE'),
(26, 'LECTURE'),
(27, 'LECTURE'),
(28, 'LECTURE'),
(29, 'ONLINE'),
(30, 'LECTURE'),
(31, 'LECTURE'),
(32, 'LECTURE'),
(33, 'DISCUSSION'),
(34, 'LECTURE'),
(35, 'ONLINE'),
(36, 'LECTURE'),
(37, 'LECTURE'),
(38, 'LECTURE'),
(39, 'LECTURE'),
(40, 'ONLINE'),
(41, 'LECTURE'),
(42, 'LECTURE'),
(43, 'LECTURE'),
(44, 'DISCUSSION');

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

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

CREATE ALGORITHM=UNDEFINED DEFINER=`hlhsiao`@`%` SQL SECURITY DEFINER VIEW `schedule_view`  AS SELECT `mainschedule`.`date` AS `date`, time_format(`mainschedule`.`starttime`,'%h:%i %p') AS `starttime`, time_format(`mainschedule`.`endtime`,'%h:%i %p') AS `endtime`, `coursenames`.`coursename` AS `coursename`, `roomnumbers`.`roomnumber` AS `roomnumber`, `types`.`type` AS `type` FROM (((`mainschedule` join `coursenames` on((`mainschedule`.`coursename_id` = `coursenames`.`coursename_id`))) join `roomnumbers` on((`mainschedule`.`roomnumber_id` = `roomnumbers`.`roomnumber_id`))) join `types` on((`mainschedule`.`type_id` = `types`.`type_id`))) WHERE ((`mainschedule`.`coursename_id` = `coursenames`.`coursename_id`) AND (`mainschedule`.`roomnumber_id` = `roomnumbers`.`roomnumber_id`) AND (`mainschedule`.`type_id` = `types`.`type_id`)) ORDER BY `mainschedule`.`mainschedule_id` ASC ;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `coursenames`
--
ALTER TABLE `coursenames`
  ADD PRIMARY KEY (`coursename_id`);

--
-- Indexes for table `mainschedule`
--
ALTER TABLE `mainschedule`
  ADD PRIMARY KEY (`mainschedule_id`),
  ADD KEY `coursename_id` (`coursename_id`),
  ADD KEY `type_id` (`type_id`),
  ADD KEY `roomnumber_id` (`roomnumber_id`);

--
-- Indexes for table `roomnumbers`
--
ALTER TABLE `roomnumbers`
  ADD PRIMARY KEY (`roomnumber_id`);

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

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `coursenames`
--
ALTER TABLE `coursenames`
  MODIFY `coursename_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=45;

--
-- AUTO_INCREMENT for table `mainschedule`
--
ALTER TABLE `mainschedule`
  MODIFY `mainschedule_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=45;

--
-- AUTO_INCREMENT for table `roomnumbers`
--
ALTER TABLE `roomnumbers`
  MODIFY `roomnumber_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=45;

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `mainschedule`
--
ALTER TABLE `mainschedule`
  ADD CONSTRAINT `mainschedule_ibfk_1` FOREIGN KEY (`coursename_id`) REFERENCES `coursenames` (`coursename_id`),
  ADD CONSTRAINT `mainschedule_ibfk_2` FOREIGN KEY (`type_id`) REFERENCES `types` (`type_id`),
  ADD CONSTRAINT `mainschedule_ibfk_3` FOREIGN KEY (`roomnumber_id`) REFERENCES `roomnumbers` (`roomnumber_id`);
COMMIT;

