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

START TRANSACTION;



--
-- Database: `casearcy_schedule`
--

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

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

CREATE TABLE `classes` (
  `class_id` int(11) NOT NULL,
  `class` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

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

INSERT INTO `classes` (`class_id`, `class`) VALUES
(1, 'pod'),
(2, 'bsm'),
(3, 'dev'),
(4, 'materials');

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

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

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

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

INSERT INTO `locations` (`location_id`, `location`) VALUES
(1, 'iyh'),
(2, 'thh');

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

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

CREATE TABLE `schedule` (
  `class_id` int(11) NOT NULL,
  `date` date NOT NULL,
  `start` time NOT NULL,
  `end` time NOT NULL,
  `location_id` int(11) NOT NULL,
  `type_id` int(11) NOT NULL,
  `pk` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `schedule`
--

INSERT INTO `schedule` (`class_id`, `date`, `start`, `end`, `location_id`, `type_id`, `pk`) VALUES
(3, '2023-09-05', '14:00:00', '16:50:00', 1, 3, 1),
(4, '2023-09-05', '18:00:00', '19:50:00', 1, 1, 2),
(1, '2023-09-06', '09:00:00', '11:50:00', 1, 3, 3),
(2, '2023-09-06', '12:00:00', '13:50:00', 2, 1, 4),
(2, '2023-09-05', '12:00:00', '12:50:00', 2, 1, 5),
(3, '2023-09-07', '14:00:00', '16:50:00', 1, 3, 6),
(4, '2023-09-07', '18:00:00', '19:50:00', 1, 1, 7),
(1, '2023-09-11', '09:00:00', '11:50:00', 1, 3, 8),
(2, '2023-09-11', '12:00:00', '13:50:00', 2, 1, 9),
(2, '2023-09-12', '12:00:00', '12:50:00', 2, 1, 10),
(3, '2023-09-12', '14:00:00', '16:50:00', 1, 3, 11),
(3, '2023-09-14', '14:00:00', '16:50:00', 1, 3, 12),
(4, '2023-09-14', '18:00:00', '19:50:00', 1, 1, 13),
(1, '2023-09-13', '09:00:00', '11:50:00', 1, 3, 14),
(2, '2023-09-13', '12:00:00', '13:50:00', 2, 1, 15),
(2, '2023-09-19', '12:00:00', '12:50:00', 2, 1, 16),
(4, '2023-09-12', '18:00:00', '19:50:00', 1, 1, 17),
(2, '2023-09-18', '12:00:00', '13:50:00', 2, 1, 18),
(1, '2023-09-18', '09:00:00', '11:50:00', 1, 3, 19),
(3, '2023-09-19', '14:00:00', '16:50:00', 1, 3, 20),
(4, '2023-09-19', '18:00:00', '19:50:00', 1, 1, 21),
(1, '2023-09-20', '09:00:00', '11:50:00', 1, 3, 22),
(2, '2023-09-20', '12:00:00', '13:50:00', 2, 1, 23),
(3, '2023-09-21', '14:00:00', '16:50:00', 1, 3, 24),
(4, '2023-09-21', '18:00:00', '19:50:00', 1, 1, 25),
(2, '2023-09-25', '12:00:00', '13:50:00', 2, 1, 26),
(1, '2023-09-25', '09:00:00', '11:50:00', 1, 3, 27),
(2, '2023-09-26', '12:00:00', '12:50:00', 2, 1, 28),
(3, '2023-09-26', '14:00:00', '16:50:00', 1, 3, 29),
(4, '2023-09-26', '18:00:00', '19:50:00', 1, 1, 30),
(1, '2023-09-27', '09:00:00', '11:50:00', 1, 3, 40),
(2, '2023-09-27', '12:00:00', '13:50:00', 2, 1, 41),
(3, '2023-09-28', '14:00:00', '16:50:00', 1, 3, 42),
(4, '2023-09-28', '18:00:00', '19:50:00', 1, 1, 43),
(2, '2023-10-02', '12:00:00', '13:50:00', 2, 1, 44),
(1, '2023-10-02', '09:00:00', '11:50:00', 1, 3, 45),
(2, '2023-10-03', '12:00:00', '12:50:00', 2, 1, 46),
(3, '2023-10-03', '14:00:00', '16:50:00', 1, 3, 47),
(4, '2023-10-03', '18:00:00', '19:50:00', 1, 1, 48),
(1, '2023-10-04', '09:00:00', '11:50:00', 1, 3, 49),
(2, '2023-10-04', '12:00:00', '13:50:00', 2, 1, 50),
(3, '2023-10-05', '14:00:00', '16:50:00', 1, 3, 51),
(4, '2023-10-05', '18:00:00', '19:50:00', 1, 1, 52);

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

--
-- Stand-in structure for view `schedule_view1`
-- (See below for the actual view)
--
CREATE TABLE `schedule_view1` (
`class` varchar(50)
,`location` varchar(50)
,`type` varchar(50)
,`date` date
,`end` time
,`start` time
,`pk` int(11)
);

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

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

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

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

INSERT INTO `types` (`type_id`, `type`) VALUES
(1, 'lect'),
(2, 'lab'),
(3, 'lect/lab');

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

--
-- Structure for view `schedule_view1`
--

CREATE ALGORITHM=UNDEFINED DEFINER=`casearcy`@`localhost` SQL SECURITY DEFINER VIEW `schedule_view1`  AS SELECT `classes`.`class` AS `class`, `locations`.`location` AS `location`, `types`.`type` AS `type`, `schedule`.`date` AS `date`, `schedule`.`end` AS `end`, `schedule`.`start` AS `start`, `schedule`.`pk` AS `pk` FROM (((`schedule` join `types`) join `locations`) join `classes`) WHERE ((`schedule`.`class_id` = `classes`.`class_id`) AND (`schedule`.`type_id` = `types`.`type_id`) AND (`schedule`.`location_id` = `locations`.`location_id`)) ;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `classes`
--
ALTER TABLE `classes`
  ADD PRIMARY KEY (`class_id`);

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

--
-- Indexes for table `schedule`
--
ALTER TABLE `schedule`
  ADD PRIMARY KEY (`pk`),
  ADD KEY `class_id` (`class_id`),
  ADD KEY `location_id` (`location_id`),
  ADD KEY `type_id` (`type_id`);

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

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `classes`
--
ALTER TABLE `classes`
  MODIFY `class_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=3;

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

--
-- AUTO_INCREMENT for table `types`
--
ALTER TABLE `types`
  MODIFY `type_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 (`class_id`) REFERENCES `classes` (`class_id`),
  ADD CONSTRAINT `schedule_ibfk_2` FOREIGN KEY (`location_id`) REFERENCES `locations` (`location_id`),
  ADD CONSTRAINT `schedule_ibfk_3` FOREIGN KEY (`type_id`) REFERENCES `types` (`type_id`);
COMMIT;

