📄 jimmy.txt
字号:
cuDay int not null, --每周使用的日期
cuTime int not null, --使用的时段
cuRemark text default '' --备注
)
go
----学生基本信息表 StudentInfo
学生编号 姓名 性别 籍贯 民族 联系电话 地址
stuID stuName stuSex stuOrigin stuNation stuTelephone stuAddress
邮编 一期 二期 三期 是否在校 备注
stuPostcode stuGrade1 stuGrade2 stuGrade3 stuAt_School stuRemark
注释: 班级信息里规定了共有9个班和他们相应的人数, 但这里面同一个人可能连续上了多个班,
所以这里填入的信息数量不一定就是所有班级的总人数,但注意数据真实性
一期 二期 三期 :存放所参加的班级编号,默认为模拟班级(也就是说没有上到该期)
外键引用班级信息表的班级编号,该数据一定要具有真实性,
与前面的班机信息表相对应,
备注中可存放该学生在校期间所获奖励或者所受处分等事件,须注明具体班级、日期及事件简介,其实这应该
也单独放在一张表中,但鉴于此内容极少,算了吧,想一想杨宇也是人啊……
这个表添加完数据后,再返回头修改班机信息表,补充上班长编号
--插入一条公共学生信息,其本身并不存在,作为必要时的默认值是用
insert studentinfo values('北大青鸟',0,'北京市','中华民族','13800000000','北京市西城区复兴门','100000',default,default,default,1,'模拟学生')
----------------------创建学生基本信息表---------------------------
if exists(select * from sysobjects where name = 'StudentInfo')
drop table StudentInfo
go
Create table StudentInfo
(
stuID int identity(10001,1) primary key, --学生编号
stuName varchar(20) not null, --姓名
stuSex bit not null, --性别,0:男 1:女
stuOrigin varchar(20) default '', --籍贯
stuNation varchar(20) default '', --民族
stuTelephone varchar(20) default ''
constraint Check_stuTelephone check(stuTelephone like
'[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
or stuTelephone like
'[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
or stuTelephone like
'[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
or stuTelephone like
'[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'),--联系电话
stuAddress text default '', --地址
stuPostcode varchar(10)
constraint Check_stuPostcode check(stuPostcode like
'[0-9][0-9][0-9][0-9][0-9][0-9]') default '000000', --邮政编码
stuGrade1 varchar(10) default '0000' constraint FK_StudentInfo_stuGrade1
foreign key(stuGrade1) references ClassInfo(claID), --一期班级编号
stuGrade2 varchar(10) default '0000' constraint FK_StudentInfo_stuGrade2
foreign key(stuGrade2) references ClassInfo(claID), --二期班级编号
stuGrade3 varchar(10) default '0000' constraint FK_StudentInfo_stuGrade3
foreign key(stuGrade3) references ClassInfo(claID), --三期班级编号
stuAt_School bit not null default 1, --是否在校 0:已毕业或离校 1:在校学习(默认)
stuRemark text default '' --备注
)
go
----学生结业成绩信息表(针对某个学生某一个学期的期末考试) StudentFSInfo
学生编号 班级编号 期末笔试 期末机试 笔试补考次数 机试补考次数 备注
stuID claID PaperScore ComputerScore PaperMakeupNumber ComputerMakeupNumber Remark
注释: 这里填入的信息数量就是已经结业的班级的人数总和,因为每个班每个人都绘有一条记录
根据前一个表的相应数据填写!!!没有结业的班级,不必填写
学生编号和班级编号作为联合主键 ,确定某一个学生在某一个学期的情况
---------------------------创建学生结业成绩信息表--------------------
if exists(select * from sysobjects where name = 'StudentFSInfo')
drop table StudentFSInfo
go
Create table StudentFSInfo -- FS: Final Score 期末成绩
(
stuID int constraint FK_StudentFSInfo_stuID
foreign key(stuID) references StudentInfo(stuID),--学生编号
claID varchar(10) constraint FK_StudentFSInfo_claID
foreign key(claID) references ClassInfo(claID)
primary key(stuID,claID), --班级编号
PaperScore float default 0, --笔试成绩
ComputerScore float default 0, --上机成绩
PaperMakeupNumber int default 0, --笔试补考次数
ComputerMakeupNumber int default 0, --机试补考次数
Remark text default '' --备注
)
go
-------学生缺勤信息表 StudentAFDInfo
编号 学生编号 班级编号 缺勤日期 缺勤类型 缺勤课时 备注
afdID stuID claID afdDate Type Hours Remark
注释: 填入30条记录,要求9个班必须都有涉及,每种缺勤类型也都有所涉及
注意缺勤日期,一定要在该班的开学和结业日期之间!!!注意真实性
缺勤类型:0:迟到 1:早退 2:旷课 3:请假
缺勤日期必填且无默认值,设计软件时注意
如果缺勤类型为2、3,则应填写缺勤课时,否则按默认值0填写
备注可以填写请假原因等等
--------------------------------创建学生缺勤信息表-------------------------------------
if exists(select * from sysobjects where name = 'StudentAFDInfo')
drop table StudentAFDInfo
go
Create table StudentAFDInfo -- AFD: Absence From Duty 缺勤
(
afdID int identity(1,1) primary key, --编号
stuID int constraint FK_StudentAFDInfo_stuID
foreign key(stuID) references StudentInfo(stuID),--学生编号
claID varchar(10) constraint FK_StudentAFDInfo_claID
foreign key(claID) references ClassInfo(claID), --班级编号
afdDate smallDatetime not null, --缺勤日期
Type int not null, --缺勤类型
--0:迟到 1:早退 2:旷课 3:请假
Hours int not null default 0, --旷课或者请假的课时
Remark text default '' --备注
)
go
-----班级考试信息表 ClassExamInfo
考试编号 班级编号 任课教师编号 考试形式 考试日期
examID claID teaID Type examDate
通过率 平均分 最高分 最低分 备注
Pass Average MaxScore MinScore Remark
注释: 用来储存学校曾经举办的所有考试(除期末结业考试之外)的信息
填入5条数据,9个班,挑选其中的4个班考5次试
考试日期一定要在该班的开学和结业日期之间!
任课教师编号允许不填(默认为空),当考试为综合考试、涉及知识面不是单一老师所授时
考试形式:0:笔试 1:机试
通过率为一个0——100范围内的整数,代表全班通过人数的百分比(例:全部通过则可写入100)
最高分、最低分直接储存分数,而不是得到该分数的学生的编号,
设计软件时注意,这里没有对分数添加检查约束,需要在软件中添加相应操作
备注中可以写入考试科目、范围说明
---------------------------创建班级考试信息表-------------------------------
if exists(select * from sysobjects where name = 'ClassExamInfo')
drop table ClassExamInfo
go
Create table ClassExamInfo
(
examID int identity(1,1) primary key, --考试编号
claID varchar(10) not null constraint FK_ClassExamInfo_claID
foreign key(claID) references ClassInfo(claID), --班级编号
teaID int default 10000 constraint FK_ClassExamInfo_teaID
foreign key(teaID) references TeacherInfo(teaID), --任课教师编号
Type bit not null, --考试形式 0:笔试 1:机试
examDate smalldatetime not null, --考试日期
NotAttend int not null, --未参加考试人数
Pass int not null, --通过率
Average float not null, --平均分
MaxScore float not null, --最高分
MinScore float not null, --最低分
Remark text default '', --备注
)
go
---------学生考试信息表 (针对某个班级的某个学生的除结业考试之外的平时测验) StudentExamInfo
学生编号 班级编号 考试编号 成绩 备注
stuID claID examID Score Remark
注释: 根据前一个表的数据,把相对应的班级的所有学生的考分填入,
应该有一部分缺考的学生,他们相应的考分就定为0,但不能没有
学生编号和班级编号作为联合主键
---------------------------创建学生考试信息表--------------------------------------
if exists(select * from sysobjects where name = 'StudentExamInfo')
drop table StudentExamInfo
go
Create table StudentExamInfo
(
stuID int constraint FK_StudentExamInfo_stuID
foreign key(stuID) references StudentInfo(stuID), --学生编号
claID varchar(10) constraint FK_StudentExamInfo_claID
foreign key(claID) references ClassInfo(claID), --班级编号
examID int not null constraint FK_StudentExamInfo_examID
foreign key(examID) references ClassExamInfo(examID)
primary key(stuID,examID), --考试编号
Score float not null, --考试成绩
Remark text default '' --备注
)
go
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -