-- phpMyAdmin SQL Dump
-- version 5.2.3
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Generation Time: Sep 23, 2026 at 10:30 AM
-- Server version: 5.7.44
-- PHP Version: 8.1.34

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `sfcheng_schedule`
--

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

--
-- Table structure for table `class_meetings`
--

CREATE TABLE `class_meetings` (
  `meeting_id` int(11) NOT NULL,
  `course_id` int(11) NOT NULL,
  `location_id` int(11) NOT NULL,
  `type_id` int(11) NOT NULL,
  `meeting_date` date NOT NULL,
  `start_time` time NOT NULL,
  `end_time` time NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `class_meetings`
--

INSERT INTO `class_meetings` (`meeting_id`, `course_id`, `location_id`, `type_id`, `meeting_date`, `start_time`, `end_time`) VALUES
(1, 1, 1, 1, '2026-09-14', '10:00:00', '11:50:00'),
(2, 2, 2, 1, '2026-09-15', '10:00:00', '11:50:00'),
(3, 3, 2, 2, '2026-09-15', '12:00:00', '13:50:00'),
(4, 4, 3, 1, '2026-09-15', '14:00:00', '15:50:00'),
(5, 1, 1, 1, '2026-09-16', '10:00:00', '11:50:00'),
(6, 2, 2, 1, '2026-09-17', '10:00:00', '11:50:00'),
(7, 3, 2, 2, '2026-09-17', '12:00:00', '13:50:00'),
(8, 4, 3, 1, '2026-09-17', '14:00:00', '15:50:00'),
(9, 5, 4, 3, '2026-09-18', '15:00:00', '16:50:00'),
(10, 1, 1, 1, '2026-09-21', '10:00:00', '11:50:00'),
(11, 2, 2, 1, '2026-09-22', '10:00:00', '11:50:00'),
(12, 3, 2, 2, '2026-09-22', '12:00:00', '13:50:00'),
(13, 4, 3, 1, '2026-09-22', '14:00:00', '15:50:00'),
(14, 1, 1, 1, '2026-09-23', '10:00:00', '11:50:00'),
(15, 2, 2, 1, '2026-09-24', '10:00:00', '11:50:00'),
(16, 3, 2, 2, '2026-09-24', '12:00:00', '13:50:00'),
(17, 4, 3, 1, '2026-09-24', '14:00:00', '15:50:00'),
(18, 5, 4, 3, '2026-09-25', '15:00:00', '16:50:00'),
(19, 1, 1, 1, '2026-09-28', '10:00:00', '11:50:00'),
(20, 2, 2, 1, '2026-09-29', '10:00:00', '11:50:00'),
(21, 3, 2, 2, '2026-09-29', '12:00:00', '13:50:00'),
(22, 4, 3, 1, '2026-09-29', '14:00:00', '15:50:00'),
(23, 1, 1, 1, '2026-09-30', '10:00:00', '11:50:00'),
(24, 2, 2, 1, '2026-10-01', '10:00:00', '11:50:00'),
(25, 3, 2, 2, '2026-10-01', '12:00:00', '13:50:00'),
(26, 4, 3, 1, '2026-10-01', '14:00:00', '15:50:00'),
(27, 5, 4, 3, '2026-10-02', '15:00:00', '16:50:00'),
(28, 1, 1, 1, '2026-10-05', '10:00:00', '11:50:00'),
(29, 2, 2, 1, '2026-10-06', '10:00:00', '11:50:00'),
(30, 3, 2, 2, '2026-10-06', '12:00:00', '13:50:00'),
(31, 4, 3, 1, '2026-10-06', '14:00:00', '15:50:00'),
(32, 1, 1, 1, '2026-10-07', '10:00:00', '11:50:00'),
(33, 2, 2, 1, '2026-10-08', '10:00:00', '11:50:00'),
(34, 3, 2, 2, '2026-10-08', '12:00:00', '13:50:00'),
(35, 4, 3, 1, '2026-10-08', '14:00:00', '15:50:00'),
(36, 5, 4, 3, '2026-10-09', '15:00:00', '16:50:00');

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

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

CREATE TABLE `courses` (
  `course_id` int(11) NOT NULL,
  `course_code` varchar(20) NOT NULL,
  `course_name` varchar(150) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

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

INSERT INTO `courses` (`course_id`, `course_code`, `course_name`) VALUES
(1, 'ACAD 324', 'The Practice of Design: Ideation to Innovation'),
(2, 'ACAD 185', 'Analytics and Marketing for Challenge-Based'),
(3, 'ACAD 276', 'Dev II'),
(4, 'BAEP 455', 'Founder\'s Dilemmas'),
(5, 'IDSN 521', 'Designing Brand Identity for Startups');

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

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

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

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

INSERT INTO `locations` (`location_id`, `location_name`) VALUES
(1, 'IYH212/213'),
(2, 'IYH210/211'),
(3, 'JFF416'),
(4, 'ONLINE');

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

--
-- Table structure for table `meeting_types`
--

CREATE TABLE `meeting_types` (
  `type_id` int(11) NOT NULL,
  `type_name` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `meeting_types`
--

INSERT INTO `meeting_types` (`type_id`, `type_name`) VALUES
(1, 'Lecture'),
(2, 'Lecture/Lab'),
(3, 'Online');

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

--
-- Stand-in structure for view `v_class_schedule`
-- (See below for the actual view)
--
CREATE TABLE `v_class_schedule` (
`meeting_id` int(11)
,`course_id` int(11)
,`location_id` int(11)
,`type_id` int(11)
,`meeting_date` date
,`start_time` time
,`end_time` time
,`location` varchar(50)
,`meeting_type` varchar(30)
,`class_name` varchar(172)
);

--
-- Indexes for dumped tables
--

--
-- Indexes for table `class_meetings`
--
ALTER TABLE `class_meetings`
  ADD PRIMARY KEY (`meeting_id`),
  ADD KEY `fk_meetings_course` (`course_id`),
  ADD KEY `fk_meetings_location` (`location_id`),
  ADD KEY `fk_meetings_type` (`type_id`);

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

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

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

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `class_meetings`
--
ALTER TABLE `class_meetings`
  MODIFY `meeting_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=37;

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

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

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

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

--
-- Structure for view `v_class_schedule`
--
DROP TABLE IF EXISTS `v_class_schedule`;

CREATE ALGORITHM=UNDEFINED DEFINER=`sfcheng`@`localhost` SQL SECURITY DEFINER VIEW `v_class_schedule`  AS SELECT `cm`.`meeting_id` AS `meeting_id`, `cm`.`course_id` AS `course_id`, `cm`.`location_id` AS `location_id`, `cm`.`type_id` AS `type_id`, `cm`.`meeting_date` AS `meeting_date`, `cm`.`start_time` AS `start_time`, `cm`.`end_time` AS `end_time`, `l`.`location_name` AS `location`, `mt`.`type_name` AS `meeting_type`, concat(`c`.`course_code`,': ',`c`.`course_name`) AS `class_name` FROM (((`class_meetings` `cm` join `courses` `c` on((`cm`.`course_id` = `c`.`course_id`))) join `locations` `l` on((`cm`.`location_id` = `l`.`location_id`))) join `meeting_types` `mt` on((`cm`.`type_id` = `mt`.`type_id`))) ORDER BY `cm`.`meeting_date` ASC, `cm`.`start_time` ASC ;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `class_meetings`
--
ALTER TABLE `class_meetings`
  ADD CONSTRAINT `fk_meetings_course` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_meetings_location` FOREIGN KEY (`location_id`) REFERENCES `locations` (`location_id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_meetings_type` FOREIGN KEY (`type_id`) REFERENCES `meeting_types` (`type_id`) ON UPDATE CASCADE;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
