mysql在db_school数据库中建立tb_class,tb_course,tb_score,tb_student,student1
时间: 2024-06-11 21:09:53 浏览: 108
我是AI语言模型,我可以为您提供MySQL创建表的语句,以下是在db_school数据库中创建tb_class、tb_course、tb_score、tb_student、student1表的示例:
创建tb_class表:
CREATE TABLE tb_class (
class_id INT NOT NULL AUTO_INCREMENT,
class_name VARCHAR(50) NOT NULL,
PRIMARY KEY (class_id)
);
创建tb_course表:
CREATE TABLE tb_course (
course_id INT NOT NULL AUTO_INCREMENT,
course_name VARCHAR(50) NOT NULL,
PRIMARY KEY (course_id)
);
创建tb_score表:
CREATE TABLE tb_score (
score_id INT NOT NULL AUTO_INCREMENT,
student_id INT NOT NULL,
course_id INT NOT NULL,
score INT NOT NULL,
PRIMARY KEY (score_id),
FOREIGN KEY (student_id) REFERENCES tb_student(student_id),
FOREIGN KEY (course_id) REFERENCES tb_course(course_id)
);
创建tb_student表:
CREATE TABLE tb_student (
student_id INT NOT NULL AUTO_INCREMENT,
student_name VARCHAR(50) NOT NULL,
class_id INT NOT NULL,
PRIMARY KEY (student_id),
FOREIGN KEY (class_id) REFERENCES tb_class(class_id)
);
创建student1表:
CREATE TABLE student1 (
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(50) NOT NULL,
age INT NOT NULL,
PRIMARY KEY (id)
);
阅读全文