数据库课程设计报告《驾校管理系统》内含详细的sql语句及运行截图Word文档格式.docx
《数据库课程设计报告《驾校管理系统》内含详细的sql语句及运行截图Word文档格式.docx》由会员分享,可在线阅读,更多相关《数据库课程设计报告《驾校管理系统》内含详细的sql语句及运行截图Word文档格式.docx(25页珍藏版)》请在冰豆网上搜索。
![数据库课程设计报告《驾校管理系统》内含详细的sql语句及运行截图Word文档格式.docx](https://file1.bdocx.com/fileroot1/2023-1/30/20c6ca10-8535-4eb5-888c-704f0f5b7610/20c6ca10-8535-4eb5-888c-704f0f5b76101.gif)
在winform中实现学员的照片显示。
6)数据统计:
在数据库中编写相应的存储过程,输入教练编号即可select其所带学员人数。
(3)有何安全性与完整性方面的要求(参照所给出的语义规则)。
如是否需要显示定
义原子事务、需定义具有什么功能的存储过程、需定义具有什么功能的触发器、对不同
的用户有何不同的系统使用权限等。
1)安全性约束:
“性别”(int)取值范围为[0,1];
“是否色盲”(tinyint)取值范围为[0,1];
“是否通过全部考试”(success)取值范围为[0,1];
“计划学习/教学日”(tinyint)取值范围为[0,1];
“考试内容”(smallint)取值范围为[0,3];
“是否参加考试”(attend)取值范围为[0,1];
“是否通过考试”(access)取值范围为[0,1];
“出生年月”(datetime)<
getdate();
“身高”(smallint)取值范围为[0,300];
“体重”(smallint)取值范围为[0,300];
“左眼视力”(real)取值范围为[0,6.0];
“右眼视力”(real)取值范围为[0,6.0]。
2)存储过程:
①以学员编号为输入参数查询学员基本信息。
②以教练员编号为输入参数统计正在跟随该教练员学习的学员人数并输出。
3)触发器:
①当“学生考试信息表”中的补考次数大于2时,触发事件,级联更新“学员基本信息”中的学费,使学费增加10%。
②当“学生考试信息”表中的“是否参与/通过考试”信息被修改时,触发事件自动生成一行新的考试信息,其中规定:
1、报名完成后1个月考理论,理论考试通过1个月后考倒桩,倒桩考试通过半个月后考小路,小路考试通过半个月后考大路,如果其中某次考试未通过,补考均安排在1个月后;
2、当大路考试通过后,不再生成新的考试信息,同时级联更新“学员基本信息”表中的“顺利结业”情况。
二、概念结构设计
画出系统整体的E-R模型;
并对模型中所出现的实体及属性等信息加以说明。
1)学员基本信息:
学员编号sno、姓名sname、身份证号sidno、性别ssex、出生年月sbirth、身高stature、体重sweight、左眼视力lefteye、右眼视力righteye、是否色盲colorbind、家庭住址saddr、工作单位scomp、教练员tno、学习费用sfee、照片sphoto,是否已通过全部考试success(加:
联系方式scall,计划学习日期(工作日/周末)sday),报名时间(enterday),其中学员编号为主键。
2)教练员基本信息:
教练编号tno、姓名tname、身份证号tidno、性别tsex、出生年月tbirth(加:
联系方式tcall,计划教学日期(工作日/周末)tday),其中教练员编号为主键。
3)学员考试信息:
学员编号sno、考试日期examday、考试内容(理论、倒桩、小路、大路)examinfo、补考次数bkcs、是否参加考试attend、是否通过access。
其中学员编号、考试内容、补考次数共同作为主键。
4)学员教练:
学员编号sno、教练编号tno
三、逻辑结构设计
(1)模式设计:
按系统整体E-R模型,写出关系模式;
并利用数据字典加以描述。
(如每个关系模式有何属性、属性的类型、属性值的长度、是否可取空值、是否为主码、
有何约束条件等信息)
(2)子模式设计:
即针对自己的设计模块的应用需定义什么样的视图表结构;
并
利用数据字典加以描述。
(如每个关系子模式有何属性、属性的类型、属性值的长度、是否可取空值、是否为主
码、有何约束条件等信息)
学员基本信息student表
字段名
数据类型
是否主键
是否为空
约束条件
默认值
描述
sno
char(8)
是
否
学员编号
tno
教练编号
sname
varchar(10)
姓名
sidno
char(18)
身份证号
ssex
tinyint
性别
sbirth
datetime
出生年月
stature
smallint
身高
sweight
体重
lefteye
real
左眼视力
righteye
右眼视力
colorbind
是否色盲
saddr
varchar(40)
家庭住址
scomp
工作单位
sfee
int
4500
学习费用
sphoto
nvarchar(100)
照片
success
是否顺利结业
scall
char(11)
联系方式
sday
计划学习日期
enterday
报名时间
教练基本信息teacher表
tname
tidno
tsex
tbirth
tcall
tday
计划教学日期
学员教练关系stte表
Tno
Char(8)
Char(8)
否
学员考试信息exam表
Examday
Datetime
考试日期
Examinfo
考试内容
Bkcs
Smallint
补考次数
Sno
Attend
Tinyint
是否参加考试
Access
是否通过
四、数据库的物理设计
为了提高在表中搜索元组的速度,在实际实现的时候应该基于某些属性建立索引。
给出
所建立的索引。
(包括按哪些表中哪些属性按升序还是降序来创建索引及相应的T-SQL的创建语句)。
exam表建立了三个索引:
CREATEINDEXsyexam_examdayONexam
(examdayASC)
CREATEINDEXsyexam_examinfoONexam
(examinfoASC)
CREATEINDEXsyexam_snoONexam
(snoASC)
stte表建立了两个索引:
CREATEINDEXsystte_snoONstte
CREATEINDEXsystte_tnoONstte
(tnoASC)
Student表建立了三个索引:
CREATEINDEXsystudent_enterdayONstudent
(enterdayASC)
CREATEINDEXsystudent_snameONstudent
(snameASC)
CREATEINDEXsystudent_snoONstudent
五、数据库设计实现及运行
(1)数据库的创建
T-SQL语句:
/*========================================*/
/*DBMSname:
MicrosoftSQLServer2005*/
/*Createdon:
2012/1/48:
57:
37*/
ifexists(select1
fromsysobjects
whereid=object_id('
"
CLRTrigger_student"
'
)
andtype='
TR'
droptrigger"
go
td_student'
droptriggertd_student
ti_student'
droptriggerti_student
tu_student'
droptriggertu_student
CLRTrigger_stte"
td_stte'
droptriggertd_stte
ti_stte'
droptriggerti_stte
tu_stte'
droptriggertu_stte
exam'
U'
droptableexam
student'
droptablestudent
teacher'
droptableteacher
stte'
droptablestte
(2)数据表的创建(可同时在创建时定义相关的约束)
createtableexam(
examdaydatetimenull,
examinfosmallintnotnull,
bkcssmallintnotnull,
snochar(8)notnull,
attendtinyintnull,
accesstinyintnull,
constraintPK_EXAMprimarykeynonclustered(examinfo,bkcs,sno)
createtablestudent(
tnochar(8)notnull,
snamevarchar(10)null,
sidnochar(18)null,
ssextinyintnull,
sbirthdatetimenull,
staturesmallintnull,
sweightsmallintnull,
lefteyerealnull,
righteyerealnull,
colorbindtinyintnull,
saddrvarchar(40)null,
scompvarchar(40)null,
sfeeintnull,
sphotonvarchar(100)null,
successtinyintnull,
scallchar(11)null,
sdaytinyintnull,
constraintPK_STUDENTprimarykeynonclustered(sno)
createtableteacher(
tnamevarchar(10)null,
tidnochar(18)null,
tsextinyintnull,
tbirthdatetimenull,
tcallchar(11)null,
tdaytinyintnull,
constraintPK_TEACHERprimarykeynonclustered(tno)
createtablestte(
tnochar(8)null,
constraintPK_stteprimarykeynonclustered(sno)
(3)存储过程的定义实现(仅需给出自己设计模块中所用的)
1、计算教练员所带学员数量的procsr_teacher
Createprocsr_teacher
@@tnochar(8),@@scountintoutput
as
begin
select@@scount=count(sno)
fromstte
wherestte.tno=@@tno
end
测试结果粘贴:
2、根据学员学号返回学员全部信息的procsrstudent
Createprocsrstudent
@@snochar(8)
select*fromstudents
wheres.sno=@@sno
3、根据学员学号返回学员部分信息的procrsname等(在进行修改操作时需要调用)
Createprocrsname
@@snochar(8),@@snamevarchar(10)
as
select@@sname=sname
fromstudent
wheresno=@@sno
(4)触发器的定义实现(仅需给出自己设计模块中所用的)
1、exam表中的exam_plan触发器
Createtriggerexam_plan
onexam
afterupdate
declare@examdaydatetime
declare@examinfosmallint
declare@bkcssmallint
declare@snochar(8)
declare@attendtinyint
declare@accesstinyint
declare@nexamdaydatetime--新插入数据行的数据
declare@nexaminfosmallint
declare@nbkcssmallint
declare@nsnochar(8)
declare@nattendtinyint
declare@naccesstinyint
declare@weekvarchar(10)--标记日期为“星期*”的
select@access=accessfrominserted
select@attend=attendfrominserted
select@examinfo=examinfofrominserted
select@sno=snofrominserted
select@bkcs=bkcsfrominserted
select@examday=examdayfrominserted
if(@access=1and@examinfo=3)
updatestudentsetsuccess=1wheresno=@sno
else
begin
if@access=1
begin
select@nexaminfo=@examinfo+1
select@nsno=@sno
select@nbkcs=@bkcs
select@nattend=0
select@naccess=0
if((@nbkcs=0and(@nexaminfo=0or@nexaminfo=1))or@nbkcs<
>
0)
begin
select@nexamday=@examday+30
select@week=datename(weekday,@nexamday)
while(@week='
星期六'
or@week='
星期日'
begin
select@nexamday=@nexamday+1
select@week=datename(weekday,@nexamday)
end
end
else
select@nexamday=@examday+15
end
else
select@nexaminfo=@examinfo
select@nbkcs=@bkcs+1
insertintoexam
values(@nexamday,@nexaminfo,@nbkcs,@nsno,@attend,@access)
end
对其中学员编号为’20090003’的人进行修改:
参加考试,并且通