要求教师表、课程表和选课表用SQL语句实现
时间: 2023-12-30 17:03:33 浏览: 76
好的,以下是教师表、课程表和选课表的SQL语句实现:
1. 教师表
```
CREATE TABLE teacher (
teacher_id INT PRIMARY KEY,
teacher_name VARCHAR(50) NOT NULL,
teacher_gender ENUM('male', 'female') NOT NULL,
teacher_age INT NOT NULL,
teacher_phone VARCHAR(20) NOT NULL
);
```
2. 课程表
```
CREATE TABLE course (
course_id INT PRIMARY KEY,
course_name VARCHAR(50) NOT NULL,
course_teacher_id INT NOT NULL,
FOREIGN KEY (course_teacher_id) REFERENCES teacher (teacher_id)
);
```
3. 选课表
```
CREATE TABLE student_course (
student_id INT NOT NULL,
course_id INT NOT NULL,
PRIMARY KEY (student_id, course_id),
FOREIGN KEY (student_id) REFERENCES student (student_id),
FOREIGN KEY (course_id) REFERENCES course (course_id)
);
```
以上是教师表、课程表和选课表的SQL语句实现,如果您有其他问题,欢迎继续提问。
阅读全文