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

START TRANSACTION;



--
-- Database: `yamangl_schedule`
--

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

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

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

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

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

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

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

CREATE TABLE `courses` (
  `course_id` int(11) NOT NULL,
  `course_code` varchar(20) NOT NULL,
  `course_name` varchar(150) NOT NULL,
  `type_id` int(11) NOT NULL,
  `location_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

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

INSERT INTO `courses` (`course_id`, `course_code`, `course_name`, `type_id`, `location_id`) VALUES
(1, 'MOR 462', 'Management Consulting', 1, 1),
(2, 'ACAD 422', 'Cybersecurity, Privacy and Trust in Connective Healthcare', 1, 2),
(3, 'IDSN 521', 'Designing Brand Identity for Startups', 1, 3),
(4, 'ACAD 207', 'Narrative Technology and the Human Experience', 1, 4),
(5, 'ACAD 276', 'DEV 2', 1, 5),
(6, 'ACAD 475A', 'The Garage Experience', 1, 4);

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

--
-- Table structure for table `course_types`
--

CREATE TABLE `course_types` (
  `type_id` int(11) NOT NULL,
  `type_name` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `course_types`
--

INSERT INTO `course_types` (`type_id`, `type_name`) VALUES
(1, 'Lecture');

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

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

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

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

INSERT INTO `locations` (`location_id`, `location_name`) VALUES
(1, 'JFF 416'),
(2, 'IYH 111'),
(3, 'IYH 213'),
(4, 'IYH 110'),
(5, 'IYH 210');

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

--
-- Stand-in structure for view `schedule_view`
-- (See below for the actual view)
--
CREATE TABLE `schedule_view` (
`Date` date
,`Start Time` varchar(8)
,`End Time` varchar(8)
,`Location` varchar(100)
,`Class Type` varchar(50)
,`Course` varchar(172)
);

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

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

CREATE ALGORITHM=UNDEFINED DEFINER=`yamangl`@`localhost` SQL SECURITY DEFINER VIEW `schedule_view`  AS SELECT `cm`.`meeting_date` AS `Date`, time_format(`cm`.`start_time`,'%l:%i %p') AS `Start Time`, time_format(`cm`.`end_time`,'%l:%i %p') AS `End Time`, `l`.`location_name` AS `Location`, `ct`.`type_name` AS `Class Type`, concat(`c`.`course_code`,': ',`c`.`course_name`) AS `Course` FROM (((`class_meetings` `cm` join `courses` `c` on((`cm`.`course_id` = `c`.`course_id`))) join `locations` `l` on((`c`.`location_id` = `l`.`location_id`))) join `course_types` `ct` on((`c`.`type_id` = `ct`.`type_id`))) ORDER BY `cm`.`meeting_date` ASC, `cm`.`start_time` ASC ;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `class_meetings`
--
ALTER TABLE `class_meetings`
  ADD PRIMARY KEY (`meeting_id`),
  ADD KEY `course_id` (`course_id`);

--
-- Indexes for table `courses`
--
ALTER TABLE `courses`
  ADD PRIMARY KEY (`course_id`),
  ADD KEY `type_id` (`type_id`),
  ADD KEY `location_id` (`location_id`);

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

--
-- Indexes for table `locations`
--
ALTER TABLE `locations`
  ADD PRIMARY KEY (`location_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `class_meetings`
--
ALTER TABLE `class_meetings`
  MODIFY `meeting_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=41;

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

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

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `class_meetings`
--
ALTER TABLE `class_meetings`
  ADD CONSTRAINT `class_meetings_ibfk_1` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`);

--
-- Constraints for table `courses`
--
ALTER TABLE `courses`
  ADD CONSTRAINT `courses_ibfk_1` FOREIGN KEY (`type_id`) REFERENCES `course_types` (`type_id`),
  ADD CONSTRAINT `courses_ibfk_2` FOREIGN KEY (`location_id`) REFERENCES `locations` (`location_id`);
COMMIT;

