2022年数据库课程方案报告《驾校管理系统》内含详细sql语句及运行截图

上传人:桔**** 文档编号:567249085 上传时间:2024-07-19 格式:PDF 页数:16 大小:1.99MB
返回 下载 相关 举报
2022年数据库课程方案报告《驾校管理系统》内含详细sql语句及运行截图_第1页
第1页 / 共16页
2022年数据库课程方案报告《驾校管理系统》内含详细sql语句及运行截图_第2页
第2页 / 共16页
2022年数据库课程方案报告《驾校管理系统》内含详细sql语句及运行截图_第3页
第3页 / 共16页
2022年数据库课程方案报告《驾校管理系统》内含详细sql语句及运行截图_第4页
第4页 / 共16页
2022年数据库课程方案报告《驾校管理系统》内含详细sql语句及运行截图_第5页
第5页 / 共16页
点击查看更多>>
资源描述

《2022年数据库课程方案报告《驾校管理系统》内含详细sql语句及运行截图》由会员分享,可在线阅读,更多相关《2022年数据库课程方案报告《驾校管理系统》内含详细sql语句及运行截图(16页珍藏版)》请在金锄头文库上搜索。

1、个人资料整理仅限学习使用上海电力学院数 据 库 原 理 课 程 设 计题目:驾校管理系统的设计与实现学生姓名:学号:班级:院系:专业年级:2018年 1 月 8 日精选学习资料 - - - - - - - - - 名师归纳总结 - - - - - - -第 1 页,共 16 页个人资料整理仅限学习使用一、需求分析需包含内容为:系统功能描述,对自己所负责的功能模块,可画出所设计模块的操作流程;并分析所需要存储的数据信息。1)信息录入:使用C#语言设计排版编写winform 窗口,给出录入信息的接口,通过C#语句实现与数据库的连接,从而向数据库中插入相应数据。2)信息修改:使用C#语言设计排版编写

2、winform 窗口,给出修改信息的接口,通过C#语句实现与数据库的连接,从修改数据库中相应数据。3)信息查询:在winform 窗口中有多条查询规则供选择有何安全性与完整性方面的要求取值范围为 0,1;“是否色盲”(tinyint取值范围为 0,1;“是否通过全部考试”(success 取值范围为 0,1;“计划学习/教案日” (tinyint取值范围为 0,1;“考试内容”(smallint取值范围为 0,3;“是否参加考试”(attend取值范围为 0,1 ;“是否通过考试” (access 取值范围为 0,1;“出生年月”(datetime;“身高” (smallint取值范围为0,3

3、00;“体重” (smallint取值范围为 0,300;“左眼视力”(real 取值范围为 0,6.0;“右眼视力” (real取值范围为 0,6.0。2)存储过程:以学员编号为输入参数查询学员基本信息。以教练员编号为输入参数统计正在跟随该教练员学习的学员人数并输出。3)触发器:当“学生考试信息表”中的补考次数大于2时,触发事件,级联更新“学员基本信息”中的学费,使学费增加10% 。当“学生考试信息”表中的“是否参与/通过考试”信息被修改时,触发事件自动生成一行新的考试信息,其中规定:1、报名完成后 1个月考理论,理论考试通过1个月后考倒桩,倒桩考试通过半个月后考小路,小路考试通过半个月后考

4、大路,如果其中某次考试未通过,补考均安排在 1个月后;注意周末不考试。2、当大路考试通过后,不再生成新的考试信息,同时级联更新“学员基本信息”表中的“顺利结业”情况。精选学习资料 - - - - - - - - - 名师归纳总结 - - - - - - -第 2 页,共 16 页个人资料整理仅限学习使用二、概念结构设计画出系统整体的E-R模型;并对模型中所出现的实体及属性等信息加以说明。1)学员基本信息:学员编号sno、姓名sname、身份证号sidno、性别ssex、出生年月sbirth、身高stature、体重 sweight、左眼视力lefteye、右眼视力righteye、是否色盲co

5、lorbind 、家庭住址saddr、工作单位scomp、教练员 tno、学习费用sfee、照片 sphoto,是否已通过全部考试success加:联系方式scall,计划学习日期工作日 /周末) sday),报名时间enterday),其中学员编号为主键。2)教练员基本信息:教练编号tno、姓名tname、身份证号tidno、性别tsex、出生年月tbirth 加:联系方式tcall,计划教案日期工作日 /周末) tday),其中教练员编号为主键。3)学员考试信息:学员编号sno、考试日期examday、考试内容 理论、倒桩、小路、大路)examinfo 、补考次数 bkcs、是否参加考试a

