-- --------------------------------------------------------
-- Server OS:                    Win64
-- HeidiSQL Version:             12.6.0.6765
-- --------------------------------------------------------



-- Dumping database structure for komb_k
CREATE DATABASE IF NOT EXISTS `komb_k` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */;
USE `komb_k`;

-- Dumping structure for table komb_k.calendars
CREATE TABLE IF NOT EXISTS `calendars` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Dumping data for table komb_k.calendars: ~3 rows (approximately)
INSERT INTO `calendars` (`id`, `name`, `created_at`) VALUES
	(1, 'Admin Calendar', '2024-11-20 12:18:42'),
	(2, 'Manager Calendar', '2024-11-20 12:18:42'),
	(3, 'Worker Calendar', '2024-11-20 12:18:42');

-- Dumping structure for table komb_k.categories
CREATE TABLE IF NOT EXISTS `categories` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Dumping data for table komb_k.categories: ~5 rows (approximately)
INSERT INTO `categories` (`id`, `name`) VALUES
	(1, 'Work'),
	(2, 'Meeting'),
	(3, 'Personal'),
	(4, 'Project'),
	(5, 'Training');

-- Dumping structure for table komb_k.events
CREATE TABLE IF NOT EXISTS `events` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `title` varchar(255) NOT NULL,
  `date` date NOT NULL,
  `start_time` time NOT NULL,
  `end_time` time DEFAULT NULL,
  `category_id` int(11) NOT NULL,
  `priority` enum('High','Medium','Low') NOT NULL,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  KEY `category_id` (`category_id`),
  CONSTRAINT `events_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
  CONSTRAINT `events_ibfk_2` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Dumping data for table komb_k.events: ~5 rows (approximately)
INSERT INTO `events` (`id`, `user_id`, `title`, `date`, `start_time`, `end_time`, `category_id`, `priority`) VALUES
	(1, 1, 'Project Kickoff', '2024-12-01', '09:00:00', '11:00:00', 1, 'High'),
	(2, 1, 'Annual Meeting', '2024-12-02', '10:00:00', '12:00:00', 2, 'Medium'),
	(3, 2, 'Team Training', '2024-12-03', '13:00:00', '15:00:00', 4, 'Low'),
	(4, 3, 'One-on-One with Manager', '2024-12-04', '15:00:00', '16:00:00', 2, 'High'),
	(5, 3, 'Personal Health Check', '2024-12-05', '08:00:00', '09:00:00', 3, 'Low');

-- Dumping structure for table komb_k.roles
CREATE TABLE IF NOT EXISTS `roles` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Dumping data for table komb_k.roles: ~3 rows (approximately)
INSERT INTO `roles` (`id`, `name`) VALUES
	(1, 'Admin'),
	(2, 'Manager'),
	(3, 'Worker');

-- Dumping structure for table komb_k.user_calendars
CREATE TABLE IF NOT EXISTS `user_calendars` (
  `user_id` int(11) NOT NULL,
  `calendar_id` int(11) NOT NULL,
  PRIMARY KEY (`user_id`,`calendar_id`),
  KEY `calendar_id` (`calendar_id`),
  CONSTRAINT `user_calendars_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
  CONSTRAINT `user_calendars_ibfk_2` FOREIGN KEY (`calendar_id`) REFERENCES `calendars` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Dumping data for table komb_k.user_calendars: ~3 rows (approximately)
INSERT INTO `user_calendars` (`user_id`, `calendar_id`) VALUES
	(1, 1),
	(2, 2),
	(3, 3);

-- Dumping structure for table komb_k.user_roles
CREATE TABLE IF NOT EXISTS `user_roles` (
  `user_id` int(11) NOT NULL,
  `role_id` int(11) NOT NULL,
  PRIMARY KEY (`user_id`,`role_id`),
  KEY `role_id` (`role_id`),
  CONSTRAINT `user_roles_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
  CONSTRAINT `user_roles_ibfk_2` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Dumping data for table komb_k.user_roles: ~3 rows (approximately)
INSERT INTO `user_roles` (`user_id`, `role_id`) VALUES
	(1, 1),
	(2, 2),
	(3, 3);

