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

START TRANSACTION;



--
-- Database: `tjharvey_schedule`
--

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

--
-- Stand-in structure for view `Class Schedule DB`
-- (See below for the actual view)
--
CREATE TABLE `Class Schedule DB` (
`name` varchar(80)
,`type` varchar(15)
,`date` date
,`start_time` time
,`end_time` time
,`location` varchar(20)
);

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

--
-- Table structure for table `dates`
--

CREATE TABLE `dates` (
  `date` date NOT NULL,
  `date_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `dates`
--

INSERT INTO `dates` (`date`, `date_id`) VALUES
('2024-09-12', 1),
('2024-09-16', 2),
('2024-09-17', 3),
('2024-09-18', 4),
('2024-09-19', 5),
('2024-09-23', 6),
('2024-09-24', 7),
('2024-09-25', 8),
('2024-09-26', 9),
('2024-09-30', 10),
('2024-10-01', 11),
('2024-10-02', 12),
('2024-10-03', 13),
('2024-10-07', 14),
('2024-10-08', 15),
('2024-10-09', 16),
('2024-10-10', 17);

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

--
-- Table structure for table `ends`
--

CREATE TABLE `ends` (
  `end_time` time NOT NULL,
  `end_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `ends`
--

INSERT INTO `ends` (`end_time`, `end_id`) VALUES
('11:50:00', 1),
('12:50:00', 2),
('13:50:00', 3),
('16:50:00', 4);

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

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

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

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

INSERT INTO `locations` (`location`, `location_id`) VALUES
('IYH 110/ 111', 1),
('IYH 110', 2),
('IYH 210/211', 3),
('IYH 212/213', 4),
('KAP 160', 5);

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

--
-- Table structure for table `my_schedule`
--

CREATE TABLE `my_schedule` (
  `date_id` int(11) NOT NULL,
  `schedule_id` int(11) NOT NULL,
  `name_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `my_schedule`
--

INSERT INTO `my_schedule` (`date_id`, `schedule_id`, `name_id`) VALUES
(1, 1, 3),
(1, 2, 4),
(1, 3, 5),
(2, 4, 2),
(2, 5, 1),
(3, 6, 3),
(3, 7, 4),
(3, 8, 5),
(4, 9, 2),
(4, 10, 1),
(5, 11, 3),
(5, 12, 4),
(5, 13, 5),
(6, 14, 2),
(6, 15, 1),
(7, 16, 3),
(7, 17, 4),
(7, 18, 5),
(8, 19, 2),
(8, 20, 1),
(9, 21, 3),
(9, 22, 4),
(9, 23, 5),
(10, 24, 2),
(10, 25, 1),
(11, 26, 3),
(11, 27, 4),
(11, 28, 5),
(12, 29, 2),
(12, 30, 1),
(11, 31, 3),
(11, 32, 4),
(11, 33, 5),
(12, 34, 2),
(12, 35, 1),
(13, 36, 3),
(13, 37, 4),
(13, 38, 5),
(14, 39, 2),
(14, 40, 1),
(15, 41, 3),
(15, 42, 4),
(15, 43, 5),
(16, 44, 2),
(16, 45, 1),
(17, 46, 3),
(17, 47, 4),
(17, 48, 5),
(5, 49, 8),
(6, 50, 8),
(8, 51, 8),
(1, 52, 1);

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

--
-- Table structure for table `names`
--

CREATE TABLE `names` (
  `name` varchar(80) NOT NULL,
  `name_id` int(11) NOT NULL,
  `start_id` int(11) NOT NULL,
  `end_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 `names`
--

INSERT INTO `names` (`name`, `name_id`, `start_id`, `end_id`, `location_id`, `type_id`) VALUES
('ACAD-230: Introduction to Interactive Physical Computing', 1, 2, 3, 1, 1),
('ACAD-245: Fundamentals of Product Design', 2, 1, 1, 2, 2),
('ACAD-324: The Practice of Design, Ideation to Innovation', 3, 1, 1, 4, 1),
('ITP-115: Programming in Python', 4, 2, 2, 5, 2),
('ACAD-276: Dev II', 5, 3, 4, 3, 1),
('Macroeconomics', 8, 2, 2, 5, 2),
('', 9, 1, 1, 1, 1),
('ACAD 34314', 10, 1, 1, 1, 1),
('', 11, 2, 1, 1, 1);

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

--
-- Table structure for table `new_schedule`
--

CREATE TABLE `new_schedule` (
  `name` varchar(80) NOT NULL,
  `name_id` int(11) NOT NULL,
  `date_id` int(11) NOT NULL,
  `start_id` int(11) NOT NULL,
  `type_id` int(11) NOT NULL,
  `location_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `new_schedule`
--

INSERT INTO `new_schedule` (`name`, `name_id`, `date_id`, `start_id`, `type_id`, `location_id`) VALUES
('ACAD-230: Introduction to Interactive Physical Computing', 1, 2, 2, 1, 1),
('ACAD-230: Introduction to Interactive Physical Computing', 1, 4, 2, 1, 1),
('ACAD-230: Introduction to Interactive Physical Computing', 1, 6, 2, 1, 1),
('ACAD-230: Introduction to Interactive Physical Computing', 1, 8, 2, 1, 1),
('ACAD-230: Introduction to Interactive Physical Computing', 1, 10, 2, 1, 1),
('ACAD-230: Introduction to Interactive Physical Computing', 1, 12, 2, 1, 1),
('ACAD-230: Introduction to Interactive Physical Computing', 1, 12, 2, 1, 1),
('ACAD-230: Introduction to Interactive Physical Computing', 1, 14, 2, 1, 1),
('ACAD-230: Introduction to Interactive Physical Computing', 1, 16, 2, 1, 1),
('ACAD-230: Introduction to Interactive Physical Computing', 1, 1, 2, 1, 1),
('ACAD-245: Fundamentals of Product Design', 2, 2, 1, 2, 2),
('ACAD-245: Fundamentals of Product Design', 2, 4, 1, 2, 2),
('ACAD-245: Fundamentals of Product Design', 2, 6, 1, 2, 2),
('ACAD-245: Fundamentals of Product Design', 2, 8, 1, 2, 2),
('ACAD-245: Fundamentals of Product Design', 2, 10, 1, 2, 2),
('ACAD-245: Fundamentals of Product Design', 2, 12, 1, 2, 2),
('ACAD-245: Fundamentals of Product Design', 2, 12, 1, 2, 2),
('ACAD-245: Fundamentals of Product Design', 2, 14, 1, 2, 2),
('ACAD-245: Fundamentals of Product Design', 2, 16, 1, 2, 2),
('ACAD-324: The Practice of Design, Ideation to Innovation', 3, 1, 1, 1, 4),
('ACAD-324: The Practice of Design, Ideation to Innovation', 3, 3, 1, 1, 4),
('ACAD-324: The Practice of Design, Ideation to Innovation', 3, 5, 1, 1, 4),
('ACAD-324: The Practice of Design, Ideation to Innovation', 3, 7, 1, 1, 4),
('ACAD-324: The Practice of Design, Ideation to Innovation', 3, 9, 1, 1, 4),
('ACAD-324: The Practice of Design, Ideation to Innovation', 3, 11, 1, 1, 4),
('ACAD-324: The Practice of Design, Ideation to Innovation', 3, 11, 1, 1, 4),
('ACAD-324: The Practice of Design, Ideation to Innovation', 3, 13, 1, 1, 4),
('ACAD-324: The Practice of Design, Ideation to Innovation', 3, 15, 1, 1, 4),
('ACAD-324: The Practice of Design, Ideation to Innovation', 3, 17, 1, 1, 4),
('ITP-115: Programming in Python', 4, 1, 2, 2, 5),
('ITP-115: Programming in Python', 4, 3, 2, 2, 5),
('ITP-115: Programming in Python', 4, 5, 2, 2, 5),
('ITP-115: Programming in Python', 4, 7, 2, 2, 5),
('ITP-115: Programming in Python', 4, 9, 2, 2, 5),
('ITP-115: Programming in Python', 4, 11, 2, 2, 5),
('ITP-115: Programming in Python', 4, 11, 2, 2, 5),
('ITP-115: Programming in Python', 4, 13, 2, 2, 5),
('ITP-115: Programming in Python', 4, 15, 2, 2, 5),
('ITP-115: Programming in Python', 4, 17, 2, 2, 5),
('ACAD-276: Dev II', 5, 1, 3, 1, 3),
('ACAD-276: Dev II', 5, 3, 3, 1, 3),
('ACAD-276: Dev II', 5, 5, 3, 1, 3),
('ACAD-276: Dev II', 5, 7, 3, 1, 3),
('ACAD-276: Dev II', 5, 9, 3, 1, 3),
('ACAD-276: Dev II', 5, 11, 3, 1, 3),
('ACAD-276: Dev II', 5, 11, 3, 1, 3),
('ACAD-276: Dev II', 5, 13, 3, 1, 3),
('ACAD-276: Dev II', 5, 15, 3, 1, 3),
('ACAD-276: Dev II', 5, 17, 3, 1, 3),
('Macroeconomics', 8, 5, 2, 2, 5),
('Macroeconomics', 8, 6, 2, 2, 5),
('Macroeconomics', 8, 8, 2, 2, 5);

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

--
-- Table structure for table `starts`
--

CREATE TABLE `starts` (
  `start_time` time NOT NULL,
  `start_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `starts`
--

INSERT INTO `starts` (`start_time`, `start_id`) VALUES
('09:00:00', 1),
('12:00:00', 2),
('14:00:00', 3);

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

--
-- Table structure for table `types`
--

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

--
-- Dumping data for table `types`
--

INSERT INTO `types` (`type`, `type_id`) VALUES
('Lecture', 1),
('Lecture-Lab', 2);

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

--
-- Structure for view `Class Schedule DB`
--

CREATE ALGORITHM=UNDEFINED DEFINER=`tjharvey`@`localhost` SQL SECURITY DEFINER VIEW `Class Schedule DB`  AS SELECT `names`.`name` AS `name`, `types`.`type` AS `type`, `dates`.`date` AS `date`, `starts`.`start_time` AS `start_time`, `ends`.`end_time` AS `end_time`, `locations`.`location` AS `location` FROM ((((((`my_schedule` join `names`) join `types`) join `dates`) join `starts`) join `ends`) join `locations`) WHERE ((`my_schedule`.`name_id` = `names`.`name_id`) AND (`my_schedule`.`date_id` = `dates`.`date_id`) AND (`names`.`start_id` = `starts`.`start_id`) AND (`names`.`end_id` = `ends`.`end_id`) AND (`names`.`type_id` = `types`.`type_id`) AND (`names`.`location_id` = `locations`.`location_id`)) ORDER BY `dates`.`date` ASC ;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `dates`
--
ALTER TABLE `dates`
  ADD PRIMARY KEY (`date_id`);

--
-- Indexes for table `ends`
--
ALTER TABLE `ends`
  ADD PRIMARY KEY (`end_id`);

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

--
-- Indexes for table `my_schedule`
--
ALTER TABLE `my_schedule`
  ADD PRIMARY KEY (`schedule_id`),
  ADD KEY `date_id` (`date_id`),
  ADD KEY `name_id` (`name_id`);

--
-- Indexes for table `names`
--
ALTER TABLE `names`
  ADD PRIMARY KEY (`name_id`),
  ADD KEY `end_id` (`end_id`),
  ADD KEY `start_id` (`start_id`),
  ADD KEY `location_id` (`location_id`),
  ADD KEY `type_id` (`type_id`);

--
-- Indexes for table `starts`
--
ALTER TABLE `starts`
  ADD PRIMARY KEY (`start_id`);

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

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `dates`
--
ALTER TABLE `dates`
  MODIFY `date_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=18;

--
-- AUTO_INCREMENT for table `ends`
--
ALTER TABLE `ends`
  MODIFY `end_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

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

--
-- AUTO_INCREMENT for table `my_schedule`
--
ALTER TABLE `my_schedule`
  MODIFY `schedule_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=53;

--
-- AUTO_INCREMENT for table `names`
--
ALTER TABLE `names`
  MODIFY `name_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;

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

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `my_schedule`
--
ALTER TABLE `my_schedule`
  ADD CONSTRAINT `my_schedule_ibfk_1` FOREIGN KEY (`date_id`) REFERENCES `dates` (`date_id`),
  ADD CONSTRAINT `my_schedule_ibfk_2` FOREIGN KEY (`name_id`) REFERENCES `names` (`name_id`);

--
-- Constraints for table `names`
--
ALTER TABLE `names`
  ADD CONSTRAINT `names_ibfk_1` FOREIGN KEY (`end_id`) REFERENCES `ends` (`end_id`),
  ADD CONSTRAINT `names_ibfk_2` FOREIGN KEY (`start_id`) REFERENCES `starts` (`start_id`),
  ADD CONSTRAINT `names_ibfk_3` FOREIGN KEY (`location_id`) REFERENCES `locations` (`location_id`),
  ADD CONSTRAINT `names_ibfk_4` FOREIGN KEY (`type_id`) REFERENCES `types` (`type_id`);
COMMIT;

