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

START TRANSACTION;



--
-- Database: `onggowar_schedule`
--

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

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

CREATE TABLE `classes` (
  `classID` int(11) NOT NULL,
  `date` date NOT NULL,
  `start_time` time NOT NULL,
  `end_time` time NOT NULL,
  `locationID` int(11) NOT NULL,
  `typeID` int(11) NOT NULL,
  `nameID` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

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

INSERT INTO `classes` (`classID`, `date`, `start_time`, `end_time`, `locationID`, `typeID`, `nameID`) VALUES
(1, '2023-09-11', '09:00:00', '11:50:00', 2, 1, 2),
(2, '2023-09-11', '13:00:00', '15:20:00', 4, 3, 5),
(3, '2023-09-12', '10:00:00', '11:50:00', 3, 3, 4),
(4, '2023-09-12', '14:00:00', '16:50:00', 1, 1, 1),
(5, '2023-09-12', '18:00:00', '19:50:00', 2, 1, 3),
(6, '2023-09-13', '09:00:00', '11:50:00', 2, 1, 2),
(7, '2023-09-13', '14:00:00', '15:20:00', 4, 3, 5),
(8, '2023-09-14', '10:00:00', '11:50:00', 3, 2, 4),
(9, '2023-09-14', '10:00:00', '11:50:00', 1, 1, 1),
(10, '2023-09-14', '18:00:00', '19:50:00', 2, 1, 3),
(11, '2023-09-18', '09:00:00', '11:50:00', 2, 1, 2),
(12, '2023-09-18', '13:00:00', '15:20:00', 4, 3, 5),
(13, '2023-09-19', '10:00:00', '11:50:00', 3, 3, 4),
(14, '2023-09-19', '14:00:00', '16:50:00', 1, 1, 1),
(15, '2023-09-19', '18:00:00', '19:50:00', 2, 1, 3),
(16, '2023-09-20', '09:00:00', '11:50:00', 2, 1, 2),
(17, '2023-09-20', '14:00:00', '15:20:00', 4, 3, 5),
(18, '2023-09-21', '10:00:00', '11:50:00', 3, 2, 4),
(19, '2023-09-21', '10:00:00', '11:50:00', 1, 1, 1),
(20, '2023-09-21', '18:00:00', '19:50:00', 2, 1, 3),
(21, '2023-09-25', '09:00:00', '11:50:00', 2, 1, 2),
(22, '2023-09-25', '13:00:00', '15:20:00', 4, 3, 5),
(23, '2023-09-26', '10:00:00', '11:50:00', 3, 3, 4),
(24, '2023-09-26', '14:00:00', '16:50:00', 1, 1, 1),
(25, '2023-09-26', '18:00:00', '19:50:00', 2, 1, 3),
(26, '2023-09-27', '09:00:00', '11:50:00', 2, 1, 2),
(27, '2023-09-27', '14:00:00', '15:20:00', 4, 3, 5),
(28, '2023-09-28', '10:00:00', '11:50:00', 3, 2, 4),
(29, '2023-09-28', '10:00:00', '11:50:00', 1, 1, 1),
(30, '2023-09-28', '18:00:00', '19:50:00', 2, 1, 3),
(31, '2023-10-02', '09:00:00', '11:50:00', 2, 1, 2),
(32, '2023-10-02', '13:00:00', '15:20:00', 4, 3, 5),
(33, '2023-10-03', '10:00:00', '11:50:00', 3, 3, 4),
(34, '2023-10-03', '14:00:00', '16:50:00', 1, 1, 1),
(35, '2023-10-03', '18:00:00', '19:50:00', 2, 1, 3),
(36, '2023-10-04', '09:00:00', '11:50:00', 2, 1, 2),
(37, '2023-10-04', '14:00:00', '15:20:00', 4, 3, 5),
(38, '2023-10-05', '10:00:00', '11:50:00', 3, 2, 4),
(39, '2023-10-05', '10:00:00', '11:50:00', 1, 1, 1),
(40, '2023-10-05', '18:00:00', '19:50:00', 2, 1, 3);

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

--
-- Stand-in structure for view `classView`
-- (See below for the actual view)
--
CREATE TABLE `classView` (
`date` date
,`start_time` time
,`end_time` time
,`locationName` varchar(50)
,`nameName` varchar(50)
,`typeName` varchar(50)
);

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

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

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

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

INSERT INTO `locations` (`locationID`, `locationName`) VALUES
(1, 'IYH 210/211'),
(2, 'IYH 212/213'),
(3, 'KAP 107'),
(4, 'SGM 101');

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

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

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

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

INSERT INTO `names` (`nameID`, `nameName`) VALUES
(1, 'ACAD 276: Dev 2'),
(2, 'ACAD 324: Practice of Design'),
(3, 'ACAD 240: Materials'),
(4, 'ITP 215: 3D Modelling'),
(5, 'AMST 301: America');

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

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

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

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

INSERT INTO `types` (`typeID`, `typeName`) VALUES
(1, 'lecture'),
(2, 'lab'),
(3, 'lecture and lab');

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

--
-- Structure for view `classView`
--

CREATE ALGORITHM=UNDEFINED DEFINER=`onggowar`@`localhost` SQL SECURITY DEFINER VIEW `classView`  AS SELECT `classes`.`date` AS `date`, `classes`.`start_time` AS `start_time`, `classes`.`end_time` AS `end_time`, `locations`.`locationName` AS `locationName`, `names`.`nameName` AS `nameName`, `types`.`typeName` AS `typeName` FROM (((`classes` join `locations`) join `names`) join `types`) WHERE ((`classes`.`locationID` = `locations`.`locationID`) AND (`classes`.`typeID` = `types`.`typeID`) AND (`classes`.`nameID` = `names`.`nameID`)) ;

--
-- Indexes for dumped tables
--

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

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

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

--
-- 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=41;

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

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

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `classes`
--
ALTER TABLE `classes`
  ADD CONSTRAINT `classes_ibfk_1` FOREIGN KEY (`locationID`) REFERENCES `locations` (`locationID`),
  ADD CONSTRAINT `classes_ibfk_2` FOREIGN KEY (`nameID`) REFERENCES `names` (`nameID`),
  ADD CONSTRAINT `classes_ibfk_3` FOREIGN KEY (`typeID`) REFERENCES `types` (`typeID`);
COMMIT;

