ImageVerifierCode 换一换
格式:DOCX , 页数:22 ,大小:1.34MB ,
资源ID:8192699      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/8192699.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(公交查询系统数据库课程设计分析方案.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

公交查询系统数据库课程设计分析方案.docx

1、公交查询系统数据库课程设计分析方案数据库课程设计报告班级:序号: 姓名: 地球科学学院地信系2018-06-28目录数据库课程设计1目录2一、概述31.1背景说明31.2开发环境3二、需求分析32.1用户需求32.2主要功能32.3数据流图32.4数据字典3三、数据库概念结构设计4四、数据库逻辑结构设计24.1 关系表设计24.2 数据表关系图2五、创建数据库及其对象25.1 建数据库和表25.2 查询实现3五、软件功能设计5六、界面设计6七、应用程序67.1 站点查询67.2 线路查询77.3 站站查询8八、实验数据示例10九、心得11一、概述1.1背景说明软件名称:公交线路查询系统 工程提

2、出者: 工程开发者: 用户:广大需要乘坐公交车的人群1.2开发环境操作系统:Windows XP软件配置:visual stutio2018,Microsoft SQLServer 2008 R2数据库配置:Microsoft SQL Server 2008 R2在PC机中新建数据库,建立各个数据表、关系图。二、需求分析2.1用户需求城市的扩张使得公交线路越来越复杂,为了使得用户更加方便地能够获得最新公交线路,“公交线路查询工具”帮助人们解决这个问题。本系统面向的对象是普通乘客,对于普通乘客来说,他们最关心的就是查询。系统也只对用户提供信息查询功能,并不对用户开放对数据的编辑权限。对于任何用户

3、,只要浏览本系统的首页,就可以根据自己的需求进行查询。数据的修改、删除、及时更新工作只能由管理人员实现并对系统进行定期的维护,保证其运行的稳定性。2.2主要功能本系统从用户的需求出发,可实现以下功能: 1、线路具体情况查询:输入线路名称就可得到该线路的途经站点,发车和末班车时间,票价等相关信息。2、经过此站点的所有路线查询:输入站点名称即可得出经过该站点的所有线路名称。3、站点间的点到点路线查询:输入出发站点和目的站点即可输出可选择的线路,包括中间站的转乘。2.3数据流图2.4数据字典1、数据项名称数据类型长度字段描述namevarchar5公交车的名称start_timetime8公交车每天

4、的最早发车时间end_timetime8公交车每天的收班时间buslength1int2公交线路去程的站点数buslength2int2公交线路回程的站点数pt_pricefloat3普通车的票价gd_pricefloat3高等级车的票价disprice_ptfloat3普通车刷卡后的价格disprice_gdfloat3高等级车刷卡后的价格companyIDint1公司编号company_namevarchar30公司名称station_idint3站点的编号station_namevarchar30站点的名称orderidint2站点在一条线路中的位置typeIDint2线路类型编号,共1

5、2类type_namevarchar5线路类型名directionchar4公交行驶方向,“去程”或“回程”linevarchar500公交行驶途径的站点2、数据流名称说明数据流来源数据流去向用户查询公交线路记录信息记录公交车线路查询信息线路+站点查询结果输出3、处理过程名称简述输入的数据流处理输出的数据流线路查询根据公交线路查询该线路上的所有站点公交车编号根据编号查询查询出该线路上的所有公交车站点站点查询根据站点查询出经过该站点的所有公交车编号站点名称根据站点查询公交车的编号路过该站点的所有公交车编号站站查询根据两个站点查询出所有线路两个不同的站点根据站点查询出所有线路输出查询出的线路三、数

6、据库概念结构设计根据需求分析,可知本系统有以下E-R图:1、公交站点E-R图 3、公交公司E-R图2、公交车E-R图 4、公交线路类型E-R图5、合并E-R图四、数据库逻辑结构设计4.1 关系表设计根据ER模型,对本系统设计出5个关系表:1、公交车表busnot nullprimary key公交车的名称start_timetimenot null最早发车时间end_timetimenot null收班时间buslength1intnot null去程的站点数buslength2intnot null回程的站点数pt_pricefloatnull普通车的票价disprice_ptfloatnu

7、ll普通车刷卡gd_pricefloatnull高等级车的票价disprice_gdfloatnull高等级车刷卡companyIDintnot nullforeignkeyreferencescompany(id,typeIDintnot nullForeignkeyreferencesbus_type(id2、公交站点stationnot null站点的名称3、线路与站点关联表bus_stationnot nullprimary key参照bus(namestation_idintnot null参照station(idorderidintnot null站点在一条线路中的位置4、公交公司

8、表company(id,name列名数据类型NULL约束说明idintNot nullprimary key公司编号nameVarchar(5Not null公司名称5、公交线路类型表bus_type(id,name列名数据类型NULL约束说明idintNot nullprimary key线路类型编号,共12类nameVarchar(10Not null线路类型名6、公交线路表busline(bus_name,direction,line 此表主要是为了方便依据线路来查询站点信息。 列名数据类型NULL约束说明bus_namevarchar(4Not nullprimary key公司编号d

9、irectionvarchar(4Not null公交行驶方向,“去程”或“回程”linevarchar(500Not null公交行驶途径的站点4.2 数据表关系图五、创建数据库及其对象5.1 建数据库和表下面是创建数据库和表的过程,数据通过手动输入。1、创建数据库createdatabasebuson(name=bus_data1,filename=C:Documents and SettingsAdministrator桌面busbus_data1.mdflogon(name=bus_log,filename=C:Documents and SettingsAdministrator桌面

10、busbus_log.ldf2、创建表公交公司表createtablecompany(idintprimarykeynotnull,namevarchar(30notnull公交线路类型表createtablebus_type(idintprimarykeynotnull,namevarchar(5notnull公交站点createtablestation(idintprimarykeynotnull,namevarchar(15notnull公交线路表createtablebusline(bus_namevarchar(5,directionchar(2notnull,linevarchar

11、(200notnull,primarykey(bus_name,direction,foreignkey(bus_namereferencesbus(name公交车表createtablebus(namevarchar(5primarykeynotnull,start_timedatetimenotnull,end_timedatetimenotnull,buslengthintnotnull,pricefloatnotnull,companyIDintnotnull,typeIDintnotnull,foreignkey(companyIDreferencescompany(id,forei

12、gnkey(typeIDreferencesbus_type(id线路与站点关联表createtablebus_station(bus_namevarchar(5,station_idint,orderidintnotnull,primarykey(bus_name,station_id,foreignkey(bus_namereferencesbus(name,foreignkey(station_idreferencesstation(id5.2 查询实现这里只介绍线路查询和站站查询的存储过程实现,其它涉及到的功能通过SQLCommand或SqlDataAdapter实现,在后面的应用程序

13、设计中实现。1、线路具体情况查询:ifexists(selectnamefromsysobjectswherename=busline_infodropprocedurebusline_infogocreateprocedurebusline_infoinputvarchar(5,outputvarchar(700outputasbeginselectoutput=linefrombuslinewherebusline.bus_name=inputendgo2、站点间的点到点路线查询:ifexists(selectnamefromsysobjectswherename=station_stat

14、iondropprocedurestation_stationgocreateprocedurestation_stationinput1varchar(30,input2varchar(30,output1varchar(5output,output2varchar(5output,output3varchar(5output,output4varchar(30output,output5varchar(30outputasbegindeclarestationID1int,stationID2int-换乘过程中的中间站点declareid1int,id2int-记录起点和终点的IDsele

15、ctid1=idfromstationwherename=input1selectid2=idfromstationwherename=input2-查找直达线路selectoutput1=a.bus_namefrom(selectbus_namefrombus_stationwherestation_id=id1a,(selectbus_namefrombus_stationwherestation_id=id2bwherea.bus_name=b.bus_name-若不存在直达线路,则搜寻一次换乘路线ifnotexists(select*frombuswherename=output1be

16、gin-查找中间站点selectstationID1=c.station_idfrom-input1能直达的站点集合c(selectdistinctstation_idfrombus_stationwherebus_namein(selectbus_namefrombus_stationwherestation_id=id1c,-input2能直达的站点集合d(selectdistinctstation_idfrombus_stationwherebus_namein(selectbus_namefrombus_stationwherestation_id=id2dwherec.station

17、_id=d.station_idselectoutput1=a.bus_namefrom(selectbus_namefrombus_stationwherestation_id=id1a,(selectbus_namefrombus_stationwherebus_station.station_id=stationID1bwherea.bus_name=b.bus_nameselectoutput2=a.bus_namefrom(selectbus_namefrombus_stationwherestation_id=id2a,(selectbus_namefrombus_stationw

18、herebus_station.station_id=stationID1bwherea.bus_name=b.bus_nameend-若不存在直达和一次换乘线路,则搜寻二次换乘路线ifnotexists(select*frombuswherename=output1andnotexists(select*frombuswherename=output2begin-查找中间线路selectoutput2=a.bus_namefrom(selectdistinctbus_namefrombus_stationwherestation_idin(selectstation_idfrombus_st

19、ationwherebus_namein(selectbus_namefrombus_stationwherestation_id=id1a,(selectdistinctbus_namefrombus_stationwherestation_idin(selectstation_idfrombus_stationwherebus_namein(selectbus_namefrombus_stationwherestation_id=id2bwherea.bus_name=b.bus_name-查找起点到中间线路的公交车selectstationID1=a.station_idfrom(sel

20、ectdistinctstation_idfrombus_stationwherebus_namein(selectbus_namefrombus_stationwherestation_id=id1a,(selectstation_idfrombus_stationwherebus_name=output2bwherea.station_id=b.station_idselectoutput1=c.bus_namefrom(selectbus_namefrombus_stationwherestation_id=id1c,(selectbus_namefrombus_stationwhere

21、station_id=stationID1dwherec.bus_name=d.bus_name-查找中间线路到终点的公交车selectstationID2=a.station_idfrom(selectdistinctstation_idfrombus_stationwherebus_namein(selectbus_namefrombus_stationwherestation_id=id2a,(selectstation_idfrombus_stationwherebus_name=output2bwherea.station_id=b.station_idselectoutput3=c

22、.bus_namefrom(selectbus_namefrombus_stationwherestation_id=id2c,(selectbus_namefrombus_stationwherestation_id=stationID2dwherec.bus_name=d.bus_nameendselectoutput4=namefromstationwhereid=stationID1selectoutput5=namefromstationwhereid=stationID2end五、软件功能设计软件共实现了3个大功能,即站点查询、线路查询、站站查询,其完成情况如下:一):检查用户是否

23、输入了站点或线路信息,如果没有录入,则提示:请输入站点!或请输入线路名!二):检查用户是否输入的站点或线路是否存在,如果不存在,则提示:此站点不存在!或此线路不存在!三):如果信息都填写正确,则根据选定的查询条件进行查找,查找的具体实现为: 1)站点查询:返回经过此站点的所有线路,并提供一条线路经过的所有站点。 如果没有结果,则提示:找不到此站点! 2)线路查询:返回此线路的类型、最早和最晚时间、票价、经过站点等信息。 SqlConnection myConnection = newSqlConnection(connectionString。 myConnection.Open(。SqlCo

24、mmand cmd = newSqlCommand(select bus_station.bus_name as 公?交?线?路名?,busline.direction as 方?向,line as 途?径?站?点? from bus_station,station,busline where station.name = + input + and dbo.station.id = bus_station.station_id and bus_station.bus_name = busline.bus_name, myConnection。SqlDataAdapter da = newSq

25、lDataAdapter(。 da.SelectCommand = cmd。 System.Data.DataSet ds = new System.Data.DataSet(。 da.Fill(ds。this.GridView1.DataSource = ds.Tables0。 GridView1.DataBind(。 cmd = null。 myConnection.Close(。 7.2 线路查询/ 查询给定线路的公交车所经过站点protectedstring busline_info1(string input string connectionString = server=TXJM

26、1FW3L1GYIC6。database = bus。Integrated Security = true。SqlConnection myConnection = newSqlConnection(connectionString。 myConnection.Open(。SqlCommand myCommand = newSqlCommand(busline_info, myConnection。 myCommand.CommandType = System.Data.CommandType.StoredProcedure。/创建参数SqlParameter bus_name = newSq

27、lParameter(input, System.Data.SqlDbType.VarChar, 5。 bus_name.Direction = System.Data.ParameterDirection.Input。 bus_name.Value = input。 myCommand.Parameters.Add(bus_name。/添加输出参数SqlParameter Result1 = newSqlParameter(output, System.Data.SqlDbType.VarChar, 700。 Result1.Direction = System.Data.ParameterDirection.Output。 myCommand.Parameters.Add(R

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1