-- ================================================
-- 카테고리 3depth (대/중/소) 테이블 생성 SQL
-- ================================================

DROP TABLE IF EXISTS `ai_category`;

CREATE TABLE `ai_category` (
  `idx`          int(11)      NOT NULL AUTO_INCREMENT,
  `parent_idx`   int(11)      NOT NULL DEFAULT '0' COMMENT '0=대분류',
  `depth`        tinyint(1)   NOT NULL DEFAULT '1' COMMENT '1=대 2=중 3=소',
  `cat_name`     varchar(100) NOT NULL,
  `apply_target` varchar(20)  NOT NULL DEFAULT '' COMMENT '대분류에만 적용: member/board/content',
  `sort_order`   tinyint(3)   NOT NULL DEFAULT '1',
  `use_yn`       tinyint(1)   NOT NULL DEFAULT '1',
  `reg_dt`       datetime     NOT NULL,
  PRIMARY KEY (`idx`),
  KEY `idx_parent` (`parent_idx`),
  KEY `idx_depth`  (`depth`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 대분류 샘플
INSERT INTO `ai_category` VALUES (1, 0, 1, '회원분류',   'member',  1, 1, NOW());
INSERT INTO `ai_category` VALUES (2, 0, 1, '게시판분류', 'board',   2, 1, NOW());
INSERT INTO `ai_category` VALUES (3, 0, 1, '콘텐츠분류', 'content', 3, 1, NOW());

-- 중분류 샘플 (회원분류 하위)
INSERT INTO `ai_category` VALUES (10, 1, 2, '등급',   '', 1, 1, NOW());
INSERT INTO `ai_category` VALUES (11, 1, 2, '지역',   '', 2, 1, NOW());

-- 소분류 샘플 (등급 하위)
INSERT INTO `ai_category` VALUES (100, 10, 3, '임원',     '', 1, 1, NOW());
INSERT INTO `ai_category` VALUES (101, 10, 3, '일반직원', '', 2, 1, NOW());
INSERT INTO `ai_category` VALUES (102, 10, 3, '인턴',     '', 3, 1, NOW());
