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

START TRANSACTION;



--
-- Database: `meiqili_schedule`
--

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

--
-- Table structure for table `class_locations`
--

CREATE TABLE `class_locations` (
  `class_location_id` int(11) NOT NULL,
  `class_location` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `class_locations`
--

INSERT INTO `class_locations` (`class_location_id`, `class_location`) VALUES
(1, 'IYH 212'),
(2, 'SGM 601'),
(3, 'IYH 210'),
(4, 'IYH 212'),
(5, 'DMC 102');

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

--
-- Table structure for table `class_main_table`
--

CREATE TABLE `class_main_table` (
  `class_id` int(25) NOT NULL,
  `date` date NOT NULL,
  `starting_time` time NOT NULL,
  `end_time` time NOT NULL,
  `class_type_id` int(11) NOT NULL,
  `location_id` int(11) NOT NULL,
  `class_name_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `class_main_table`
--

INSERT INTO `class_main_table` (`class_id`, `date`, `starting_time`, `end_time`, `class_type_id`, `location_id`, `class_name_id`) VALUES
(1, '2023-09-11', '09:00:00', '11:50:00', 1, 1, 1),
(2, '2023-09-12', '12:30:00', '13:50:00', 1, 2, 2),
(3, '2023-09-12', '14:00:00', '16:50:00', 1, 3, 3),
(4, '2023-09-12', '18:00:00', '19:50:00', 1, 4, 4),
(5, '2023-09-13', '18:00:00', '20:50:00', 1, 5, 5),
(14, '2023-09-13', '09:00:00', '11:50:00', 1, 1, 1),
(15, '2023-09-14', '12:30:00', '13:50:00', 1, 2, 2),
(16, '2023-09-14', '14:00:00', '16:50:00', 1, 3, 3),
(17, '2023-09-14', '18:00:00', '19:50:00', 1, 4, 4),
(18, '2023-09-18', '09:00:00', '11:50:00', 1, 1, 1),
(19, '2023-09-19', '12:30:00', '13:50:00', 1, 2, 2),
(20, '2023-09-19', '14:00:00', '16:50:00', 1, 3, 3),
(21, '2023-09-19', '18:00:00', '19:50:00', 1, 4, 4),
(22, '2023-09-20', '18:00:00', '20:50:00', 1, 5, 5),
(23, '2023-09-20', '09:00:00', '11:50:00', 1, 1, 1),
(24, '2023-09-21', '12:30:00', '13:50:00', 1, 2, 2),
(25, '2023-09-21', '14:00:00', '16:50:00', 1, 3, 3),
(26, '2023-09-21', '18:00:00', '19:50:00', 1, 4, 4),
(27, '2023-09-25', '09:00:00', '11:50:00', 1, 1, 1),
(28, '2023-09-26', '12:30:00', '13:50:00', 1, 2, 2),
(29, '2023-09-26', '14:00:00', '16:50:00', 1, 3, 3),
(30, '2023-09-26', '18:00:00', '19:50:00', 1, 4, 4),
(31, '2023-09-27', '18:00:00', '20:50:00', 1, 5, 5),
(32, '2023-09-27', '09:00:00', '11:50:00', 1, 1, 1),
(33, '2023-09-28', '12:30:00', '13:50:00', 1, 2, 2),
(34, '2023-09-28', '14:00:00', '16:50:00', 1, 3, 3),
(35, '2023-09-28', '18:00:00', '19:50:00', 1, 4, 4),
(41, '2023-10-02', '09:00:00', '11:50:00', 1, 1, 1),
(42, '2023-10-03', '12:30:00', '13:50:00', 1, 2, 2),
(43, '2023-10-03', '14:00:00', '16:50:00', 1, 3, 3),
(44, '2023-10-03', '18:00:00', '19:50:00', 1, 4, 4),
(45, '2023-10-04', '18:00:00', '20:50:00', 1, 5, 5),
(46, '2023-10-04', '09:00:00', '11:50:00', 1, 1, 1),
(47, '2023-10-05', '12:30:00', '13:50:00', 1, 2, 2),
(48, '2023-10-05', '14:00:00', '16:50:00', 1, 3, 3),
(49, '2023-10-05', '18:00:00', '19:50:00', 1, 4, 4),
(50, '2023-10-09', '09:00:00', '11:50:00', 1, 1, 1),
(51, '2023-10-10', '12:30:00', '13:50:00', 1, 2, 2),
(52, '2023-10-10', '14:00:00', '16:50:00', 1, 3, 3),
(53, '2023-10-10', '18:00:00', '19:50:00', 1, 4, 4),
(54, '2023-10-11', '18:00:00', '20:50:00', 1, 5, 5),
(55, '2023-10-11', '09:00:00', '11:50:00', 1, 1, 1),
(56, '2023-10-12', '12:30:00', '13:50:00', 1, 2, 2),
(57, '2023-10-12', '14:00:00', '16:50:00', 1, 3, 3),
(58, '2023-10-12', '18:00:00', '19:50:00', 1, 4, 4),
(59, '2023-10-16', '09:00:00', '11:50:00', 1, 1, 1),
(60, '2023-10-17', '12:30:00', '13:50:00', 1, 2, 2),
(61, '2023-10-17', '14:00:00', '16:50:00', 1, 3, 3),
(62, '2023-10-17', '18:00:00', '19:50:00', 1, 4, 4),
(63, '2023-10-18', '18:00:00', '20:50:00', 1, 5, 5),
(64, '2023-10-18', '09:00:00', '11:50:00', 1, 1, 1),
(65, '2023-10-19', '12:30:00', '13:50:00', 1, 2, 2),
(66, '2023-10-19', '14:00:00', '16:50:00', 1, 3, 3),
(67, '2023-10-19', '18:00:00', '19:50:00', 1, 4, 4);

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

--
-- Table structure for table `class_names`
--

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

--
-- Dumping data for table `class_names`
--

INSERT INTO `class_names` (`class_id`, `class_name`) VALUES
(1, 'ACAD 324: The Practice of Design'),
(2, 'HP 370: Introduction to Epidemiology'),
(3, 'ACAD 276: Dev II'),
(4, 'ACAD 240: Materials'),
(5, 'NAUT 301A: Seamanship and Navigation');

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

--
-- Table structure for table `class_types`
--

CREATE TABLE `class_types` (
  `class_type_id` int(11) NOT NULL,
  `class_type` varchar(25) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `class_types`
--

INSERT INTO `class_types` (`class_type_id`, `class_type`) VALUES
(1, 'lecture'),
(2, 'lab');

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

--
-- Stand-in structure for view `meiqi_schedule_view`
-- (See below for the actual view)
--
CREATE TABLE `meiqi_schedule_view` (
`class_location` varchar(20)
,`class_name` varchar(50)
,`class_type` varchar(25)
,`starting_time` time
,`end_time` time
,`date` date
);

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

--
-- Structure for view `meiqi_schedule_view`
--

CREATE ALGORITHM=UNDEFINED DEFINER=`meiqili`@`localhost` SQL SECURITY DEFINER VIEW `meiqi_schedule_view`  AS SELECT `class_locations`.`class_location` AS `class_location`, `class_names`.`class_name` AS `class_name`, `class_types`.`class_type` AS `class_type`, `class_main_table`.`starting_time` AS `starting_time`, `class_main_table`.`end_time` AS `end_time`, `class_main_table`.`date` AS `date` FROM (((`class_locations` join `class_main_table`) join `class_names`) join `class_types`) WHERE ((`class_main_table`.`location_id` = `class_locations`.`class_location_id`) AND (`class_main_table`.`class_name_id` = `class_names`.`class_id`) AND (`class_main_table`.`class_type_id` = `class_types`.`class_type_id`)) ;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `class_locations`
--
ALTER TABLE `class_locations`
  ADD PRIMARY KEY (`class_location_id`);

--
-- Indexes for table `class_main_table`
--
ALTER TABLE `class_main_table`
  ADD PRIMARY KEY (`class_id`),
  ADD KEY `class_id_relationship_1` (`class_name_id`),
  ADD KEY `class_location_relationship` (`location_id`),
  ADD KEY `class_type_relationship` (`class_type_id`);

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

--
-- Indexes for table `class_types`
--
ALTER TABLE `class_types`
  ADD PRIMARY KEY (`class_type_id`);

--
-- AUTO_INCREMENT for dumped tables
--

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

--
-- AUTO_INCREMENT for table `class_main_table`
--
ALTER TABLE `class_main_table`
  MODIFY `class_id` int(25) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=68;

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

--
-- AUTO_INCREMENT for table `class_types`
--
ALTER TABLE `class_types`
  MODIFY `class_type_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `class_main_table`
--
ALTER TABLE `class_main_table`
  ADD CONSTRAINT `class_id_relationship_1` FOREIGN KEY (`class_name_id`) REFERENCES `class_names` (`class_id`),
  ADD CONSTRAINT `class_location_relationship` FOREIGN KEY (`location_id`) REFERENCES `class_locations` (`class_location_id`),
  ADD CONSTRAINT `class_type_relationship` FOREIGN KEY (`class_type_id`) REFERENCES `class_types` (`class_type_id`);

--
-- Constraints for table `class_names`
--
ALTER TABLE `class_names`
  ADD CONSTRAINT `class_names_ibfk_1` FOREIGN KEY (`class_id`) REFERENCES `class_main_table` (`class_id`);
COMMIT;

