# BG04 — 数据库总览 > 状态:当前有效 > 引擎:SQLite > 建表方式:GORM AutoMigrate > 最后更新:2026-09-21 当前数据库按五个域理解最清楚: 1. 组织与治理域 2. 对象定义域 3. 运行域 4. 知识底座域 5. 兼容业务域 ## 1. 组织与治理域 主要包括: - `user` - `department` - `position` - `system_config` - `ai_call_log` ## 2. 对象定义域 主要包括: - `specialist` - `skill_definition` - `xapp_definition` - `user_xapp_center` - `action_definition` 连接器当前主要通过注册与运行时目录表达,没有独立核心表承担全部定义。 ## 3. 运行域 主要包括: - `project` - `task_record` - `task_run` - `task_artifact` ## 4. 知识底座域 主要包括: - `knowledge_space` - `knowledge_source` - `knowledge_chunk` - `knowledge_faq` - `media_file` ## 5. 兼容业务域 主要包括: - `company_train` - `product` - `course` - `learning_progress` - `question` - `exam_paper` - `exam_record` - `mistake_record` - `certificate` ## 6. 当前判断 - 当前数据库已经不是旧培训系统单轴结构 - 对象定义、任务运行和知识底座共同构成主干 - 培训考试相关表继续存在,但统一归入兼容业务域理解 ### 4.3 `task_artifact` 任务交付物表,核心字段: - `task_id` - `specialist_key` - `title` - `artifact_type` - `status` - `content_text` - `content_json` - `source_refs_json` - `created_by_run_id` ### 4.4 `project` 项目表,核心字段: - `name` - `instruction` - `template_key` - `owner` - `pinned` - `specialist_keys` - `skill_keys` - `connector_keys` 说明: - 项目是任务容器 - 默认挂载能力以 JSON 字符串形式存储在各类 `*_keys` 字段中 --- ## 5. 知识与素材域 ### 5.1 `media_file` 素材文件表,核心字段: - `filename` - `stored_name` - `stored_path` - `file_ext` - `file_size` - `status` - `source` - `submitter_id` - `bind_type` - `bind_id` - `remark` - `reject_reason` - `audit_by` - `audit_at` - `knowledge_space_key` - `extracted` 说明: - `status`:`pending` / `approved` / `rejected` - `source`:`employee` / `admin` - `bind_type`:`company` / `product` / `course` / `none` ### 5.2 `knowledge_space` 知识空间表,核心字段: - `key` - `name` - `description` - `scope` - `status` - `sort_order` - `is_default` ### 5.3 `knowledge_source` 结构化知识源表,核心字段: - `title` - `file_path` - `category` - `domain` - `source_version` - `audit_status` - `knowledge_space_key` - `audit_by` - `audit_at` - `reject_reason` - `ingested` ### 5.4 `knowledge_chunk` 知识块表,核心字段: - `media_file_id` - `knowledge_source_id` - `source_type` - `source_id` - `knowledge_space_key` - `chunk_index` - `content` 说明: - `media_file_id` 与 `knowledge_source_id` 对应两类知识来源 - 当前搜索与问答最终都消费这张表 ### 5.5 `knowledge_faq` FAQ 表,核心字段: - `knowledge_space_key` - `question` - `answer` - `similar_questions` - `keywords` - `status` - `sort_order` - `hit_count` ### 5.6 `study_note` 学习笔记表,核心字段: - `user_id` - `item_type` - `item_id` - `content` --- ## 6. 培训考试兼容域 ### 6.1 `product` 产品表继续存在,承接兼容产品知识域。 核心字段: - `code` - `name` - `category` - `tags` - `description` - `pricing` - `commission_recommend` - `commission_negotiate` - `public_course_bonus` - `version_risk` - `report_rules` - `status` ### 6.2 `course` 课程表继续存在,承接兼容课程域。 核心字段: - `code` - `name` - `category` - `target_customers` - `forbidden_customers` - `scripts` - `sales_process` - `objection_handling` - `delivery_pitfalls` - `report_rules` - `related_product_id` - `status` ### 6.3 `question` 考试题目表,核心字段: - `domain` - `course_id` - `type` - `stem` - `options` - `answer` - `explanation` - `status` 说明: - 当前 `type` 已包含 `essay` - `options` 与 `answer` 按 JSON 文本存储 ### 6.4 `exam_paper` 考试配置表,核心字段: - `name` - `type` - `domain` - `question_count` - `total_score` - `pass_score` - `duration_minutes` - `randomize` - `position_id` - `status` ### 6.5 `exam_record` 考试记录表,核心字段: - `user_id` - `paper_id` - `exam_name` - `score` - `total_score` - `pass_score` - `passed` - `correct_count` - `wrong_count` - `detail_json` - `submitted_at` ### 6.6 `certificate` 证书表,核心字段: - `user_id` - `exam_record_id` - `user_name` - `exam_name` - `score` - `total_score` - `pass_score` - `cert_no` - `issued_at` ### 6.7 `mistake_record` 错题本表,核心字段: - `user_id` - `question_id` - `source` - `question_type` - `question_stem` - `user_answer` - `correct_answer` - `explanation` - `resolved` ### 6.8 `learning_progress` 学习进度表,核心字段: - `user_id` - `item_type` - `item_id` ### 6.9 `point_event` 积分流水表,核心字段: - `user_id` - `event_type` - `points` - `ref_type` - `ref_id` ### 6.10 `position_knowledge` 岗位知识要求表,核心字段: - `position_id` - `domain` - `course_id` - `product_id` - `required_level` - `weight` - `is_mandatory` ### 6.11 `position_exam_blueprint` 岗位考试蓝图表,核心字段: - `position_id` - `domain` - `type` - `count` --- ## 7. 当前关系理解 当前核心关系可以概括为: ```text user ├─< task_record ├─< project ├─< ai_call_log ├─< study_note ├─< learning_progress ├─< exam_record ├─< certificate ├─< point_event └─1 user_xapp_center specialist ├─< task_record ├─< task_run └─< task_artifact project └─< task_record task_record ├─< task_run └─< task_artifact knowledge_space ├─< knowledge_source ├─< knowledge_chunk └─< knowledge_faq media_file └─< knowledge_chunk knowledge_source └─< knowledge_chunk position ├─< user ├─< position_knowledge ├─< position_exam_blueprint └─< exam_paper ``` --- ## 8. 当前结论 - 当前数据库的真实形态是: **对象定义域 + 任务运行域 + 知识底座域已经成立,培训考试兼容域继续并存的混合态单库。**