﻿CREATE TABLE `group_info` (
  `group_id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '그룹 고유 ID (PK)',
  `group_name` VARCHAR(100) NOT NULL COMMENT '그룹(부서) 이름 (UNIQUE)',
  `manager_user_id` BIGINT(20) DEFAULT NULL COMMENT '그룹 관리자 사용자 ID (FK, user_info.user_id)',
  PRIMARY KEY (group_id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 8,
AVG_ROW_LENGTH = 2730,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = '그룹(부서) 정보',
ROW_FORMAT = DYNAMIC;

ALTER TABLE `group_info` 
  ADD UNIQUE INDEX uix_group_name(group_name) COMMENT '그룹 이름은 고유해야 함';

ALTER TABLE `group_info` 
  ADD CONSTRAINT `fk_group_manager` FOREIGN KEY (manager_user_id)
    REFERENCES user_info(user_id) ON DELETE SET NULL ON UPDATE CASCADE;