6、ttend、是否通过access。其中学员编号、考试内容、补考次数共同作为主键。4)学员教练:学员编号sno、教练编号tno 三、逻辑结构设计1)模式设计:按系统整体E-R模型,写出关系模式;并利用数据字典加以描述。如每个关系模式有何属性、属性的类型、属性值的长度、是否可取空值、是否为主码、有何约束条件等信息)2)子模式设计:即针对自己的设计模块的应用需定义什么样的视图表结构;并利用 数据字典 加以描述。 是否学员编号tno char(8 否否教练编号sname varchar(10 否是姓名sidno char(18 否是身份证号ssex tinyint 否是性别sbirth datetim

7、e 否是出生年月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 否是报名时间教练基本信息te

8、acher 表字段名数据类型是否主键是否为空约束条件默认值描述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 否是考试日期Ex

9、aminfo smallint 是否考试内容Bkcs Smallint 是否补考次数Sno Char(8 是否学员编号Attend Tinyint 否是是否参加考试Access tinyint 否是是否通过四、数据库的物理设计为了提高在表中搜索元组的速度,在实际实现的时候应该基于某些属性建立索引。给出所建立的索引。精选学习资料 - - - - - - - - - 名师归纳总结 - - - - - - -第 4 页,共 16 页个人资料整理仅限学习使用CREATE INDEX syexam_examinfo ON exam ( examinfoASCCREATE INDEX syexam_sno

10、 ON exam ( sno ASCstte 表建立了两个索引:CREATE INDEX systte_sno ON stte ( sno ASC CREATE INDEX systte_tnoON stte ( tno ASC Student表建立了三个索引:CREATE INDEX systudent_enterdayON student ( enterday ASC CREATE INDEX systudent_sname ON student ( sname ASCCREATE INDEX systudent_sno ON student ( sno ASC五、数据库设计实现及运行 a

11、nd type = TR drop trigger CLR Trigger_student go if exists (select 1 from sysobjects where id = object_id(td_student and type = TR drop trigger td_student go if exists (select 1 from sysobjects where id = object_id(ti_student and type = TR drop trigger ti_student go if exists (select 1 from sysobjec

12、ts where id = object_id(tu_student and type = TR drop trigger tu_student go if exists (select 1 from sysobjects where id = object_id(CLR Trigger_stte and type = TR drop trigger CLR Trigger_stte go if exists (select 1 from sysobjects where id = object_id(td_stte and type = TR drop trigger td_stte go

13、if exists (select 1 from sysobjects where id = object_id(ti_stte and type = TR drop trigger ti_stte go if exists (select 1 from sysobjects where id = object_id(tu_stte and type = TR drop trigger tu_stte go if exists (select 1 from sysobjects where id = object_id(exam and type = U drop table exam go

14、if exists (select 1 from sysobjects 精选学习资料 - - - - - - - - - 名师归纳总结 - - - - - - -第 5 页,共 16 页个人资料整理仅限学习使用 where id = object_id(student and type = U drop table student go if exists (select 1 from sysobjects where id = object_id(teacher and type = U drop table teacher go if exists (select 1 from sysob

15、jects where id = object_id(stte and type = U drop table stte go 2)数据表的创建 not null, attend tinyint null, access tinyint null, constraint PK_EXAM primary key nonclustered (examinfo, bkcs, sno go create table student ( sno char(8 not null, tno char(8 not null, sname varchar(10 null, sidno char(18 null,

16、 ssex tinyintnull, sbirth datetime null, stature smallint null, sweight smallint null, lefteye real null, righteye real null, colorbind tinyint null, saddr varchar(40 null, scomp varchar(40 null, sfee int null, sphoto nvarchar(100 null, success tinyint null, scall char(11 null, sday tinyint null, co

17、nstraint PK_STUDENT primary key nonclustered (sno go create table teacher ( tno char(8 not null, tname varchar(10 null, tidno char(18 null, tsex tinyint null, tbirth datetime null, tcall char(11 null, tday tinyint null, constraint PK_TEACHER primary key nonclustered (tno go create table stte( tno ch

18、ar(8 null, sno char(8 not null, constraint PK_stte primary key nonclustered (sno go3)存储过程的定义实现,scount int output as begin select scount=count(sno from stte where stte.tno=tno end 测试结果粘贴:精选学习资料 - - - - - - - - - 名师归纳总结 - - - - - - -第 6 页,共 16 页个人资料整理仅限学习使用2、根据学员学号返回学员全部信息的proc srstudent Create proc s

19、rstudent sno char(8 as select * from student s where s.sno=sno 3、根据学员学号返回学员部分信息的proc rsname等,sname varchar(10 as select sname=sname from student where sno=sno4)触发器的定义实现 declare attend tinyint declare access tinyint declare nexamday datetime-新插入数据行的数据declare nexaminfo smallint declare nbkcs smallint

20、declare nsno char(8 declare nattend tinyint declare naccess tinyint declare week varchar(10-标记日期为 “ 星期 *” 的select access=access from inserted select attend=attend from inserted select examinfo=examinfo from inserted select sno=sno from inserted select bkcs=bkcs from inserted select examday=examday f

21、rom inserted if (access=1 and examinfo=3 update student set success=1 where sno=sno else begin if access=1 begin select nexaminfo=examinfo+1 select nsno=sno select nbkcs=bkcs 精选学习资料 - - - - - - - - - 名师归纳总结 - - - - - - -第 7 页,共 16 页个人资料整理仅限学习使用select nattend=0 select naccess=0 if (nbkcs=0 and(nexami

22、nfo=0 or nexaminfo=1or nbkcs0begin 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

23、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=0 and(nexaminfo=0 or nexaminfo=1or nbkcs0begin select nexamday=examday+30 select week=daten

24、ame(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 精选学习资料 - - - - - - - - - 名师归纳总结 - - - - - - -第 8 页,共 16 页个人资料整理仅

25、限学习使用select nexamday=nexamday+1 select week=datename(weekday,nexamday end end end insert into exam values(nexamday,nexaminfo,nbkcs,nsno,attend,accessend end 测试结果粘贴:对其中学员编号为 20090003 的人进行修改:参加考试,并且通过了考试对学员编号为 20090001 的人进行修改:参加考试,并且未通过考试对学员编号为 20090009 的人进行修改:参加考试,并且通过了考试测试结果如下:精选学习资料 - - - - - - - -

26、 - 名师归纳总结 - - - - - - -第 9 页,共 16 页个人资料整理仅限学习使用2、student 表中的 sfee_tri触发器ALTER trigger sfee_tri on exam after insert as declare bkcs smallint begin select bkcs=bkcs from inserted if bkcs2 begin update student set sfee=sfee*1.1 where sno in(select sno from inserted end end ds = new DataSet(。 string sc

27、omm = string.Format(select * from student where sno=0, textBoxxybh.Text。 da = new SqlDataAdapter(scomm, conn。 da.Fill(ds, student。 if (ds.Tables0.Rows.Count != 0 string sql = string.Format(update student set sno=0,sname=1,ssex=2,sbirth=3,stature=4,sweight=5,lefteye=6,righteye=7,colorblind=8,sidno=9,

28、scall=10,saddr=11,scomp=12,success=13,sday=14,tno=15,sphoto=16,enterday=17,textBoxxybh.Text, textBoxxm.Text, comboBoxxb.SelectedIndex, dateTimePicker1.Value, textBoxsg.Text, textBoxtz.Text, textBoxzysl.Text, textBoxyysl.Text, comboBoxsfsm.SelectedIndex, textBoxsfzh.Text, textBoxlxfs.Text, textBoxjtd

29、z.Text, textBoxgzdw.Text,comboBoxsljy.SelectedIndex, comboBoxxxrq.SelectedIndex, comboBoxsljy.SelectedText, textBoxzpxz.Text, dateTimePickerrxrq.Value。精选学习资料 - - - - - - - - - 名师归纳总结 - - - - - - -第 10 页,共 16 页个人资料整理仅限学习使用 else string sql = string.Format(insert into student values(0,1,2,3,4,5,6,7,8,9

30、,10,11,12,13,14,15,16,17,textBoxxybh.Text, textBoxxm.Text, comboBoxxb.SelectedIndex, dateTimePicker1.Value, textBoxsg.Text, textBoxtz.Text, textBoxzysl.Text, textBoxyysl.Text, comboBoxsfsm.SelectedIndex, textBoxsfzh.Text, textBoxlxfs.Text, textBoxjtdz.Text, textBoxgzdw.Text,comboBoxsljy.SelectedInde

31、x, comboBoxxxrq.SelectedIndex, comboBoxsljy.SelectedText, textBoxzpxz.Text, dateTimePickerrxrq.Value。 comm = conn.CreateCommand(。 comm.CommandText = sql。 sql = string.Format(insert into stte values(0,1, textBoxxybh.Text, comboBoxsljy.ValueMember 。 comm = conn.CreateCommand(。 comm.CommandText = sql。

32、MessageBox.Show(保存成功! 。 功能界面 粘贴);功能界面简单描述;在相应栏目中输入要录入的信息,单击“保存”进行数据保存,单击“取消”关闭窗口。其中“性别”、“是否色盲”、“顺利结业”、“学习日期”、“教练员”为combobox类型输入可选数据中的其中一项,“照片选择”为单击上传button 触发 openfiledialog,选中照片路径,该路径信息将在textbox中显示,“出生日期”和“入学日期”为datetimepicker传入 datetime 类型的数据信息。T-SQL 语句与宿主语言嵌套使用代码段。string sql = string.Format(inser

33、t into student values(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17精选学习资料 - - - - - - - - - 名师归纳总结 - - - - - - -第 11 页,共 16 页个人资料整理仅限学习使用,textBoxxybh.Text, textBoxxm.Text, comboBoxxb.SelectedIndex, dateTimePicker1.Value, textBoxsg.Text, textBoxtz.Text, textBoxzysl.Text, textBoxyysl.Text, comboBoxsfsm.

34、SelectedIndex, textBoxsfzh.Text, textBoxlxfs.Text, textBoxjtdz.Text, textBoxgzdw.Text,comboBoxsljy.SelectedIndex, comboBoxxxrq.SelectedIndex, comboBoxsljy.SelectedText, textBoxzpxz.Text, dateTimePickerrxrq.Value。SqlCommandcomm = conn.CreateCommand( 。comm.CommandText = sql 。sql = string.Format(insert

35、 into stte values(0,1, textBoxxybh.Text, comboBoxsljy.ValueMember。comm = conn.CreateCommand( 。comm.CommandText = sql 。测试结果粘贴;2)删除数据操作每个功能模块描述方法如下: private void buttonsc_Click(object sender, EventArgs e conn.Open(。 DialogResult r=MessageBox.Show(确认删除该行? , 提示,MessageBoxButtons.OKCancel,MessageBoxIcon.

36、Information。 if (r.ToString( = Cancel return。 else ds.Tables0.RowsdataGridView.CurrentRow.Index.Delete(。 string currentsno。 currentsno = 精选学习资料 - - - - - - - - - 名师归纳总结 - - - - - - -第 12 页,共 16 页个人资料整理仅限学习使用dataGridView.RowsdataGridView.CurrentCell.RowIndex.Cells0.Value.ToString(。/ 提取当前单元格所在行的sno st

37、ring sql = string.Format(delete from student where sno=0, currentsno。 comm = conn.CreateCommand(。 comm.CommandText = sql。 comm.ExecuteNonQuery(。 conn.Close(。 功能界面 粘贴);功能界面简单描述;单击 datagridview中任一数据后,若选择“删除当前行!”,则系统提示用户确认对其删除后,将该数据行从 datagridview中删除,同时在数据库中进行删除操作,实现数据的删除。T-SQL 语句与宿主语言嵌套使用代码段。string cu

38、rrentsno。currentsno = dataGridView.RowsdataGridView.CurrentCell.RowIndex.Cells0.Value.ToString(。/ 提取当前单元格所在行的 snostring sql = string.Format(delete from student where sno=0, currentsno。SqlCommandcomm = conn.CreateCommand( 。comm.CommandText = sql 。测试结果粘贴:精选学习资料 - - - - - - - - - 名师归纳总结 - - - - - - -第

39、13 页,共 16 页个人资料整理仅限学习使用3)修改数据操作每个功能模块描述方法如下:public Form4(string x conn.Open(。 InitializeComponent(。 xybh = x。 DataSet ds =new DataSet(。 string item=string.Format(select * from student where sno=0,xybh。 ds = new DataSet(。 da = new SqlDataAdapter(item, conn。 da.Fill(ds, student。 textBoxxybh.Text = xyb

40、h。 if (ds.Tables0.Rows.Count != 0/即说明 xybh这个学号是存在的,则各个textbox 和combobox中显示已有信息 /学员姓名 SqlCommand myc = new SqlCommand(rsname, conn。 myc.CommandType = CommandType.StoredProcedure。 / 调用数据库中的存储过程“rsname”,输入学号返回姓名精选学习资料 - - - - - - - - - 名师归纳总结 - - - - - - -第 14 页,共 16 页个人资料整理仅限学习使用 myc.Parameters.Add(ne

41、w SqlParameter(sno,SqlDbType.Char,8。 myc.Parameterssno.Value=xybh。 myc.Parameters.Add(new SqlParameter(sname, SqlDbType.VarChar, 40。 myc.Parameterssname.Direction = ParameterDirection.ReturnValue。 if (myc.Parameterssname.Value != null textBoxxm.Text = myc.Parameterssname.Value.ToString(。 / 其他 textbo

42、x 同样方法调用数据库中的存储过程返回希望得到的相应值 conn.Close(。 功能界面 粘贴);功能界面简单描述;输入学员编号后,经判断知该学号为已存在学号,则此时希望进行修改操作,与添加界面相同,但是相应的 textbox 、 combobox及datetimepiker中显示数据库中已有信息,减少输入的重复操作,最后与添加操作类似,单击“保存”button 即可。T-SQL 语句与宿主语言嵌套使用代码段。string sql = string.Format(update student set sno=0,sname=1,ssex=2,sbirth=3,stature=4,sweigh

43、t=5,lefteye=6,righteye=7,colorblind=8,sidno=9,scall=10,saddr=11,scomp=12,success=13,sday=14,tno=15,sphoto=16,enterday=17,textBoxxybh.Text, textBoxxm.Text, comboBoxxb.SelectedIndex, dateTimePicker1.Value, textBoxsg.Text, textBoxtz.Text, textBoxzysl.Text, textBoxyysl.Text, comboBoxsfsm.SelectedIndex,

44、textBoxsfzh.Text, textBoxlxfs.Text, textBoxjtdz.Text, textBoxgzdw.Text,comboBoxsljy.SelectedIndex, comboBoxxxrq.SelectedIndex, comboBoxsljy.SelectedText, textBoxzpxz.Text, dateTimePickerrxrq.Value。SqlCommandcomm = conn.CreateCommand( 。comm.CommandText = sql 。sql = string.Format(insert into stte valu

45、es(0,1, textBoxxybh.Text, comboBoxsljy.ValueMember。精选学习资料 - - - - - - - - - 名师归纳总结 - - - - - - -第 15 页,共 16 页个人资料整理仅限学习使用comm = conn.CreateCommand( 。comm.CommandText = sql 。测试结果粘贴;六、数据库维护数据库维护具体是指备份系统数据、数据库、事务日志、数据库及其日志间的相互作用,万一系统失败时恢复数据库系统,在数据库系统运行过程中必须不断地对其进行评价、调整与修改。七、心得体会通过本次课程设计,我对本学期所学的“数据库”及“

46、C#”两门课程都有了更深一层的理解和学习。对数据库的认识不再停留在基础知识的认识上,能够更加清楚其后台工作状况,熟悉其语言特点及规则,通过创建具有复杂功能的触发器、存储结构,拓展数据库的功能。尤其是在需求分析的过程和复杂触发器的创建过程。需求分析中我学到了一些帮助考虑需求的思想,能够更大程度的避免创建数据库后,出现频繁更改值类型或列名等行为;创建复杂触发器的过程让我更加透彻理解数据库的语言精髓,对于日后sql语句的编写应用有很大帮助。对于C# 的应用不再停留于简单的winform 窗口,而是做到与数据库进行连接,通过winform 的前台接口,对数据库传入相应的sql 语句,从而实现数据库的插入、更新、删除等操作,实现sql 语句的前台明了化。在实践中与搭档秦嘉颖的协调工作很成功,根据我们相互的特长,秦嘉颖主要负责编写数据库中的 sql 语句,如触发器、存储过程的生成等;而我主要负责winform 界面设计及 winform 与数据库的连接编程。我们的工作并不是单一进行的,而是相互交流,相互检查发现问题并共同讨论解决的,所以不仅做到了扬长避短,还通过对方的教导弥补了自己的弱项。相信这次设计对于日后的软件程序设计都有很大帮助!精选学习资料 - - - - - - - - - 名师归纳总结 - - - - - - -第 16 页,共 16 页

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 建筑/环境 > 施工组织

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号