景点门票销售管理系统数据库设计

  • 格式:doc
  • 大小:131.41 KB
  • 文档页数:20

景点门票销售管理系统数据库设计李丙崇学生姓名:2010508009学号:任欣月学生姓名:2010508041学号:计算机科学与技术专业:于宝华指导老师:1.目录1引言33编写目的............................................................1.1 3................................................................1.2背景3...........................................................参考资料1.34需求分析242.1................................................................目标4............................................................2.2运算坏境4...........................................................需求概述2.35结构设计35逻辑结构设计........................................................3.15E-R图 3.1.1局部63.1.2全局E-R图73.1.3关系模式8关系图3.1.1 8........................................................3.2物理结构设计10存储过程4. 10.........................................统计指定日期的门票销售情况4.1104.2.........................................统计指定月份的门票销售情况11统计指定日期各种价格的门票销售情况4.3................................. 12...................................统计指定营业员指定日期的收费情况4.313触发器515完整性约束616数据库备份7.2.1引言随着全球信息化的发展,我们也步入信息时代,各类管理也更加系统化,公司利用管理信息系统来管理各类业务已经非常普遍。

各类系统也相应的得到飞速发展,为了让我们的管理更加系统,更加清晰,更加科学,从而也开发了一个简单,易操作的管理管理系统。

1.1编写目的根据门票销售管理的特点对被开发软件系统的主要功能、性能进行完整描述,为,软件开发进行详细设计和编程提供基础。

为软件提供测试和验收的依据,即为选取测试用例和进行验收的依据。

1.2背景a.该软件系统的名称:门票管理信息系统;本项目的任务提出者:b.石河子大学本项目的开发者:c.任欣月李丙崇,本项目用户:d.景点门票销售部1.3参考资料[1]王珊,萨师煊.数据库系统概论[M].高等教育出版社,2006年5月第4版[2]郑人杰,马素霞,殷人昆.软件工程概率[M].机械工业出版社,2009年11月[3]马晓梅.SQL Server实验指导[M].清华大学出版社,2009年9月第3版3.2需求分析2.1目标这个门票管理系统主要是处理旅客买票,订票,退票,以及各类查询结算。

该系统针对的用户是门票销售部门,由于门票销售,查询以及计算各天或者不同时间段的收入比较繁琐,此系统方便简单的实现了这些功能,使得管理员与职工方便很多,让这个门票销售都变得条条有理。

2.2运算坏境(1)软件资源服务器端软件选择的具体说明:操作系统:Windows2007Server或Windows XP。

数据库管理系统:SQL Server。

开发工具:visual studio2008.软件平台:windows+iis+mssql。

客户端软件选择的具体说明:web浏览器。

2.3需求概述本系统的开发是为了提高门票销售以及管理的效率,尽可能杜绝各个销售环节中可能出现的资金流失不明现象,满足系统化的门票管理域收入需求。

系统功能主要包括:登陆管理(包括管理员登陆以及职工登陆,职工注册情况),系统管理(系统启用,及其系统截止),直接销售(个人购买与团购),订票管理(订票与查看订票状态),退票管理(处理当天所要退的票),查询管理(按时间查询,按职工号查询,游客种类查询,按时间票号查询,按时间,职工号查询,按时间,游客种类查询,以及当天销售查询),结算管理(具体时间查询以及时间段查询),最后是系统简介。

4.结构设计3逻辑结构设计3.1图E-R3.1.1局部图营业员E-R图4.图5.游客E-R图图E-R门票6.图5.图门票类型图E-R 7. 3.1.2全局E-R图图8总体E-R图6.3.1.3关系模式Admin_T(Sell_operator,User_name,password,Sex,Realname,Cardnumber,Age,Phone,Us er_type)该表为管理表,表项包括销售营业员,用户姓名,密码,性别,真实姓名,卡号,年龄,电话号码,用户类型的信息。

主键为销售营业员。

(Dd_TOrder_ID,Custom_ID,Ticker_ID,Ticker_type,Ticker_Price,Sell_operator,S ell_date,Sell_month)该表为订单表,表项有订单号,游客号,门票号,门票类型,门票价格,销售营业员,销售日期和销售月份。

该表的主键为订单号,外键有游客号,门票号,门票类型,门票价格和销售营业员。

(Custom_ID,Custom_name,Sex,Age,Cardnumber,Custom_type,Custom_phonCust om_Te)该表为游客信息表,表项有游客号,游客姓名,身份证号,游客类型,游客电话。

该表主键为游客号,无外键。

