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

START TRANSACTION;



--
-- Database: `amypan_schedule`
--

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

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

CREATE TABLE `class` (
  `class_id` int(11) NOT NULL,
  `course_code` varchar(10) NOT NULL,
  `course_name` varchar(100) NOT NULL,
  `section` varchar(10) NOT NULL,
  `units` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

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

INSERT INTO `class` (`class_id`, `course_code`, `course_name`, `section`, `units`) VALUES
(1, 'ACAD 182', 'Case Studies in Innovation', '10211', 4),
(2, 'ACAD 276', 'Dev II', '10241', 4),
(3, 'ACAD 376', 'Industry Practicum I', '10253', 4),
(4, 'ACAD 475A', 'The Garage Experience', '10286', 4),
(5, 'N/A', 'dev 3', 'N/A', 0),
(6, 'N/A', 'dev 3', 'N/A', 0),
(7, 'N/A', 'dev 3', 'N/A', 0),
(8, 'N/A', 'dev 3', 'N/A', 0);

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

--
-- Table structure for table `class_meeting`
--

CREATE TABLE `class_meeting` (
  `meeting_id` int(11) NOT NULL,
  `class_id` int(11) NOT NULL,
  `type_id` int(11) NOT NULL,
  `day` varchar(10) NOT NULL,
  `start_time` time NOT NULL,
  `end_time` time NOT NULL,
  `location_id` int(11) NOT NULL,
  `week` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `class_meeting`
--

INSERT INTO `class_meeting` (`meeting_id`, `class_id`, `type_id`, `day`, `start_time`, `end_time`, `location_id`, `week`) VALUES
(1, 1, 1, 'Mon', '10:00:00', '11:50:00', 1, 1),
(2, 1, 1, 'Wed', '10:00:00', '11:50:00', 1, 1),
(3, 2, 1, 'Tue', '14:00:00', '16:50:00', 2, 1),
(4, 2, 1, 'Thu', '14:00:00', '16:50:00', 2, 1),
(5, 3, 1, 'Tue', '10:00:00', '11:50:00', 2, 1),
(6, 3, 1, 'Thu', '10:00:00', '11:50:00', 2, 1),
(7, 4, 1, 'Wed', '12:00:00', '13:50:00', 3, 1),
(8, 4, 1, 'Fri', '12:00:00', '13:50:00', 3, 1),
(9, 1, 1, 'Mon', '10:00:00', '11:50:00', 1, 2),
(10, 1, 1, 'Wed', '10:00:00', '11:50:00', 1, 2),
(11, 2, 1, 'Tue', '14:02:00', '16:50:00', 2, 2),
(12, 2, 1, 'Thu', '14:01:00', '16:50:00', 2, 2),
(13, 3, 1, 'Tue', '10:00:00', '11:50:00', 2, 2),
(14, 3, 1, 'Thu', '10:00:00', '11:50:00', 2, 2),
(15, 4, 1, 'Wed', '12:00:00', '13:50:00', 3, 2),
(16, 4, 1, 'Fri', '12:00:00', '13:50:00', 3, 2),
(17, 1, 1, 'Mon', '10:00:00', '11:50:00', 1, 3),
(18, 1, 1, 'Wed', '10:00:00', '11:50:00', 1, 3),
(19, 2, 1, 'Tue', '14:00:00', '16:50:00', 2, 3),
(20, 2, 1, 'Thu', '14:00:00', '16:50:00', 2, 3),
(21, 3, 1, 'Tue', '10:00:00', '11:50:00', 2, 3),
(22, 3, 1, 'Thu', '10:00:00', '11:50:00', 2, 3),
(23, 4, 1, 'Wed', '12:00:00', '13:50:00', 3, 3),
(24, 4, 1, 'Fri', '12:00:00', '13:50:00', 3, 3),
(25, 1, 1, 'Mon', '10:00:00', '11:50:00', 1, 4),
(26, 1, 1, 'Wed', '10:00:00', '11:50:00', 1, 4),
(27, 2, 1, 'Tue', '14:00:00', '16:50:00', 2, 4),
(28, 2, 1, 'Thu', '14:00:00', '16:50:00', 2, 4),
(29, 3, 1, 'Tue', '10:00:00', '11:50:00', 2, 4),
(30, 3, 1, 'Thu', '10:00:00', '11:50:00', 2, 4),
(31, 4, 1, 'Wed', '12:00:00', '13:50:00', 3, 4),
(32, 4, 1, 'Fri', '12:00:00', '13:50:00', 3, 4),
(33, 1, 2, '2024-09-28', '17:13:00', '19:18:00', 1, 1),
(34, 1, 1, '2024-09-28', '06:26:00', '09:30:00', 1, 1),
(35, 1, 1, '2024-09-28', '07:31:00', '12:30:00', 1, 1);

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

--
-- Stand-in structure for view `class_schedule`
-- (See below for the actual view)
--
CREATE TABLE `class_schedule` (
`meeting_id` int(11)
,`class_id` int(11)
,`course_code` varchar(10)
,`course_name` varchar(100)
,`section` varchar(10)
,`type_id` int(11)
,`class_type` varchar(50)
,`day` varchar(10)
,`start_time` time
,`end_time` time
,`location_id` int(11)
,`location_name` varchar(100)
,`week` int(11)
);

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

--
-- Table structure for table `class_type`
--

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

--
-- Dumping data for table `class_type`
--

INSERT INTO `class_type` (`type_id`, `type_name`) VALUES
(1, 'Lecture'),
(2, 'Lab');

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

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

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

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

INSERT INTO `location` (`location_id`, `location_name`) VALUES
(1, 'IYH 212'),
(2, 'IYA 210/211'),
(3, 'IYH 110');

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

--
-- Structure for view `class_schedule`
--

CREATE ALGORITHM=UNDEFINED DEFINER=`amypan`@`localhost` SQL SECURITY DEFINER VIEW `class_schedule`  AS SELECT `cm`.`meeting_id` AS `meeting_id`, `c`.`class_id` AS `class_id`, `c`.`course_code` AS `course_code`, `c`.`course_name` AS `course_name`, `c`.`section` AS `section`, `ct`.`type_id` AS `type_id`, `ct`.`type_name` AS `class_type`, `cm`.`day` AS `day`, `cm`.`start_time` AS `start_time`, `cm`.`end_time` AS `end_time`, `l`.`location_id` AS `location_id`, `l`.`location_name` AS `location_name`, `cm`.`week` AS `week` FROM (((`class_meeting` `cm` join `class` `c` on((`cm`.`class_id` = `c`.`class_id`))) join `class_type` `ct` on((`cm`.`type_id` = `ct`.`type_id`))) join `location` `l` on((`cm`.`location_id` = `l`.`location_id`))) ;

--
-- Indexes for dumped tables
--

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

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

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

--
-- Indexes for table `location`
--
ALTER TABLE `location`
  ADD PRIMARY KEY (`location_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=9;

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

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

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `class_meeting`
--
ALTER TABLE `class_meeting`
  ADD CONSTRAINT `class_meeting_ibfk_1` FOREIGN KEY (`type_id`) REFERENCES `class_type` (`type_id`),
  ADD CONSTRAINT `class_meeting_ibfk_2` FOREIGN KEY (`location_id`) REFERENCES `location` (`location_id`);
COMMIT;

