




已阅读5页,还剩11页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
上海电力学院数据库原理课程设计题 目: 驾校管理系统的设计与实现 学生姓名: 学 号: 班 级: 院 系: 专业年级: 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)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表字段名数据类型是否主键是否为空约束条件默认值描述snochar(8)是否学员编号tnochar(8)否否教练编号snamevarchar(10)否是姓名sidnochar(18)否是身份证号ssextinyint否是性别sbirthdatetime否是出生年月staturesmallint否是身高sweightsmallint否是体重lefteyereal否是左眼视力righteyereal否是右眼视力colorbindtinyint否是是否色盲saddrvarchar(40)否是家庭住址scompvarchar(40)否是工作单位sfeeint否是4500学习费用sphotonvarchar(100)否是照片successtinyint否是是否顺利结业scallchar(11)否是联系方式sdaytinyint否是计划学习日期enterdaydatetime否是报名时间教练基本信息teacher表字段名数据类型是否主键是否为空约束条件默认值描述tnochar(8)是否教练编号tnamevarchar(10)否是姓名tidnochar(18)否是身份证号tsextinyint否是性别tbirthdatetime否是出生年月tcallchar(11)否是联系方式tdaytinyint否是计划教学日期学员教练关系stte表字段名数据类型是否主键是否为空约束条件默认值描述TnoChar(8)否是教练编号sno Char(8)是 否学员编号学员考试信息exam表字段名数据类型是否主键是否为空约束条件默认值描述ExamdayDatetime否是考试日期Examinfosmallint是否考试内容BkcsSmallint是否补考次数SnoChar(8)是否学员编号AttendTinyint否是是否参加考试 Accesstinyint否是是否通过四、数据库的物理设计为了提高在表中搜索元组的速度,在实际实现的时候应该基于某些属性建立索引。给出所建立的索引。(包括按哪些表中哪些属性按升序还是降序来创建索引及相应的T-SQL的创建语句)。exam表建立了三个索引:CREATE INDEX syexam_examday ON exam (examday ASC)CREATE INDEX syexam_examinfo ON exam (examinfo ASC)CREATE INDEX syexam_sno ON exam(sno ASC)stte表建立了两个索引:CREATE INDEX systte_sno ON stte(sno ASC)CREATE INDEX systte_tno ON stte (tno ASC)Student表建立了三个索引:CREATE INDEX systudent_enterday ON student (enterday ASC)CREATE INDEX systudent_sname ON student (sname ASC)CREATE INDEX systudent_sno ON student(sno ASC)五、数据库设计实现及运行(1)数据库的创建T-SQL语句:/*=*/* DBMS name: Microsoft SQL Server 2005 */* Created on: 2012/1/4 8:57:37 */*=*/if exists (select 1 from sysobjects where id = object_id(CLR Trigger_student) and type = TR) drop trigger CLR Trigger_studentgoif exists (select 1 from sysobjects where id = object_id(td_student) and type = TR) drop trigger td_studentgoif exists (select 1 from sysobjects where id = object_id(ti_student) and type = TR) drop trigger ti_studentgoif exists (select 1 from sysobjects where id = object_id(tu_student) and type = TR) drop trigger tu_studentgoif exists (select 1 from sysobjects where id = object_id(CLR Trigger_stte) and type = TR) drop trigger CLR Trigger_sttegoif exists (select 1 from sysobjects where id = object_id(td_stte) and type = TR) drop trigger td_sttegoif exists (select 1 from sysobjects where id = object_id(ti_stte) and type = TR) drop trigger ti_sttegoif exists (select 1 from sysobjects where id = object_id(tu_stte) and type = TR) drop trigger tu_sttegoif exists (select 1 from sysobjects where id = object_id(exam) and type = U) drop table examgoif exists (select 1 from sysobjects where id = object_id(student) and type = U) drop table studentgoif exists (select 1 from sysobjects where id = object_id(teacher) and type = U) drop table teachergoif exists (select 1 from sysobjects where id = object_id(stte) and type = U) drop table sttego(2)数据表的创建(可同时在创建时定义相关的约束)T-SQL语句:create table exam ( examday datetime null, examinfo smallint not null, bkcs smallint not null, sno char(8) not null, attend tinyint null, access tinyint null, constraint PK_EXAM primary key nonclustered (examinfo, bkcs, sno)gocreate table student ( sno char(8) not null, tno char(8) not null, sname varchar(10) null, sidno char(18) null, ssex tinyint null, 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, constraint PK_STUDENT primary key nonclustered (sno)gocreate 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)gocreate table stte ( tno char(8) null, sno char(8) not null, constraint PK_stte primary key nonclustered (sno)go(3)存储过程的定义实现(仅需给出自己设计模块中所用的)T-SQL语句:1、计算教练员所带学员数量的proc sr_teacherCreate proc sr_teachertno char(8),scount int outputasbeginselect scount=count(sno)from sttewhere stte.tno=tnoend测试结果粘贴:2、根据学员学号返回学员全部信息的proc srstudentCreate proc srstudentsno char(8)asselect * from student swhere s.sno=sno3、根据学员学号返回学员部分信息的proc rsname等(在进行修改操作时需要调用)Create proc rsnamesno char(8),sname varchar(10)as select sname=snamefrom studentwhere sno=sno(4)触发器的定义实现(仅需给出自己设计模块中所用的)T-SQL语句:1、exam表中的exam_plan触发器Create trigger exam_planon examafter updateasbegindeclare examday datetimedeclare examinfo smallintdeclare bkcs smallintdeclare sno char(8)declare attend tinyintdeclare access tinyintdeclare nexamday datetime-新插入数据行的数据declare nexaminfo smallintdeclare nbkcs smallintdeclare nsno char(8)declare nattend tinyintdeclare naccess tinyintdeclare week varchar(10)-标记日期为“星期*”的select access=access from insertedselect attend=attend from insertedselect examinfo=examinfo from insertedselect sno=sno from insertedselect bkcs=bkcs from insertedselect examday=examday from insertedif (access=1 and examinfo=3)update student set success=1 where sno=snoelsebeginif access=1beginselect nexaminfo=examinfo+1select nsno=snoselect nbkcs=bkcsselect nattend=0select naccess=0if (nbkcs=0 and(nexaminfo=0 or nexaminfo=1)or nbkcs0)beginselect nexamday=examday+30select week=datename(weekday,nexamday)while(week=星期六 or week=星期日)beginselect nexamday=nexamday+1select week=datename(weekday,nexamday)endendelsebeginselect nexamday=examday+15select week=datename(weekday,nexamday)while(week=星期六 or week=星期日)beginselect nexamday=nexamday+1select week=datename(weekday,nexamday)endendendelsebeginselect nsno=snoselect nexaminfo=examinfoselect nbkcs=bkcs+1select nattend=0select naccess=0if (nbkcs=0 and(nexaminfo=0 or nexaminfo=1)or nbkcs0)beginselect nexamday=examday+30select week=datename(weekday,nexamday)while(week=星期六 or week=星期日)beginselect nexamday=nexamday+1select week=datename(weekday,nexamday)endendelsebeginselect nexamday=examday+15select week=datename(weekday,nexamday)while(week=星期六 or week=星期日)beginselect nexamday=nexamday+1select week=datename(weekday,nexamday)endendendinsert into examvalues(nexamday,nexaminfo,nbkcs,nsno,attend,access)endend测试结果粘贴:对其中学员编号为20090003的人进行修改:参加考试,并且通过了考试对学员编号为20090001的人进行修改:参加考试,并且未通过考试对学员编号为20090009的人进行修改:参加考试,并且通过了考试测试结果如下:2、student表中的sfee_tri触发器ALTER trigger sfee_trion examafter insertasdeclare bkcs smallintbeginselect bkcs=bkcs from insertedif bkcs2beginupdate studentset sfee=sfee*1.1where sno in(select sno from inserted)endend(5)自行设计各模块中所涉及的操作语句1)插入数据操作每个功能模块描述方法如下: private void buttonbc_Click(object sender, EventArgs e) ds = new DataSet(); string scomm = 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,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, textBoxjtdz.Text, textBoxgzdw.Text,comboBoxsljy.SelectedIndex, comboBoxxxrq.SelectedIndex, comboBoxsljy.SelectedText, textBoxzpxz.Text, dateTimePickerrxrq.Value); else string sql = string.Format(insert into student values(0,1,2,3,4,5,6,7,8,9,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.SelectedIndex, 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; MessageBox.Show(保存成功!); 功能界面(粘贴); 功能界面简单描述;在相应栏目中输入要录入的信息,单击“保存”进行数据保存,单击“取消”关闭窗口。其中“性别”、“是否色盲”、“顺利结业”、“学习日期”、“教练员”为combobox类型输入可选数据中的其中一项,“照片选择”为单击上传button触发openfiledialog,选中照片路径,该路径信息将在textbox中显示,“出生日期”和“入学日期”为datetimepicker传入datetime类型的数据信息。T-SQL语句与宿主语言嵌套使用代码段(粘贴);public const string txt1 = Data Source=GUJIBALA-PCSQLEXPRESS;Initial Catalog=kcsj_driver;Integrated Security=True;SqlConnection conn = new SqlConnection(txt1);string sql = string.Format(insert into student values(0,1,2,3,4,5,6,7,8,9,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.SelectedIndex, comboBoxxxrq.SelectedIndex, comboBoxsljy.SelectedText, textBoxzpxz.Text, dateTimePickerrxrq.Value);SqlCommand 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;测试结果粘贴; 2)删除数据操作每个功能模块描述方法如下: private void buttonsc_Click(object sender, EventArgs e) conn.Open(); DialogResult r=MessageBox.Show(确认删除该行?,提示,MessageBoxButtons.OKCancel,MessageBoxIcon.Information); if (r.ToString() = Cancel) return; else ds.Tables0.RowsdataGridView.CurrentRow.Index.Delete(); string currentsno; currentsno = dataGridView.RowsdataGridView.CurrentCell.RowIndex.Cells0.Value.ToString();/提取当前单元格所在行的sno string sql = string.Format(delete from student where sno=0, currentsno); comm = conn.CreateCommand(); comm.CommandText = sql; comm.ExecuteNonQuery(); conn.Close(); 功能界面(粘贴);功能界面简单描述;单击datagridview中任一数据后,若选择“删除当前行!”,则系统提示用户确认对其删除后,将该数据行从datagridview中删除,同时在数据库中进行删除操作,实现数据的删除。T-SQL语句与宿主语言嵌套使用代码段(粘贴);public const string txt1 = Data Source=GUJIBALA-PCSQLEXPRESS;Initial Catalog=kcsj_driver;Integrated Security=True;SqlConnection conn = new SqlConnection(txt1);string currentsno;currentsno = dataGridView.RowsdataGridView.CurrentCell.RowIndex.Cells0.Value.ToString();/提取当前单元格所在行的snostring sql = string.Format(delete from student where sno=0, currentsno);SqlCommand comm = conn.CreateCommand();comm.CommandText = sql;测试结果粘贴: 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 = xybh; if (ds.Tables0.Rows.Count != 0)/即说明xybh这个学号是存在的,则各个textbox和combobox中显示已有信息 /学员姓名 SqlCommand myc = new SqlCommand(rsname, conn); myc.CommandType = CommandType.StoredProcedure; /调用数据库中的存储过程“rsname”,输入学号返回姓名 myc.Parameters.Add(new 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(); /其他textbox同样方法调用 数据库中的存储过程 返回希望得到的相应值 conn.Close(); 功能界面(粘贴);功能界面简单描述;输入学员编号后,经判断知该学号为已存在学号,则此时希望进行修改操作,与添加界面相同,但是相应的textbox、combobox及datetimepiker中显示数据库中已有信息,减少输入的重复操作,最后与添加操作类似,单击“保存”button即可。T-SQL语句与宿主语言嵌套使用代码段(粘贴);public const string txt1 = Data Source=GUJIBALA-PCSQLEXPRESS;Initial Catalog=kcsj_driver;Integrated Security=T
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 中小学教师信息技术应用能力提升工程试题及答案
- 浙江省嘉兴市2026届高三上学期9月基础测试语文试题(含答案)
- 烹饪营养与卫生(第3版)-课件 11.项目三任务八.科学烹饪的意义
- 应对课件教学课件
- 2025全民国防教育日主题班会课件
- 巡察问题底稿课件教学
- 岩石学三大岩类课件
- 输电安全培训新闻稿课件
- 小鸭课件教学课件
- 养殖场动物养殖场安全生产与应急预案合同范本
- 公司有关进一步改组股份合作制实施方案
- 房建工程监理规划范本
- 高速通信管道迁改施工方案
- USP 62-非无菌产品的微生物检验特定微生物的试验CN
- 幕墙UHPC施工专项方案 (评审版)
- 2025-2030年地域风味酱板鸭行业跨境出海战略研究报告
- 2025年一季度全院难免压疮风险评估上报总结分析(二篇)
- 2025-2030年中国微晶玻璃面板行业规模分析及投资前景规划研究报告
- 小学生班级安全小卫士
- 2025年江苏南京市国企集团招聘笔试参考题库含答案解析
- GB/T 33761-2024绿色产品评价通则
评论
0/150
提交评论