Files
schoolNews/schoolNewsServ/.bin/mysql/INDEX.md
2025-10-15 10:39:51 +08:00

289 lines
9.4 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 数据库文件索引
## 📋 文件清单
### SQL脚本文件
| 文件名 | 说明 | 表数量 | 执行顺序 |
|--------|------|--------|----------|
| `sql/createDB.sql` | 创建数据库 | 0 | 1 |
| `sql/createTableUser.sql` | 用户管理模块 | 3 | 2 |
| `sql/createTablePermission.sql` | 权限管理模块 | 8 | 3 |
| `sql/createTableResource.sql` | 资源管理模块 | 8 | 4 |
| `sql/createTableCourse.sql` | 课程管理模块 | 4 | 5 |
| `sql/createTableLearning.sql` | 学习管理模块 | 6 | 6 |
| `sql/createTableUserCenter.sql` | 个人中心模块 | 6 | 7 |
| `sql/createTableAI.sql` | 智能体模块 | 6 | 8 |
| `sql/createTableSystem.sql` | 系统管理模块 | 8 | 9 |
| `sql/initAll.sql` | 一键执行所有SQL | - | - |
**总计**: 49张表
### 执行脚本
| 文件名 | 平台 | 说明 |
|--------|------|------|
| `init-database.bat` | Windows | Windows批处理脚本 |
| `init-database.sh` | Linux/Mac | Shell脚本 |
### 文档文件
| 文件名 | 说明 | 推荐阅读 |
|--------|------|----------|
| `INDEX.md` | 本文件,文件索引 | ⭐⭐⭐ |
| `使用说明.md` | 详细使用说明 | ⭐⭐⭐⭐⭐ |
| `sql/README.md` | 表结构详细说明 | ⭐⭐⭐⭐⭐ |
| `sql/表结构汇总.md` | 表结构汇总列表 | ⭐⭐⭐⭐ |
| `sql/ER关系图.md` | 表关系图 | ⭐⭐⭐⭐ |
## 📁 完整目录结构
```
.bin/mysql/
├── init-database.bat # Windows初始化脚本
├── init-database.sh # Linux/Mac初始化脚本
├── INDEX.md # 本文件
├── 使用说明.md # 使用指南
└── sql/ # SQL脚本目录
├── createDB.sql # [1] 创建数据库
├── createTableUser.sql # [2] 用户管理模块
│ ├── tb_sys_user # 用户表
│ ├── tb_sys_user_info # 用户信息表
│ └── tb_sys_login_log # 登录日志表
├── createTablePermission.sql # [3] 权限管理模块
│ ├── tb_sys_dept # 部门表
│ ├── tb_sys_role # 角色表
│ ├── tb_sys_dept_role # 部门-角色关联表
│ ├── tb_sys_user_dept_role # 用户-部门-角色关联表
│ ├── tb_sys_permission # 权限表
│ ├── tb_sys_role_permission # 角色-权限关联表
│ ├── tb_sys_menu # 菜单表
│ └── tb_sys_menu_permission # 菜单-权限关联表
├── createTableResource.sql # [4] 资源管理模块
│ ├── tb_resource # 资源表
│ ├── tb_resource_category # 资源分类表
│ ├── tb_banner # Banner表
│ ├── tb_resource_recommend # 资源推荐表
│ ├── tb_tag # 标签表
│ ├── tb_resource_tag # 资源-标签关联表
│ ├── tb_data_collection_config # 数据采集配置表
│ └── tb_data_collection_log # 数据采集记录表
├── createTableCourse.sql # [5] 课程管理模块
│ ├── tb_course # 课程表
│ ├── tb_course_chapter # 课程章节表
│ ├── tb_course_tag # 课程-标签关联表
│ └── tb_course_dept # 课程-部门权限表
├── createTableLearning.sql # [6] 学习管理模块
│ ├── tb_learning_task # 学习任务表
│ ├── tb_task_resource # 任务-资源关联表
│ ├── tb_task_course # 任务-课程关联表
│ ├── tb_task_user # 任务-用户表
│ ├── tb_learning_record # 学习记录表
│ └── tb_learning_statistics # 学习统计表
├── createTableUserCenter.sql # [7] 个人中心模块
│ ├── tb_user_collection # 用户收藏表
│ ├── tb_achievement # 成就表
│ ├── tb_user_achievement # 用户-成就关联表
│ ├── tb_user_points # 用户积分表
│ ├── tb_points_record # 积分记录表
│ └── tb_user_browse_record # 用户浏览记录表
├── createTableAI.sql # [8] 智能体模块
│ ├── tb_ai_agent_config # 智能体配置表
│ ├── tb_ai_knowledge # 知识库表
│ ├── tb_ai_conversation # 对话会话表
│ ├── tb_ai_message # 对话消息表
│ ├── tb_ai_upload_file # 上传文件表
│ └── tb_ai_usage_statistics # AI使用统计表
├── createTableSystem.sql # [9] 系统管理模块
│ ├── tb_sys_operation_log # 操作日志表
│ ├── tb_sys_config # 系统配置表
│ ├── tb_sys_visit_statistics # 访问统计表
│ ├── tb_sys_notification # 系统通知表
│ ├── tb_sys_file # 文件上传记录表
│ ├── tb_sys_dict_type # 数据字典类型表
│ └── tb_sys_dict_data # 数据字典详情表
├── initAll.sql # 一键执行所有SQL
├── README.md # 表结构详细说明
├── 表结构汇总.md # 表结构汇总
└── ER关系图.md # 表关系图
```
## 🚀 快速开始
### 第一次使用
1. **阅读使用说明**
```
打开 使用说明.md
```
2. **执行初始化脚本**
**Windows:**
```cmd
双击 init-database.bat
```
**Linux/Mac:**
```bash
chmod +x init-database.sh
./init-database.sh
```
3. **验证安装**
```sql
USE school_news;
SHOW TABLES;
```
### 了解表结构
1. **快速查看**:阅读 `sql/表结构汇总.md`
2. **详细了解**:阅读 `sql/README.md`
3. **理解关系**:阅读 `sql/ER关系图.md`
## 📊 模块说明
### 1⃣ 用户管理模块
负责用户账号、用户信息和登录日志管理。
**核心表**:
- tb_sys_user (用户表)
- tb_sys_user_info (用户信息表)
### 2⃣ 权限管理模块
实现RBAC权限控制支持部门、角色、权限、菜单管理。
**核心表**:
- tb_sys_dept (部门表)
- tb_sys_role (角色表)
- tb_sys_permission (权限表)
### 3⃣ 资源管理模块
管理新闻资源、分类、标签、推荐和数据采集。
**核心表**:
- tb_resource (资源表)
- tb_resource_category (资源分类表)
- tb_banner (Banner表)
### 4⃣ 课程管理模块
管理在线课程、章节、标签和权限。
**核心表**:
- tb_course (课程表)
- tb_course_chapter (章节表)
### 5⃣ 学习管理模块
管理学习任务、学习记录和统计数据。
**核心表**:
- tb_learning_task (学习任务表)
- tb_learning_record (学习记录表)
- tb_learning_statistics (学习统计表)
### 6⃣ 个人中心模块
管理用户收藏、成就、积分和浏览记录。
**核心表**:
- tb_user_collection (收藏表)
- tb_achievement (成就表)
- tb_user_points (积分表)
### 7⃣ 智能体模块
提供AI对话、知识库和文件问答功能。
**核心表**:
- tb_ai_agent_config (AI配置表)
- tb_ai_knowledge (知识库表)
- tb_ai_conversation (对话会话表)
### 8⃣ 系统管理模块
管理系统配置、日志、通知和文件。
**核心表**:
- tb_sys_config (系统配置表)
- tb_sys_operation_log (操作日志表)
- tb_sys_notification (通知表)
## 📈 数据量预估
| 模块 | 预估数据量 | 增长速度 |
|------|-----------|----------|
| 用户管理 | 1万-10万 | 缓慢 |
| 权限管理 | 100-1000 | 缓慢 |
| 资源管理 | 1万-100万 | 中等 |
| 课程管理 | 100-10000 | 缓慢 |
| 学习管理 | 10万-1000万 | 快速 |
| 个人中心 | 10万-1000万 | 中等 |
| 智能体 | 10万-1000万 | 快速 |
| 系统管理 | 100万-1亿 | 快速 |
## 🔧 维护建议
### 日常维护
- 每天备份数据库
- 每周清理过期日志
- 每月统计表分析
### 性能优化
- 定期执行 ANALYZE TABLE
- 监控慢查询日志
- 适时添加索引
### 数据归档
- 登录日志保留3个月
- 操作日志保留6个月
- 学习记录:永久保存
- 浏览记录保留1年
## 📝 版本信息
- **版本**: v1.0.0
- **发布日期**: 2025-10-15
- **数据库**: MySQL 5.7+
- **字符集**: utf8mb4
- **引擎**: InnoDB
## 🔗 相关链接
- [MySQL官方文档](https://dev.mysql.com/doc/)
- [数据库设计规范](https://www.cnblogs.com/huchong/p/10219318.html)
- [SQL优化指南](https://developer.aliyun.com/article/72501)
## 📞 技术支持
如有问题,请检查:
1. MySQL版本 >= 5.7
2. 字符集为 utf8mb4
3. 存储引擎为 InnoDB
4. 是否有足够的磁盘空间
## ⚠️ 注意事项
1. **首次运行**前,请备份现有数据库
2. **生产环境**使用前,请修改默认密码
3. **定期备份**数据,防止数据丢失
4. **性能监控**,及时发现并解决问题
5. **安全加固**,限制数据库访问权限
## 📅 更新计划
- [ ] 添加数据字典详细说明
- [ ] 补充性能测试报告
- [ ] 增加示例数据脚本
- [ ] 提供Docker部署方案
- [ ] 添加自动化测试用例