mysql
2021/4/27 19:29:15
本文主要是介绍mysql,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
create table if not exists Student
(StuID char(8),
StuName varchar(10),
StuSex char(2),
StuBirthday date,
Native varchar(20) comment ‘籍贯’,
National char(6) comment ‘民族’,
Telephone char(11),
ClassID char(10)
);
create table Course
(CourseID char(8),
CourseName varchar(25),
CourseNature char(10) comment ‘课程性质’,
Credit tinyint(1) comment ‘学分’,
CourseRemark text comment ‘备注’
)
engine=innodb
default character set utf8
default collate utf8_general_ci;
CREATE TABLE class(
ClassID char(10) NOT NULL,
ClassName varchar(20) DEFAULT NULL,
Num int(11) DEFAULT NULL,
TeacherID char(10) DEFAULT NULL,
MajorID char(8) DEFAULT NULL,
PRIMARY KEY (ClassID)
);
create table Teacher
(TeacherID char(10),
TeacherName varchar(8),
TeacherSex char(2) default ‘女’,
TeacherBirthday date,
Telephone char(11),
DepartmentID char(8)
);
create table Department
(DepartmentID char(8),
primary key(DepartmentID),
DepartmentName varchar(20)
);
create table Score
(StuID char(8),
CourseID char(8),
ExamScore int,
PartScore int,
primary key(StuID,CourseID)
);
create table Major
(MajorID char(8) primary key,
MajorName varchar(20) unique,
DepartmentID char(8)
);
create table Classroom
(ClassroomID varchar(10) primary key,
ClassroomType varchar(20) not null,
PersonNumber int,
Place varchar(20)
);
create table RollCall
(StuID char(8),
CourseID char(8),
AttendNumber int check(AttendNumber>=0),
AbsenceNumber int check(AbsenceNumber>=0),
LateNumber int check(LateNumber>=0),
primary key(StuID,CourseID)
);
alter table class add primary key(ClassID);
alter table course add primary key(CourseID);
alter table classroom add primary key(ClassroomID);
create table TeachingCourse
(ClassID char(10),
CourseID char(8),
ClassroomID varchar(10),
TeacherID char(10),
WeekDay char(3) not null,
Part tinyint not null,
foreign key(ClassID) references class(ClassID),
foreign key(CourseID) references course(CourseID),
foreign key(ClassroomID) references classroom(ClassroomID),
foreign key(TeacherID) references teacher(TeacherID)
);
这篇关于mysql的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-20部署MySQL集群入门:新手必读指南
- 2024-11-20部署MySQL集群教程:初学者指南
- 2024-11-20部署MySQL集群项目实战:新手教程
- 2024-11-20部署MySQL集群资料:新手入门教程
- 2024-11-20MySQL集群部署教程:入门级详解
- 2024-11-20MySQL集群教程:入门与实践指南
- 2024-11-20部署MySQL集群教程:新手入门指南
- 2024-11-20MySQL读写分离教程:轻松入门
- 2024-11-20部署MySQL集群入门:一步一步搭建你的数据库集群
- 2024-11-19部署MySQL集群学习:入门教程