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

START TRANSACTION;



--
-- Database: `julielua_schedule`
--

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

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

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

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

INSERT INTO `endTimes` (`ID`, `endTime`) VALUES
(1, '11:50:00'),
(2, '15:50:00'),
(3, '10:50:00'),
(4, '13:50:00');

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

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

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

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

INSERT INTO `locations` (`ID`, `location`) VALUES
(1, 'IYH212/213'),
(2, 'IYH110'),
(3, 'THH101'),
(4, 'VHE214'),
(5, 'IYH210'),
(6, 'IYH111');

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

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

CREATE TABLE `names` (
  `ID` int(11) NOT NULL,
  `name` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `names`
--

INSERT INTO `names` (`ID`, `name`) VALUES
(1, 'ACAD-324: The Practice of Design'),
(2, 'ACAD-444: Designing Products for Industry'),
(3, 'PSYC-100: Introduction to Psychology'),
(4, 'PSYC-100: Lab'),
(5, 'ACAD-276: Dev II'),
(6, 'ACAD-191: Python for Machine Intelligence');

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

--
-- Table structure for table `schedule`
--

CREATE TABLE `schedule` (
  `ID` int(11) NOT NULL,
  `date` date NOT NULL,
  `startTime_id` int(11) NOT NULL,
  `endTime_id` int(11) NOT NULL,
  `name_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 `schedule`
--

INSERT INTO `schedule` (`ID`, `date`, `startTime_id`, `endTime_id`, `name_id`, `type_id`, `location_id`) VALUES
(1, '2025-09-15', 1, 1, 1, 1, 1),
(2, '2025-09-15', 2, 2, 2, 1, 2),
(3, '2025-09-16', 3, 3, 3, 1, 3),
(4, '2025-09-16', 4, 4, 4, 2, 4),
(5, '2025-09-16', 2, 2, 5, 3, 5),
(6, '2025-09-17', 1, 1, 1, 1, 1),
(7, '2025-09-17', 2, 2, 2, 1, 2),
(8, '2025-09-18', 3, 3, 3, 1, 3),
(9, '2025-09-18', 4, 4, 6, 3, 6),
(10, '2025-09-18', 2, 2, 5, 3, 5),
(11, '2025-09-22', 1, 1, 1, 1, 1),
(12, '2025-09-22', 2, 2, 2, 1, 2),
(13, '2025-09-23', 3, 3, 3, 1, 3),
(14, '2025-09-23', 4, 4, 4, 2, 4),
(15, '2025-09-23', 2, 2, 5, 3, 5),
(16, '2025-09-24', 1, 1, 1, 1, 1),
(17, '2025-09-24', 2, 2, 2, 1, 2),
(18, '2025-09-25', 3, 3, 3, 1, 3),
(19, '2025-09-25', 4, 4, 6, 3, 6),
(20, '2025-09-25', 2, 2, 5, 3, 5),
(21, '2025-09-29', 1, 1, 1, 1, 1),
(22, '2025-09-29', 2, 2, 2, 1, 2),
(23, '2025-09-30', 3, 3, 3, 1, 3),
(24, '2025-09-30', 4, 4, 4, 2, 4),
(25, '2025-09-30', 2, 2, 5, 3, 5),
(26, '2025-10-01', 1, 1, 1, 1, 1),
(27, '2025-10-01', 2, 2, 2, 1, 2),
(28, '2025-10-02', 3, 3, 3, 1, 3),
(29, '2025-10-02', 4, 4, 6, 3, 6),
(30, '2025-10-02', 2, 2, 5, 3, 5),
(31, '2025-10-06', 1, 1, 1, 1, 1),
(32, '2025-10-06', 2, 2, 2, 1, 2),
(33, '2025-10-07', 3, 3, 3, 1, 3),
(34, '2025-10-07', 4, 4, 4, 2, 4),
(35, '2025-10-07', 2, 2, 5, 3, 5),
(36, '2025-10-08', 1, 1, 1, 1, 1),
(37, '2025-10-08', 2, 2, 2, 1, 2),
(38, '2025-10-09', 3, 3, 3, 1, 3),
(39, '2025-10-09', 4, 4, 6, 3, 6),
(40, '2025-10-09', 2, 2, 5, 3, 5);

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

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

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

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

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

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

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

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

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

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

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

INSERT INTO `types` (`ID`, `type`) VALUES
(1, 'lecture'),
(2, 'lab'),
(3, 'lecture-lab');

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

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

CREATE ALGORITHM=UNDEFINED DEFINER=`julielua`@`localhost` SQL SECURITY DEFINER VIEW `scheduleView`  AS SELECT `schedule`.`ID` AS `ID`, `schedule`.`date` AS `date`, `startTimes`.`startTime` AS `startTime`, `endTimes`.`endTime` AS `endTime`, `names`.`name` AS `name`, `types`.`type` AS `type`, `locations`.`location` AS `location` FROM (((((`schedule` join `startTimes`) join `endTimes`) join `names`) join `types`) join `locations`) WHERE ((`schedule`.`startTime_id` = `startTimes`.`ID`) AND (`schedule`.`endTime_id` = `endTimes`.`ID`) AND (`schedule`.`name_id` = `names`.`ID`) AND (`schedule`.`type_id` = `types`.`ID`) AND (`schedule`.`location_id` = `locations`.`ID`)) ORDER BY `schedule`.`ID` ASC ;

--
-- Indexes for dumped tables
--

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

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

--
-- Indexes for table `names`
--
ALTER TABLE `names`
  ADD PRIMARY KEY (`ID`);

--
-- Indexes for table `schedule`
--
ALTER TABLE `schedule`
  ADD PRIMARY KEY (`ID`),
  ADD KEY `endTime_id` (`endTime_id`),
  ADD KEY `location_id` (`location_id`),
  ADD KEY `name_id` (`name_id`),
  ADD KEY `startTime_id` (`startTime_id`),
  ADD KEY `type_id` (`type_id`);

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

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

--
-- AUTO_INCREMENT for dumped tables
--

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

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

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

--
-- AUTO_INCREMENT for table `schedule`
--
ALTER TABLE `schedule`
  MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=41;

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

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `schedule`
--
ALTER TABLE `schedule`
  ADD CONSTRAINT `schedule_ibfk_1` FOREIGN KEY (`endTime_id`) REFERENCES `endTimes` (`ID`),
  ADD CONSTRAINT `schedule_ibfk_2` FOREIGN KEY (`location_id`) REFERENCES `locations` (`ID`),
  ADD CONSTRAINT `schedule_ibfk_3` FOREIGN KEY (`name_id`) REFERENCES `names` (`ID`),
  ADD CONSTRAINT `schedule_ibfk_4` FOREIGN KEY (`startTime_id`) REFERENCES `startTimes` (`ID`),
  ADD CONSTRAINT `schedule_ibfk_5` FOREIGN KEY (`type_id`) REFERENCES `types` (`ID`);
COMMIT;

