Files
Nexus_Edu/database/README.md
2025-11-28 19:23:19 +08:00

63 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

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.

# 数据库脚本使用说明
## 文件说明
- `schema.sql` - 完整建表语句11张表
- `seed.sql` - 初始化示例数据
- `drop.sql` - 清理所有表(危险!仅开发用)
## 使用步骤
### 1. 创建数据库
```sql
CREATE DATABASE edunexus CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE edunexus;
```
### 2. 执行建表脚本
```bash
mysql -u root -p edunexus < schema.sql
```
或在MySQL客户端中
```sql
SOURCE schema.sql;
```
### 3. 插入示例数据(可选)
```bash
mysql -u root -p edunexus < seed.sql
```
### 4. 清理数据(仅开发)
```bash
mysql -u root -p edunexus < drop.sql
```
## 表结构概览
| 模块 | 表名 | 说明 |
|------|------|------|
| 身份 | application_users | 用户账号 |
| 组织 | schools, grades, classes, class_members | 学校组织架构 |
| 教材 | subjects, textbooks, textbook_units, textbook_lessons, knowledge_points | 教材知识体系 |
| 题库 | questions, question_knowledge | 题目库和知识点关联 |
| 试卷 | exams, exam_nodes | 试卷和题目节点(树形) |
| 作业 | assignments, student_submissions, submission_details | 作业发布和提交 |
## 重要说明
- 所有表都包含审计字段created_at, created_by等
- 使用UUID作为主键VARCHAR(36)
- 支持软删除is_deleted字段
- exam_nodes表支持无限层级嵌套
- 密码使用bcrypt hash存储
## 下一步
数据库创建完成后请使用后端API服务连接数据库。