Sell_amount,Sell_money,Sell_month)Ticket_summary(Sell_ID,Ticket_type,该表为门票信息统计表,表项有出售号码,门票类型,出售时间,出售月份,出售价格。

该表主键为出售号,外键为门票类型。

(Ticket_type,Ticket_type_name,Ticket_price,Ticket_Count,Ticket_coTick et_Tmment,Date)该表为门票信息表,表项有门票类型,类型名,门票价格,门票数量,日期。

主键为门票类型,无外键。

(Ticket_ID,Ticket_type,Sell_flag)Ticket_List该表为门票属性信息表,表项为门票号,门票类型,和是否出售标记。

主键为门票号,外键为门票类型。

7.3.1.1关系图3.2物理结构设计表1Admin_T表列名数据类型允许空NO NULL Sell_operator nvarchar(10)NOvarchar(20)NULL User_nameNO NULL Password varchar(20)NULL Sex char(5)NULL varchar(20)RealnameNULLcardnumberchar(18)NULL intAgeNULL Phone char(11)NULLUser_type char(10)表2Custom_T表数据类型允许空列名NO char(10)Custom_IDNULLNO Custom_namevarchar(20)NULLNULLSex char(5)NULLAge intNULLCardnumber char(18)NULL char(10)Custom_typeNULL Custom_phonechar(11)8.表3dd_T表数据类列允许NOrder_INULchar(10Nchar(10Custom_INULNNULTicket_Ichar(17NNULchar(3Ticket_typNdecimal(5,2NULTicket_PricNNULnvarchar(10Sell_operatorNOSell_date NULLdatetime NO Sell_month nvarchar(10)NULL表Ticket_List表4允许空列名数据类型NOchar(17)Ticket_ID NULLNULL Ticket_type char(3)NULL intSell_flag表Ticket_summary表5允许空数据类型列名NOSell_ID char(20)NULLNOchar(3)Ticket_type NULLNULLdatetimeSell_dateNULL Sell_amount intNULL Sell_money decimal(5,2)NULLnvarchar(10)Sell_month表6表Ticket_T允许NULNULNNULNNULNNULNNUL4.存储过程4.1统计指定日期的门票销售情况create Procedure Pro_QTicsinf@starttime datetime,@endtime datetime,@sSell_amount_out int output, @sSell_money_out decimal(5,2)outputAS select@sSell_amount_out=count(Ticket_ID),@sSell_money_out=sum(dd_T.Ticket_Price)fromdd_T,Ticket_Twhere Ticket_T.Ticket_type=dd_T.Ticket_type and Sell_date between@starttime and@endtimedeclare@starttimedatetime,@endtime datetime,@sSell_amount_out int, @sSell_money_out decimal(5,2)select@starttime='2013/1/1300:00:00'select@endtime='2013/1/1319:40:00'exec Pro_QTicsinf@starttime,@endtime,@sSell_amount_outoutput,@sSell_money_out outputselect@sSell_amount_out as门票数量,@sSell_money_out as金额4.2统计指定月份的门票销售情况create Procedure Pro_QTicsminf@sSell_month nvarchar(10),@sSell_amount_out intoutput,@sSell_money_outdecimal(5,2)outputAS select@sSell_amount_out=count(Ticket_ID),@sSell_money_out=sum(dd_T.Ticket_Price)fromdd_T,Ticket_Twhere Ticket_T.Ticket_type=dd_T.Ticket_type andSell_month=@sSell_month10.declare@sSell_month nvarchar(10),@sSell_amount_out int,@sSell_money_out decimal(5,2)select@sSell_month='2013/1'exec Pro_QTicsminf@sSell_month,@sSell_amount_outoutput,@sSell_money_outoutputselect@sSell_amount_out as门票数量,@sSell_money_out as金额4.3统计指定日期各种价格的门票销售情况create Procedure Pro_QTicsPinf@starttime datetime,@endtime datetime,@sTicket_type char(3),@sTicket_Price_out decimal(5,2)output,@sSell_amount_out int output, @sSell_money_out decimal(5,2)outputAS select@sTicket_Price_out=Ticket_Price,@sSell_amount_out=count(Ticket_ID),@sSell_money_out=sum(dd_T.Ticket_Price)fromdd_Twhere@sTicket_type=dd_T.Ticket_type and Sell_date between@starttime and@endtimegroup by Ticket_Pricedeclare@starttimedatetime,@endtime datetime,@sTicket_type char(3), @sTicket_Price_out decimal(5,2),@sSell_amount_out int,@sSell_money_out decimal(5,2)select@starttime='2013/1/1300:00:00'select@endtime='2013/1/1319:40:00'select@sTicket_type='T01'exec Pro_QTicsPinf@starttime,@endtime,@sTicket_type,@sTicket_Price_outoutput,@sSell_amount_out output,@sSell_money_out outputselect@sTicket_Price_out as门票价格,@sSell_amount_out as门票数量, 11.@sSell_money_out as门票金额select@sTicket_type='T02'exec Pro_QTicsPinf@starttime,@endtime,@sTicket_type,@sTicket_Price_outoutput,@sSell_amount_out output,@sSell_money_out outputselect@sTicket_Price_out as门票价格,@sSell_amount_out as门票数量, @sSell_money_out as门票金额select@sTicket_type='T03'exec Pro_QTicsPinf@starttime,@endtime,@sTicket_type,@sTicket_Price_outoutput,@sSell_amount_out output,@sSell_money_out outputselect@sTicket_Price_out as门票价格,@sSell_amount_out as门票数量, @sSell_money_out as门票金额4.3统计指定营业员指定日期的收费情况create Procedure Pro_QTicsCinf@starttime datetime,@endtime datetime,@sSell_operator nvarchar(10), @sSell_amount_out int output,@sSell_money_out decimal(5,2)output AS select@sSell_amount_out=count(Ticket_ID),@sSell_money_out=sum(dd_T.Ticket_Price)fromdd_Twhere@sSell_operator=dd_T.Sell_operator and Sell_date between@starttime@endtimeandSell_operatorby groupdatetime,@sSell_operator@endtimedatetime,declare@starttime nvarchar(10),2)@sSell_money_outdecimal(5,@sSell_amount_out int,00:00:00'@starttime='2013/1/13select23:40:00'select@endtime='2013/1/13@sSell_operator='001'select12.exec Pro_QTicsCinf@starttime,@endtime,@sSell_operator,@sSell_amount_outoutput,@sSell_money_out outputselect@sSell_operator as营业员,@sSell_amount_out as销售门票数量,@sSell_money_out as收费总金额select@sSell_operator='002'exec Pro_QTicsCinf@starttime,@endtime,@sSell_operator,@sSell_amount_outoutput,@sSell_money_out outputselect@sSell_operator as营业员,@sSell_amount_out as销售门票数量,@sSell_money_out as收费总金额5触发器a.有人买票时,自动更改门票标志位create triggerTRIGGER_BUY_TICon dd_T for insertasbeginDeclare@Ticket_ID_IN char(17)Select@Ticket_ID_IN=Ticket_ID from insertedupdate Ticket_List set Sell_flag=1where Ticket_ID=@Ticket_ID_INendinsertintodd_Tvalues('O006','1005','S0006','T02',40,'001','2013/2/13 19:50:00','2013/2')b.若有人退票,对各表所有有关该人的信息进行级联删除create trigger TRiGGER_EXIT_TICon dd_T for deleteas13.beginDeclare@Order_ID_DELchar(10),@Custom_ID_DELchar(10),@Ticket_ID_ALT char(17)Select@Order_ID_DEL=Order_ID,@Custom_ID_DEL=Custom_ID,@Ticket_ID_ALT=Ticket _IDfrom deletedupdate Ticket_List set Sell_flag=0where Ticket_ID=@Ticket_ID_ALTdelete from Custom_Twhere Custom_ID=@Custom_ID_DELendgoDELETE from dd_T where Order_ID='O006'c.当门票销售时自动减少该该类型门票的总量create trigger tri_Tic_Sellon Ticket_summary for insertas declare@oldcount int,@newcount int,@sTicket_type char(3)select@sTicket_type=Ticket_type,@newcount=Sell_amount from inserted select@oldcount=Ticket_CountfromTicket_TwhereTicket_type=@sTicket_typeif@newcount>0and@oldcount>0beginupdateTicket_TsetTicket_Count=@oldcount-@newcountwhereTicket_type=@sTicket_typereturnendrollback transactioninsertintoTicket_summaryvalues('C0004','T01','2013-01-1718:47',14.'002',2,40,'2013-01')d.当门票修改类型时自动修改门票各类型的数量create trigger tri_Ticxgon Ticket_List for updateasdeclare@sTic_IDchar(17),@sTicket_typechar(3),@saTicket_type char(3),@scount int,@sacount intselect@sTicket_type=Ticket_type,@sTic_ID=Ticket_ID from inserted wherefromTicket_Listselect@saTicket_type=Ticket_typeTicket_ID=@sTic_IDwhere@scount=Ticket_CountfromTicket_TselectTicket_type=@sTicket_typewhereselect@sacount=Ticket_CountfromTicket_TTicket_type=@saTicket_typebeginwheresetTicket_Count=@scount+1updateTicket_TTicket_type=@sTicket_typereturnwheresetTicket_COunt=@sacount-1Ticket_TupdateTicket_type=@saTicket_typereturnendtransaction rollbackTicket_ID='S0001'update Ticket_List whereTicket_type='T02'set完整性约束6Attraction_ManageUSEgocheckwithAdmin_T tablealter15.add constraint CHECK_SEX check(Sex='男'or Sex='女'),constraint CHECK_AGE check(Age>=0)goalter table Custom_T with checkadd constraint CHECK1_SEX check(Sex='男'or Sex='女'),constraint CHECK1_AGE check(Age>=0)goalter table Admin_alter table Ticket_summary with checkadd constraint CHECK_Sell_amount check(Sell_amount>=0), check(Sell_money>=0.00)CHECK_Sell_moneyconstraint数据库备份7.完整数据库备份7.1Attraction_Manage usegoAttraction_Managedatabase backup\Fbackup_Attraction_Manage'disk='E:\备份数据库to initwithgo完整数据库恢复7.2master usegoAttraction_Managedatabase restore\Fbackup_Attraction_Manage'备份数据库disk='E:\fromREPLACE withgo差异数据库备份7.3Attraction_Manageuse16.backup database Attraction_Manageto disk='E:\备份数据库\Dbackup_Attraction_Manage'with differentialgo7.4差异数据库备份恢复use mastergorestore database Attraction_Managefrom disk='E:\备份数据库\Fbackup_Attraction_Manage'with norecoverygorestore database Attraction_Managefrom disk='D:\备份数据库\Dbackup_Attraction_Manage' replace withgo17.。