

-- Table structure for table `novels` --
DROP TABLE IF EXISTS `novels`;
CREATE TABLE `novels` (
  `id` int NOT NULL AUTO_INCREMENT,
  `title` varchar(255) NOT NULL COMMENT '小说标题',
  `description` text COMMENT '简介',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- Dumping data for table `novels` --
INSERT INTO `novels` (`id`, `title`, `description`, `created_at`, `updated_at`) VALUES ('1', '新小说', '开始你的创作', '2025-12-21 06:38:27', '2025-12-21 06:38:27');


-- Table structure for table `knowledge_base` --
DROP TABLE IF EXISTS `knowledge_base`;
CREATE TABLE `knowledge_base` (
  `id` int NOT NULL AUTO_INCREMENT,
  `novel_id` int NOT NULL COMMENT '所属小说ID',
  `background` text COMMENT '时代背景',
  `world_view` text COMMENT '世界观',
  `forbidden_content` text COMMENT '不能出现内容',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `novel_id` (`novel_id`),
  CONSTRAINT `knowledge_base_ibfk_1` FOREIGN KEY (`novel_id`) REFERENCES `novels` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;



-- Table structure for table `characters` --
DROP TABLE IF EXISTS `characters`;
CREATE TABLE `characters` (
  `id` int NOT NULL AUTO_INCREMENT,
  `novel_id` int NOT NULL COMMENT '所属小说ID',
  `name` varchar(100) NOT NULL COMMENT '角色名称',
  `speech_style` text COMMENT '说话风格',
  `clothing_style` text COMMENT '衣着风格',
  `emotional_state` varchar(255) DEFAULT NULL COMMENT '情感状态',
  `life_status` enum('alive','dead') DEFAULT 'alive' COMMENT '生死状态',
  `unique_skills` text COMMENT '独特技能',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `novel_id` (`novel_id`),
  CONSTRAINT `characters_ibfk_1` FOREIGN KEY (`novel_id`) REFERENCES `novels` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;



-- Table structure for table `plots` --
DROP TABLE IF EXISTS `plots`;
CREATE TABLE `plots` (
  `id` int NOT NULL AUTO_INCREMENT,
  `novel_id` int NOT NULL COMMENT '所属小说ID',
  `chapter_number` int NOT NULL COMMENT '章节序号',
  `chapter_title` varchar(255) DEFAULT NULL COMMENT '章节标题',
  `content` longtext COMMENT '章节正文',
  `summary` text COMMENT '章节核心概要（压缩后）',
  `plot_path` varchar(255) DEFAULT NULL COMMENT '剧情路径',
  `character_interactions` text COMMENT '角色互动关系',
  `hidden_clues` text COMMENT '隐藏线索',
  `clue_echoes` text COMMENT '线索呼应',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `novel_id` (`novel_id`),
  CONSTRAINT `plots_ibfk_1` FOREIGN KEY (`novel_id`) REFERENCES `novels` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

