使用SQL命令或是可视化操作界面创建教学管理系统中的4张基本表,表名分别为学生表、教师表、课程表、教学表。
时间: 2024-10-01 19:13:05 浏览: 44
创建这四个基本表格的SQL命令示例如下:
1. 学生表 (students)
```sql
CREATE TABLE students (
id INT PRIMARY KEY,
name VARCHAR(100),
age INT,
gender CHAR(1),
class_id INT,
FOREIGN KEY (class_id) REFERENCES classes(id)
);
```
2. 教师表 (teachers)
```sql
CREATE TABLE teachers (
id INT PRIMARY KEY,
name VARCHAR(100),
position VARCHAR(50),
department VARCHAR(50),
FOREIGN KEY (class_id) REFERENCES classes(id)
);
```
3. 课程表 (courses)
```sql
CREATE TABLE courses (
id INT PRIMARY KEY,
course_name VARCHAR(100),
description TEXT,
teacher_id INT,
FOREIGN KEY (teacher_id) REFERENCES teachers(id)
);
```
4. 教学表 (teaching)
```sql
CREATE TABLE teaching (
id INT PRIMARY KEY,
student_id INT,
course_id INT,
start_date DATE,
end_date DATE,
FOREIGN KEY (student_id) REFERENCES students(id),
FOREIGN KEY (course_id) REFERENCES courses(id)
);
```
以上命令假设每个课程有一个教师,学生可以选择参加课程,教学表记录了学生选课的具体信息。
阅读全文