7.7 KiB
7.7 KiB
校园思政新闻平台 - 数据库表结构汇总
一、用户管理模块(3张表)
| 表名 | 中文名 | 说明 | 主要字段 |
|---|---|---|---|
| tb_sys_user | 用户表 | 存储用户账号信息 | id, username, password, email, phone, status |
| tb_sys_user_info | 用户信息表 | 存储用户详细信息 | id, user_id, avatar, full_name, gender, address |
| tb_sys_login_log | 登录日志表 | 记录用户登录历史 | id, user_id, ip_address, login_time, status |
二、权限管理模块(8张表)
| 表名 | 中文名 | 说明 | 主要字段 |
|---|---|---|---|
| tb_sys_dept | 部门表 | 组织架构 | id, dept_id, name, parent_id, description |
| tb_sys_role | 角色表 | 系统角色 | id, role_id, name, description |
| tb_sys_dept_role | 部门-角色关联表 | 部门与角色关系 | id, dept_id, role_id |
| tb_sys_user_dept_role | 用户-部门-角色关联表 | 用户在部门中的角色 | id, user_id, dept_id, role_id |
| tb_sys_permission | 权限表 | 系统权限定义 | id, permission_id, name, code, description |
| tb_sys_role_permission | 角色-权限关联表 | 角色拥有的权限 | id, role_id, permission_id |
| tb_sys_menu | 菜单表 | 系统菜单 | id, menu_id, name, parent_id, url, type |
| tb_sys_menu_permission | 菜单-权限关联表 | 菜单访问权限 | id, menu_id, permission_id |
三、资源管理模块(8张表)
| 表名 | 中文名 | 说明 | 主要字段 |
|---|---|---|---|
| tb_resource | 资源表 | 新闻/文章资源 | id, title, content, category_id, view_count, status |
| tb_resource_category | 资源分类表 | 资源分类(党史学习等6类) | id, category_id, name, parent_id, order_num |
| tb_banner | Banner表 | 轮播图管理 | id, title, image_url, link_type, link_id, order_num |
| tb_resource_recommend | 资源推荐表 | TOP资源推荐 | id, resource_id, order_num, reason |
| tb_tag | 标签表 | 数据标签 | id, tag_id, name, color, description |
| tb_resource_tag | 资源-标签关联表 | 资源标签关系 | id, resource_id, tag_id |
| tb_data_collection_config | 数据采集配置表 | 数据采集源配置 | id, name, source_url, frequency, status |
| tb_data_collection_log | 数据采集记录表 | 采集日志 | id, config_id, collect_count, status, collect_time |
四、课程管理模块(4张表)
| 表名 | 中文名 | 说明 | 主要字段 |
|---|---|---|---|
| tb_course | 课程表 | 课程信息 | id, course_id, name, description, teacher, status |
| tb_course_chapter | 课程章节表 | 课程章节内容 | id, course_id, name, content, video_url, order_num |
| tb_course_tag | 课程-标签关联表 | 课程标签关系 | id, course_id, tag_id |
| tb_course_dept | 课程-部门权限表 | 课程访问权限 | id, course_id, dept_id |
五、学习管理模块(6张表)
| 表名 | 中文名 | 说明 | 主要字段 |
|---|---|---|---|
| tb_learning_task | 学习任务表 | 学习计划/任务 | id, task_id, name, description, start_time, end_time |
| tb_task_resource | 任务-资源关联表 | 任务关联的资源 | id, task_id, resource_id, required |
| tb_task_course | 任务-课程关联表 | 任务关联的课程 | id, task_id, course_id, required |
| tb_task_user | 任务-用户表 | 任务接收人员及完成情况 | id, task_id, user_id, status, progress |
| tb_learning_record | 学习记录表 | 详细学习记录 | id, user_id, resource_type, resource_id, duration |
| tb_learning_statistics | 学习统计表 | 按天统计学习数据 | id, user_id, stat_date, total_duration, resource_count |
六、个人中心模块(6张表)
| 表名 | 中文名 | 说明 | 主要字段 |
|---|---|---|---|
| tb_user_collection | 用户收藏表 | 收藏的资源/课程 | id, user_id, collection_type, collection_id |
| tb_achievement | 成就表 | 勋章/等级定义 | id, achievement_id, name, type, condition_type |
| tb_user_achievement | 用户-成就关联表 | 用户获得的成就 | id, user_id, achievement_id, obtain_time |
| tb_user_points | 用户积分表 | 用户积分和等级 | id, user_id, total_points, current_points, level |
| tb_points_record | 积分记录表 | 积分变动记录 | id, user_id, points, type, source_type |
| tb_user_browse_record | 用户浏览记录表 | 浏览历史 | id, user_id, browse_type, browse_id, browse_time |
七、智能体模块(6张表)
| 表名 | 中文名 | 说明 | 主要字段 |
|---|---|---|---|
| tb_ai_agent_config | 智能体配置表 | AI助手配置 | id, name, system_prompt, model_name, temperature |
| tb_ai_knowledge | 知识库表 | AI知识库内容 | id, title, content, source_type, category |
| tb_ai_conversation | 对话会话表 | 对话会话 | id, user_id, title, status, message_count |
| tb_ai_message | 对话消息表 | 对话消息记录 | id, conversation_id, role, content, token_count |
| tb_ai_upload_file | 上传文件表 | 用户上传的文件 | id, user_id, file_name, file_path, extracted_text |
| tb_ai_usage_statistics | AI使用统计表 | AI使用数据统计 | id, user_id, stat_date, conversation_count, total_tokens |
八、系统管理模块(8张表)
| 表名 | 中文名 | 说明 | 主要字段 |
|---|---|---|---|
| tb_sys_operation_log | 操作日志表 | 用户操作记录 | id, user_id, module, operation, status, create_time |
| tb_sys_config | 系统配置表 | 系统参数配置 | id, config_key, config_value, config_type, config_group |
| tb_sys_visit_statistics | 访问统计表 | 系统访问数据 | id, stat_date, total_visits, active_users |
| tb_sys_notification | 系统通知表 | 用户通知消息 | id, user_id, type, title, content, is_read |
| tb_sys_file | 文件上传记录表 | 文件管理 | id, file_name, file_path, file_size, module |
| tb_sys_dict_type | 数据字典类型表 | 字典类型定义 | id, dict_type, dict_name, description |
| tb_sys_dict_data | 数据字典详情表 | 字典数据项 | id, dict_type, dict_label, dict_value, dict_sort |
数据库统计
- 总表数: 49张表
- 用户管理: 3张表
- 权限管理: 8张表
- 资源管理: 8张表
- 课程管理: 4张表
- 学习管理: 6张表
- 个人中心: 6张表
- 智能体: 6张表
- 系统管理: 8张表
表命名规范
- 系统表前缀:
tb_sys_ - 资源相关:
tb_resource_ - 课程相关:
tb_course_ - 学习相关:
tb_learning_或tb_task_ - 用户相关:
tb_user_ - AI相关:
tb_ai_ - 其他业务表:
tb_+ 业务名
关联关系类型
- 1对1: 用户↔用户信息、用户↔积分
- 1对多: 部门↔子部门、课程↔章节、会话↔消息
- 多对多: 用户↔角色、资源↔标签、任务↔资源/课程
数据存储容量评估
| 表类型 | 预估数据量 | 存储策略 |
|---|---|---|
| 用户表 | 1万-10万 | 长期保存 |
| 资源表 | 1万-100万 | 长期保存 |
| 课程表 | 100-10000 | 长期保存 |
| 学习记录 | 10万-1000万 | 按年归档 |
| 日志表 | 100万-1亿 | 按月归档 |
| 浏览记录 | 100万-1亿 | 按季度归档 |
| 对话消息 | 10万-1000万 | 按年归档 |
性能优化建议
-
索引优化:
- 所有外键字段建立索引
- 常用查询条件字段建立索引
- 时间范围查询建立时间索引
-
分表策略:
- 日志表按月分表
- 记录表按年分表
- 统计表按天/月预聚合
-
缓存策略:
- 系统配置使用Redis缓存
- 热门资源使用缓存
- 用户权限信息缓存
-
查询优化:
- 避免全表扫描
- 使用分页查询
- 适当使用冗余字段减少JOIN
-
数据归档:
- 定期归档历史日志
- 清理过期的浏览记录
- 备份重要业务数据