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

START TRANSACTION;



--
-- Database: `budovsky_schedule`
--

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

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

CREATE TABLE `classes` (
  `classID` int(11) NOT NULL,
  `date` date NOT NULL,
  `startTimeID` int(11) NOT NULL,
  `endTimeID` int(11) NOT NULL,
  `locationID` int(11) NOT NULL,
  `typeID` int(11) NOT NULL,
  `courseID` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `classes`
--

INSERT INTO `classes` (`classID`, `date`, `startTimeID`, `endTimeID`, `locationID`, `typeID`, `courseID`) VALUES
(1, '2024-09-16', 2, 1, 4, 1, 1),
(2, '2024-09-16', 3, 2, 1, 2, 2),
(3, '2024-09-17', 1, 1, 2, 2, 3),
(4, '2024-09-17', 4, 3, 3, 2, 4),
(5, '2024-09-18', 2, 1, 4, 1, 1),
(6, '2024-09-18', 3, 2, 1, 2, 2),
(7, '2024-09-19', 1, 1, 2, 2, 3),
(8, '2024-09-19', 4, 3, 3, 2, 4),
(9, '2024-09-23', 2, 1, 4, 1, 1),
(10, '2024-09-23', 3, 2, 1, 2, 2),
(11, '2024-09-24', 1, 1, 2, 2, 3),
(12, '2024-09-24', 4, 3, 3, 2, 4),
(13, '2024-09-25', 2, 1, 4, 1, 1),
(14, '2024-09-25', 3, 2, 1, 2, 2),
(15, '2024-09-26', 1, 1, 2, 2, 3),
(16, '2024-09-26', 4, 3, 3, 2, 4),
(17, '2024-09-30', 2, 1, 4, 1, 1),
(18, '2024-09-30', 3, 2, 1, 2, 2),
(19, '2024-10-01', 1, 1, 2, 2, 3),
(20, '2024-10-01', 4, 3, 3, 2, 4),
(21, '2024-10-02', 2, 1, 4, 1, 1),
(22, '2024-10-02', 3, 2, 1, 2, 2),
(23, '2024-10-03', 1, 1, 2, 2, 3),
(24, '2024-10-03', 4, 3, 3, 2, 4),
(25, '2024-10-07', 2, 1, 4, 1, 1),
(26, '2024-10-07', 3, 2, 1, 2, 2),
(27, '2024-10-08', 1, 1, 2, 2, 3),
(28, '2024-10-08', 4, 3, 3, 2, 4),
(29, '2024-10-09', 2, 1, 4, 1, 1),
(31, '2024-10-09', 3, 2, 1, 2, 2),
(32, '2024-10-10', 1, 1, 2, 2, 3),
(33, '2024-10-10', 4, 3, 3, 2, 4),
(34, '2024-10-15', 4, 3, 3, 2, 4),
(35, '2024-10-15', 4, 3, 3, 2, 4);

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

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

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

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

INSERT INTO `courses` (`courseID`, `courseName`) VALUES
(1, 'Mor462: Management Consulting'),
(2, 'Acad230: Physical Computing'),
(3, 'Acad324: Practice of Design'),
(4, 'Acad276: Dev 2');

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

--
-- Table structure for table `endTimes`
--

CREATE TABLE `endTimes` (
  `endTimeID` int(11) NOT NULL,
  `endTime` time NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `endTimes`
--

INSERT INTO `endTimes` (`endTimeID`, `endTime`) VALUES
(1, '11:50:00'),
(2, '13:50:00'),
(3, '16:50:00');

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

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

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

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

INSERT INTO `locations` (`locationID`, `location`) VALUES
(1, 'IYA110'),
(2, 'IYA212/213'),
(3, 'IYA210/211'),
(4, 'JFF416');

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

--
-- Stand-in structure for view `scheduleView`
-- (See below for the actual view)
--
CREATE TABLE `scheduleView` (
`classID` int(11)
,`date` date
,`courseName` varchar(50)
,`startTime` time
,`endTime` time
,`location` varchar(10)
,`type` varchar(50)
);

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

--
-- Table structure for table `startTimes`
--

CREATE TABLE `startTimes` (
  `startTimeID` int(11) NOT NULL,
  `startTime` time NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `startTimes`
--

INSERT INTO `startTimes` (`startTimeID`, `startTime`) VALUES
(1, '09:00:00'),
(2, '10:00:00'),
(3, '12:00:00'),
(4, '14:00:00');

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

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

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

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

INSERT INTO `types` (`typeID`, `type`) VALUES
(1, 'lecture'),
(2, 'lecture/lab');

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

--
-- Structure for view `scheduleView`
--

CREATE ALGORITHM=UNDEFINED DEFINER=`budovsky`@`localhost` SQL SECURITY DEFINER VIEW `scheduleView`  AS SELECT `classes`.`classID` AS `classID`, `classes`.`date` AS `date`, `courses`.`courseName` AS `courseName`, `startTimes`.`startTime` AS `startTime`, `endTimes`.`endTime` AS `endTime`, `locations`.`location` AS `location`, `types`.`type` AS `type` FROM (((((`classes` join `courses`) join `startTimes`) join `endTimes`) join `locations`) join `types`) WHERE ((`classes`.`courseID` = `courses`.`courseID`) AND (`classes`.`startTimeID` = `startTimes`.`startTimeID`) AND (`classes`.`endTimeID` = `endTimes`.`endTimeID`) AND (`classes`.`locationID` = `locations`.`locationID`) AND (`classes`.`typeID` = `types`.`typeID`)) ;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `classes`
--
ALTER TABLE `classes`
  ADD PRIMARY KEY (`classID`),
  ADD KEY `courseID` (`courseID`),
  ADD KEY `startTimeID` (`startTimeID`),
  ADD KEY `endTimeID` (`endTimeID`),
  ADD KEY `locationID` (`locationID`),
  ADD KEY `typeID` (`typeID`);

--
-- Indexes for table `courses`
--
ALTER TABLE `courses`
  ADD PRIMARY KEY (`courseID`);

--
-- Indexes for table `endTimes`
--
ALTER TABLE `endTimes`
  ADD PRIMARY KEY (`endTimeID`);

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

--
-- Indexes for table `startTimes`
--
ALTER TABLE `startTimes`
  ADD PRIMARY KEY (`startTimeID`);

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

--
-- AUTO_INCREMENT for dumped tables
--

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

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

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

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

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

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `classes`
--
ALTER TABLE `classes`
  ADD CONSTRAINT `classes_ibfk_1` FOREIGN KEY (`courseID`) REFERENCES `courses` (`courseID`),
  ADD CONSTRAINT `classes_ibfk_2` FOREIGN KEY (`startTimeID`) REFERENCES `startTimes` (`startTimeID`),
  ADD CONSTRAINT `classes_ibfk_3` FOREIGN KEY (`endTimeID`) REFERENCES `endTimes` (`endTimeID`),
  ADD CONSTRAINT `classes_ibfk_4` FOREIGN KEY (`locationID`) REFERENCES `locations` (`locationID`),
  ADD CONSTRAINT `classes_ibfk_5` FOREIGN KEY (`typeID`) REFERENCES `types` (`typeID`);
COMMIT;

