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

START TRANSACTION;



--
-- Database: `mingxinw_schedule`
--

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

--
-- Table structure for table `classes`
--

CREATE TABLE `classes` (
  `classes_id` int(11) NOT NULL,
  `date` date NOT NULL,
  `start_time` time NOT NULL,
  `end_time` time NOT NULL,
  `course_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 `classes`
--

INSERT INTO `classes` (`classes_id`, `date`, `start_time`, `end_time`, `course_id`, `location_id`, `type_id`) VALUES
(1, '2023-09-11', '09:00:00', '11:50:00', 3, 2, 1),
(2, '2023-09-11', '17:00:00', '18:20:00', 4, 3, 1),
(3, '2023-09-12', '09:30:00', '10:50:00', 5, 4, 1),
(4, '2023-09-12', '11:00:00', '12:50:00', 1, 7, 1),
(5, '2023-09-12', '14:00:00', '16:50:00', 2, 1, 3),
(6, '2023-09-13', '09:00:00', '11:50:00', 3, 2, 1),
(7, '2023-09-13', '17:00:00', '18:20:00', 4, 3, 1),
(8, '2023-09-14', '09:30:00', '10:50:00', 5, 4, 1),
(9, '2023-09-14', '11:00:00', '12:50:00', 1, 7, 1),
(10, '2023-09-14', '14:00:00', '16:50:00', 2, 1, 3),
(11, '2023-09-15', '08:30:00', '09:50:00', 5, 5, 2),
(12, '2023-09-15', '10:00:00', '11:50:00', 4, 6, 2),
(13, '2023-09-18', '09:00:00', '11:50:00', 3, 2, 1),
(14, '2023-09-18', '17:00:00', '18:20:00', 4, 3, 1),
(15, '2023-09-19', '09:30:00', '10:50:00', 5, 4, 1),
(16, '2023-09-19', '11:00:00', '12:50:00', 1, 7, 1),
(17, '2023-09-19', '14:00:00', '16:50:00', 2, 1, 3),
(18, '2023-09-20', '09:00:00', '11:50:00', 3, 2, 1),
(19, '2023-09-20', '17:00:00', '18:20:00', 4, 3, 1),
(20, '2023-09-21', '09:30:00', '10:50:00', 5, 4, 1),
(21, '2023-09-21', '11:00:00', '12:50:00', 1, 7, 1),
(22, '2023-09-21', '14:00:00', '16:50:00', 2, 1, 3),
(23, '2023-09-22', '08:30:00', '09:50:00', 5, 5, 2),
(24, '2023-09-22', '10:00:00', '11:50:00', 4, 6, 2),
(25, '2023-09-25', '09:00:00', '11:50:00', 3, 2, 1),
(26, '2023-09-25', '17:00:00', '18:20:00', 4, 3, 1),
(27, '2023-09-26', '09:30:00', '10:50:00', 5, 4, 1),
(28, '2023-09-26', '11:00:00', '12:50:00', 1, 7, 1),
(29, '2023-09-26', '14:00:00', '16:50:00', 2, 1, 3),
(30, '2023-09-27', '09:00:00', '11:50:00', 3, 2, 1),
(31, '2023-09-27', '17:00:00', '18:20:00', 4, 3, 1),
(32, '2023-09-28', '09:30:00', '10:50:00', 5, 4, 1),
(33, '2023-09-28', '11:00:00', '12:50:00', 1, 7, 1),
(34, '2023-09-28', '14:00:00', '16:50:00', 2, 1, 3),
(35, '2023-09-29', '08:30:00', '09:50:00', 5, 5, 2),
(36, '2023-09-29', '10:00:00', '11:50:00', 4, 6, 2),
(37, '2023-10-02', '09:00:00', '11:50:00', 3, 2, 1),
(38, '2023-10-02', '17:00:00', '18:20:00', 4, 3, 1),
(39, '2023-10-03', '09:30:00', '10:50:00', 5, 4, 1),
(40, '2023-10-03', '11:00:00', '12:50:00', 1, 7, 1),
(41, '2023-10-03', '14:00:00', '16:50:00', 2, 1, 3),
(42, '2023-10-04', '09:00:00', '11:50:00', 3, 2, 1),
(43, '2023-10-04', '17:00:00', '18:20:00', 4, 3, 1),
(44, '2023-10-05', '09:30:00', '10:50:00', 5, 4, 1),
(45, '2023-10-05', '11:00:00', '12:50:00', 1, 7, 1),
(46, '2023-10-05', '14:00:00', '16:50:00', 2, 1, 3),
(47, '2023-10-06', '08:30:00', '09:50:00', 5, 5, 2),
(48, '2023-10-06', '10:00:00', '11:50:00', 4, 6, 2);

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

--
-- Stand-in structure for view `classes_view`
-- (See below for the actual view)
--
CREATE TABLE `classes_view` (
`date` date
,`start_time` varchar(8)
,`end_time` varchar(8)
,`courseName` varchar(50)
,`locationName` varchar(25)
,`typeName` varchar(25)
);

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

--
-- Table structure for table `course`
--

CREATE TABLE `course` (
  `course_id` int(11) NOT NULL,
  `courseName` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `course`
--

INSERT INTO `course` (`course_id`, `courseName`) VALUES
(1, 'ACAD 499: Intro to Physical Computing'),
(2, 'ACAD 276: Dev 2'),
(3, 'ACAD 324: The Practice of Design'),
(4, 'CSCI 170: Discrete Methods in Computer Science'),
(5, 'LING 285: Human Language and Technology');

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

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

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

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

INSERT INTO `location` (`location_id`, `locationName`) VALUES
(1, 'IYH210'),
(2, 'IYH212'),
(3, 'SGM101'),
(4, 'THH102'),
(5, 'KAP138'),
(6, 'THH210'),
(7, 'IYH111');

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

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

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

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

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

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

--
-- Structure for view `classes_view`
--

CREATE ALGORITHM=UNDEFINED DEFINER=`mingxinw`@`%` SQL SECURITY DEFINER VIEW `classes_view`  AS SELECT `classes`.`date` AS `date`, time_format(`classes`.`start_time`,'%h:%i %p') AS `start_time`, time_format(`classes`.`end_time`,'%h:%i %p') AS `end_time`, `course`.`courseName` AS `courseName`, `location`.`locationName` AS `locationName`, `type`.`typeName` AS `typeName` FROM (((`classes` join `course` on((`classes`.`course_id` = `course`.`course_id`))) join `location` on((`classes`.`location_id` = `location`.`location_id`))) join `type` on((`classes`.`type_id` = `type`.`type_id`))) WHERE ((`classes`.`course_id` = `course`.`course_id`) AND (`classes`.`location_id` = `location`.`location_id`) AND (`classes`.`type_id` = `type`.`type_id`)) ORDER BY `classes`.`classes_id` ASC ;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `classes`
--
ALTER TABLE `classes`
  ADD PRIMARY KEY (`classes_id`),
  ADD KEY `classes_1` (`course_id`),
  ADD KEY `classes_2` (`location_id`),
  ADD KEY `classes_3` (`type_id`);

--
-- Indexes for table `course`
--
ALTER TABLE `course`
  ADD PRIMARY KEY (`course_id`);

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

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

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `classes`
--
ALTER TABLE `classes`
  MODIFY `classes_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=49;

--
-- AUTO_INCREMENT for table `course`
--
ALTER TABLE `course`
  MODIFY `course_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=8;

--
-- 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 `classes`
--
ALTER TABLE `classes`
  ADD CONSTRAINT `classes_1` FOREIGN KEY (`course_id`) REFERENCES `course` (`course_id`),
  ADD CONSTRAINT `classes_2` FOREIGN KEY (`location_id`) REFERENCES `location` (`location_id`),
  ADD CONSTRAINT `classes_3` FOREIGN KEY (`type_id`) REFERENCES `type` (`type_id`);
COMMIT;

