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

START TRANSACTION;



--
-- Database: `roryan_schedule`
--

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

--
-- Table structure for table `class`
--

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

--
-- Dumping data for table `class`
--

INSERT INTO `class` (`class_id`, `class`) VALUES
(1, '[ACAD 240] Materials: Denim to Nanotubes'),
(2, '[ACAD 276] Dev II'),
(3, '[ACAD 324] The Practice of Design: Ideation to Innovation'),
(4, '[AMST 301] America, the Frontier, and the New West'),
(5, '[ITP 215] Introduction to 3D Modeling, Animation, and Visual Effects');

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

--
-- Table structure for table `location`
--

CREATE TABLE `location` (
  `location_id` int(11) NOT NULL,
  `location` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `location`
--

INSERT INTO `location` (`location_id`, `location`) VALUES
(1, 'IYH212/213'),
(2, 'IYH210/211'),
(3, 'SGM101'),
(4, 'DMC160'),
(5, 'KAP107');

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

--
-- Table structure for table `meeting`
--

CREATE TABLE `meeting` (
  `meeting_id` int(11) NOT NULL,
  `date` date NOT NULL,
  `time_start` time NOT NULL,
  `time_end` time NOT NULL,
  `class_id` int(11) NOT NULL,
  `location_id` int(11) NOT NULL,
  `type_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `meeting`
--

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

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

--
-- Table structure for table `type`
--

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

--
-- Dumping data for table `type`
--

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

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

--
-- Stand-in structure for view `vw_schedule_meeting`
-- (See below for the actual view)
--
CREATE TABLE `vw_schedule_meeting` (
`date` date
,`time_start` varchar(8)
,`time_end` varchar(8)
,`class` varchar(255)
,`location` varchar(255)
,`type` varchar(255)
);

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

--
-- Structure for view `vw_schedule_meeting`
--

CREATE ALGORITHM=UNDEFINED DEFINER=`roryan`@`localhost` SQL SECURITY DEFINER VIEW `vw_schedule_meeting`  AS SELECT `m`.`date` AS `date`, date_format(`m`.`time_start`,'%h:%i %p') AS `time_start`, date_format(`m`.`time_end`,'%h:%i %p') AS `time_end`, `c`.`class` AS `class`, `l`.`location` AS `location`, `t`.`type` AS `type` FROM (((`meeting` `m` left join `class` `c` on((`c`.`class_id` = `m`.`class_id`))) left join `location` `l` on((`l`.`location_id` = `m`.`location_id`))) left join `type` `t` on((`t`.`type_id` = `m`.`type_id`))) ORDER BY `m`.`meeting_id` ASC ;

--
-- Indexes for dumped tables
--

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

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

--
-- Indexes for table `meeting`
--
ALTER TABLE `meeting`
  ADD PRIMARY KEY (`meeting_id`),
  ADD KEY `schedule_ibfk_1` (`class_id`),
  ADD KEY `schedule_ibfk_2` (`location_id`),
  ADD KEY `schedule_ibfk_3` (`type_id`);

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

--
-- AUTO_INCREMENT for dumped tables
--

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

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

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

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `meeting`
--
ALTER TABLE `meeting`
  ADD CONSTRAINT `schedule_ibfk_1` FOREIGN KEY (`class_id`) REFERENCES `class` (`class_id`),
  ADD CONSTRAINT `schedule_ibfk_2` FOREIGN KEY (`location_id`) REFERENCES `location` (`location_id`),
  ADD CONSTRAINT `schedule_ibfk_3` FOREIGN KEY (`type_id`) REFERENCES `type` (`type_id`);
COMMIT;

