数据库课程方案设计书报告《驾校管理系统》内含详细的sql语句及运行截图.docx
- 文档编号:30772884
- 上传时间:2023-08-23
- 格式:DOCX
- 页数:30
- 大小:1,004.20KB
数据库课程方案设计书报告《驾校管理系统》内含详细的sql语句及运行截图.docx
《数据库课程方案设计书报告《驾校管理系统》内含详细的sql语句及运行截图.docx》由会员分享,可在线阅读,更多相关《数据库课程方案设计书报告《驾校管理系统》内含详细的sql语句及运行截图.docx(30页珍藏版)》请在冰豆网上搜索。
数据库课程方案设计书报告《驾校管理系统》内含详细的sql语句及运行截图
上海电力学院
数据库原理课程设计
题目:
驾校管理系统的设计与实现
学生姓名:
学号:
班级:
院系:
专业年级:
2012年1月8日
一、需求分析
需包含内容为:
(1)问题描述:
设计系统的简单描述
以驾校管理员身份登录该系统界面,实现对驾校的学员信息、教练信息、学员考试信息等进行多条件组合查询,索引查看,自动安排考试日期,自动生成学费以及信息修改、录入、删除等功能。
(2)系统功能描述,对自己所负责的功能模块,可画出所设计模块的操作流程;并分析所需要存储的数据信息。
1)信息录入:
使用C#语言设计排版编写winform窗口,给出录入信息的接口,通过C#语句实现与数据库的连接,从而向数据库中插入相应数据。
2)信息修改:
使用C#语言设计排版编写winform窗口,给出修改信息的接口,通过C#语句实现与数据库的连接,从修改数据库中相应数据。
3)信息查询:
在winform窗口中有多条查询规则供选择(可多选),根据选择的查询条件写出相应程序语言实现与数据库的连接查询。
4)系统需要自动安排学员考试日期:
在数据库中编写相应的trigger,当学员考试信息表中某条记录的“是否通过考试”或“是否参与考试”的值改变时,该触发器被触发,生成新一行数据。
规定:
①报名完成后1个月考理论,理论考试通过1个月后考倒桩,倒桩考试通过半个月后考小路,小路考试通过半个月后考大路,如果其中某次考试未通过,补考均安排在1个月后;注意周末不考试。
②当大路考试通过后,不再生成新的考试信息,同时级联更新“学员基本信息”表中的“顺利结业”情况。
5)显示照片:
在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) 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 char(8) 否 否 教练编号 sname varchar(10) 否 是 姓名 sidno char(18) 否 是 身份证号 ssex tinyint 否 是 性别 sbirth datetime 否 是 出生年月 stature smallint 否 是 身高 sweight smallint 否 是 体重 lefteye real 否 是 左眼视力 righteye real 否 是 右眼视力 colorbind tinyint 否 是 是否色盲 saddr varchar(40) 否 是 家庭住址 scomp varchar(40) 否 是 工作单位 sfee int 否 是 4500 学习费用 sphoto nvarchar(100) 否 是 照片 success tinyint 否 是 是否顺利结业 scall char(11) 否 是 联系方式 sday tinyint 否 是 计划学习日期 enterday datetime 否 是 报名时间 教练基本信息teacher表 字段名 数据类型 是否主键 是否为空 约束条件 默认值 描述 tno char(8) 是 否 教练编号 tname varchar(10) 否 是 姓名 tidno char(18) 否 是 身份证号 tsex tinyint 否 是 性别 tbirth datetime 否 是 出生年月 tcall char(11) 否 是 联系方式 tday tinyint 否 是 计划教学日期 学员教练关系stte表 字段名 数据类型 是否主键 是否为空 约束条件 默认值 描述 Tno Char(8) 否 是 教练编号 sno Char(8) 是 否 学员编号 学员考试信息exam表 字段名 数据类型 是否主键 是否为空 约束条件 默认值 描述 Examday Datetime 否 是 考试日期 Examinfo smallint 是 否 考试内容 Bkcs Smallint 是 否 补考次数 Sno Char(8) 是 否 学员编号 Attend Tinyint 否 是 是否参加考试 Access tinyint 否 是 是否通过 四、数据库的物理设计 为了提高在表中搜索元组的速度,在实际实现的时候应该基于某些属性建立索引。 给出 所建立的索引。 (包括按哪些表中哪些属性按升序还是降序来创建索引及相应的T-SQL的创建语句)。 exam表建立了三个索引: CREATEINDEXsyexam_examdayONexam (examdayASC) CREATEINDEXsyexam_examinfoONexam (examinfoASC) CREATEINDEXsyexam_snoONexam (snoASC) stte表建立了两个索引: CREATEINDEXsystte_snoONstte (snoASC) CREATEINDEXsystte_tnoONstte (tnoASC) Student表建立了三个索引: CREATEINDEXsystudent_enterdayONstudent (enterdayASC) CREATEINDEXsystudent_snameONstudent (snameASC) CREATEINDEXsystudent_snoONstudent (snoASC) 五、数据库设计实现及运行 (1)数据库的创建 T-SQL语句: /*========================================*/ /*DBMSname: MicrosoftSQLServer2005*/ /*Createdon: 2012/1/48: 57: 37*/ /*========================================*/ ifexists(select1 fromsysobjects whereid=object_id('"CLRTrigger_student"') andtype='TR') droptrigger"CLRTrigger_student" go ifexists(select1 fromsysobjects whereid=object_id('td_student') andtype='TR') droptriggertd_student go ifexists(select1 fromsysobjects whereid=object_id('ti_student') andtype='TR') droptriggerti_student go ifexists(select1 fromsysobjects whereid=object_id('tu_student') andtype='TR') droptriggertu_student go ifexists(select1 fromsysobjects whereid=object_id('"CLRTrigger_stte"') andtype='TR') droptrigger"CLRTrigger_stte" go ifexists(select1 fromsysobjects whereid=object_id('td_stte') andtype='TR') droptriggertd_stte go ifexists(select1 fromsysobjects whereid=object_id('ti_stte') andtype='TR') droptriggerti_stte go ifexists(select1 fromsysobjects whereid=object_id('tu_stte') andtype='TR') droptriggertu_stte go ifexists(select1 fromsysobjects whereid=object_id('exam') andtype='U') droptableexam go ifexists(select1 fromsysobjects whereid=object_id('student') andtype='U') droptablestudent go ifexists(select1 fromsysobjects whereid=object_id('teacher') andtype='U') droptableteacher go ifexists(select1 fromsysobjects whereid=object_id('stte') andtype='U') droptablestte go (2)数据表的创建(可同时在创建时定义相关的约束) T-SQL语句: createtableexam( examdaydatetimenull, examinfosmallintnotnull, bkcssmallintnotnull, snochar(8)notnull, attendtinyintnull, accesstinyintnull, constraintPK_EXAMprimarykeynonclustered(examinfo,bkcs,sno) ) go createtablestudent( snochar(8)notnull, 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) ) go createtableteacher( tnochar(8)notnull, tnamevarchar(10)null, tidnochar(18)null, tsextinyintnull, tbirthdatetimenull, tcallchar(11)null, tdaytinyintnull, constraintPK_TEACHERprimarykeynonclustered(tno) ) go createtablestte( tnochar(8)null, snochar(8)notnull, constraintPK_stteprimarykeynonclustered(sno) ) go (3)存储过程的定义实现(仅需给出自己设计模块中所用的) T-SQL语句: 1、计算教练员所带学员数量的procsr_teacher Createprocsr_teacher @@tnochar(8),@@scountintoutput as begin select@@scount=count(sno) fromstte wherestte.tno=@@tno end 测试结果粘贴: 2、根据学员学号返回学员全部信息的procsrstudent Createprocsrstudent @@snochar(8) as select*fromstudents wheres.sno=@@sno 3、根据学员学号返回学员部分信息的procrsname等(在进行修改操作时需要调用) Createprocrsname @@snochar(8),@@snamevarchar(10) as select@@sname=sname fromstudent wheresno=@@sno (4)触发器的定义实现(仅需给出自己设计模块中所用的) T-SQL语句: 1、exam表中的exam_plan触发器 Createtriggerexam_plan onexam afterupdate as begin 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 begin select@nexamday=@examday+15 select@week=datename(weekday,@nexamday) while(@week='星期六'or@week='星期日') begin select@nexamday=@nexamday+1 select@week=datename(weekday,@nexamday) end end end else begin select@nsno=@sno select@nexaminfo=@examinfo select@nbkcs=@bkcs+1 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 begin select@nexamday=@examday+15 select@week=datename(weekday,@nexamday) while(@week='星期六'or@week='星期日') begin select@nexamday=@nexamday+1 select@week=datename(weekday,@nexamday) end end end insertintoexam values(@nexamday,@nexaminfo,@nbkcs,@nsno,@attend,@access) end end 测试结果粘贴: 对其中学员编号为’20090003’的人进行修改: 参
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 驾校管理系统 数据库 课程 方案设计 书报 驾校 管理 系统 内含 详细 sql 语句 运行 截图