数据库课程设计报告-图书销售系统设计.doc_第1页
数据库课程设计报告-图书销售系统设计.doc_第2页
数据库课程设计报告-图书销售系统设计.doc_第3页
数据库课程设计报告-图书销售系统设计.doc_第4页
数据库课程设计报告-图书销售系统设计.doc_第5页
已阅读5页,还剩14页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

华中科技大学 数据库课程设计报告本科实验报告课程名称:数据库课程设计报告姓 名:学 院:计算机科学与技术院 系:计算机科学与技术专 业:计算机科学与技术年 级:学 号:指导教师:2007年 9月15日一 . 课程设计目的和要求1. 熟悉大型数据库管理系统的结构与组成;2. 熟悉数据库应用系统的设计方法和开发过程;3. 掌握一种大型数据库管理系统(dm5、oracle或sql server)的应用技术和开发工具的使用;4. 熟悉数据库设计工具的使用;5. 熟悉数据库安全的相关知识和技术;6. 熟悉数据库系统的管理和维护。二 . 咚咚图书销售系统设计说明书1.概要说明 本系统开发平台: + sql server 2005 本系统采用架构: petshop 本系统运行环境: windows xp 或以上版本(安装iis5.0以上版本) 2.模块设计本系统总共划分以下几个模块:a. 图书编目b. 图书查找c. 图书进货(修改已经编目的图书数量,同时调整价格)d. 图书退货e. 会员添加/修改/删除f. 出版社管理g. 会员组管理h. 用户状态管理i. 零售购买j. 零售退货k. 图书销售/退货统计l. 系统设置i. 表设计图书编目 列名数据类型可否为空说明idint(4)not null主键、自动增长isbnvchar(20)not null图书isbn booknamevchar(20)not null图书名称authorvchar(20)null图书作者editionvchar(20)null图书版本bookconcernidint(4)not null图书出版社formatvchar(20)null图书开本publisttimedatetime(8)null出版日期totalpagesint(4)null总页数pricefloatnot null定价summaryvchar(200)null 图书简介classvchar(10)not null图书类别stocksint(4)not null库存量coverpicvchar(20)null图书封面图片cost floatnot null成本levelint(4)null推荐等级addtimedatetime(8)null图书编目日期其中bookid为主键, bookconcernid是表bookconcern 中convernid的外码,class是表bookclass中classid 的外码图书进货列名数据类型可否为空说明idint(4)not null主键、自动增长orderidvchar(20)not null进货订单号 concernidvchar(20)not null图书出版社idnumint(4)not null图书数目updatecostfloatnot null修改后的图书价格addtimedatetimenot null进货日期agocostfloatnot null图书以前价格nowcostfloat not null本次进货价格bookidint(4)not null图书id其中id为主键, bookconcernid是表bookconcern 中convernid的外码,bookid是表book中bookid 的外码图书进货(主键,进货订单,图书出版社id,图书数目,进货日期,图书以前价格,本次进货价格,图书id)图书退货列名数据类型可否为空说明idint(4)not null主键、自动增长orderidvchar(20)not null进货订单号 concernidvchar(20)not null图书出版社idnumint(4)not null图书数目addtimedatetimenot null进货日期costfloatnot null图书价格bookidint(4)not null图书id其中id为主键, bookconcernid是表bookconcern 中convernid的外码,bookid是表book中bookid 的外码图书退货(主键,进货订单编号,图书出版社id,图书数目,进货日期,图书价格,本次进货价格,图书id)图书类别列名数据类型可否为空说明classidint(4)not null主键、自动增长,类别idclassnamevchar(20)not null图书类别名 parentclassint(4)not null上一级类别的idextravchar(200)null额外信息其中classid为主键.图书出版社列名数据类型可否为空说明concernidint(4)not null主键、自动增长,出版社idconnamevchar(20)not null出版社名 conaddressvchar(30)null出版社地址contelvchar(20)null出版社电话conwebsitevchar(20)null出版社网址conemailvchar(20)null出版社email其中concernid为主键.图书出版社(出版社id,出版社名,出版社地址,出版社电话,出版社网址,出版社email)图书零售列名数据类型可否为空说明idint(4)not null主键、自动增长orderidvchar(20)not null零售单号 useridint(4)not null用户idnumint(4)not null图书数目returnkeyvchar(10)not null小票addtimedatetimenot null进货日期discountfloatnot null图书折扣operatoridint(4)not null操作员iddescriptionvchar(200)null其他描述bookidint(4)not null图书id其中id为主键, bookid是表book 中bookid的外码,userid是表user中id 的外码,当userid为-1时表示此次零售是普通用户,否则则是会员购买!零售(主键,零售单号,用户id,图书数目,进货日期,图书折扣,管理员id,图书id)会员表 列名数据类型可否为空说明idint(4)not null主键、自动增长usertypeint(4)not null会员组编号usernamevchar(20)null会员名pwdvchar(20)not null密码integralint(4)not null会员积分emailvchar(20)null会员emailaddressvchar(20)null地址postalcodevchar(10)null邮编telvchar(10)null电话descriptionvchar(200)null其他描述idcardvchar(50)not null 身份证rmbfloatnot null余额periodofvaliditydatetime(8)not null会员有效期serialnumbervchar(20)not null会员编号statusint(4)not null会员状态sexboolnull性别addtimedatetime(8)null添加日期其中id为主键, usertype是表usertype 中usertype_id的外码, status是表 userstatus 中id 的外码触发器 : modifyjifen该触发器的作用是当改变了某一个会员的会员组类别的时候,系统将自动调整其积分,使得积分回归该会员组定义的积分限之内-set ansi_nulls onset quoted_identifier ongoalter trigger modifyjifen on dbo.user after insert asdeclare userid int declare integral int declare usertype intselect userid=id,usertype=usertype,integral=integral from inserteddeclare integral_low int,integral_up intselect integral_low=integral_low,integral_up=integral_up from usertype where usertype_id=usertypeif integralintegral_upbeginupdate user set integral=integral_low where id=useridend-会员组列名数据类型可否为空说明usertype_idint(4)not null主键、自动增长,会员组idusertype_namevchar(20)not null会员组名称 discountfloatnot null会员组折扣integral_lowint(4)not null积分下限integral_upint(4)not null积分上限descriptionvchar(200)null描述信息其中usertype_id为主键. 会员组(主键、自动增长,会员组id,会员组名称,会员组折扣,积分下限,积分上限,描述信息)触发器 : modify_low_up该触发器的作用是当改变了某一个会员组的积分上限或者下限的时候,系统将自动调整其相邻的会员组的下限或者上限-set ansi_nulls onset quoted_identifier ongoalter trigger modify_low_up on dbo.usertype after updateas declare integrallow int,integrallow0 int declare integralup int,integralup0 int declare usertypeid intselect usertypeid=usertype_id,integrallow=integral_low,integralup=integral_up from inserted select integrallow0=integral_low,integralup0=integral_up from deleted -select 记录号 from inserted修改后的 -select 记录号 from deleted修改前的 declare integrallow2 int,integralup2 int,usertypeid2 intset integrallow2=-1set integralup2=-1if integrallow0integrallowbeginselect usertypeid2=usertype_id,integrallow2=integral_low,integralup2=integral_up from usertype where integral_up=integrallow0-1if integrallow2-1beginupdate usertype set integral_up=integrallow-1 where usertype_id=usertypeid2endendif integralup0integralupbeginselect usertypeid2=usertype_id,integrallow2=integral_low,integralup2=integral_up from usertype where integral_low=integralup0+1if integrallow2-1beginupdate usertype set integral_low=integralup+1 where usertype_id=usertypeid2endend-会员状态列名数据类型可否为空说明idint(4)not null主键、自动增长,状态iduserstatusvchar(20)not null状态名称 descriptionvchar(200)null描述信息其中id为主键.ii. 视图设计bookinfo: 表book和 表bookconcern通过concernid内连接生成.booksell_userinfo_bookinfo: 视图bookinfo和 表userinfo通过bookid和userid外连接生成.userinfo: 表user和 表usertype 和 userstatus 通过usertype_id 和userstatus_id内连接生成.tuihuo/xiaoshou: 表booksell和 视图bookinfo 和 userinfo 通过userid 和bookid外连接生成.以下是部分连接语句:1. 视图 bookinfoselect dbo.book.bookid, dbo.book.isbn, dbo.book.bookname, dbo.book.author, dbo.book.edition, dbo.book.bookconcernid, dbo.bookconcern.conname, dbo.book.format, dbo.book.publishtime, dbo.book.totalpages, dbo.book.price, dbo.book.summary, dbo.book.stocks, dbo.book.class1, dbo.book.class2, dbo.book.class3, bookclass_1.classname as classname1, bookclass_2.classname as classname2, bookclass_3.classname as classname3, dbo.book.coverpic, dbo.book.cost, dbo.book.level, dbo.book.userrate, dbo.book.addtime, dbo.booksmetcount, dbo.bookstat.clickcountfrom dbo.book inner join dbo.bookconcern on dbo.book.bookconcernid = dbo.bookconcern.concernid inner join dbo.bookstat on dbo.book.bookid = dbo.bookstat.bookid left outer join dbo.bookclass as bookclass_3 on bookclass_3.classid = dbo.book.class3 left outer join dbo.bookclass as bookclass_2 on dbo.book.class2 = bookclass_2.classid left outer join dbo.bookclass as bookclass_1 on dbo.book.class1 = bookclass_1.classidselect dbo.bookinfo.isbn, dbo.bookinfo.bookname, dbo.bookinfo.author, dbo.bookinfo.edition, dbo.bookinfo.bookconcernid, dbo.bookinfo.conname, dbo.bookinfo.format, dbo.bookinfo.publishtime, dbo.bookinfo.totalpages, dbo.bookinfo.price, dbo.bookinfo.summary, dbo.bookinfo.stocks, dbo.bookinfo.classname1, dbo.bookinfo.classname2, dbo.bookinfo.classname3, dbo.userinfo.username, dbo.booksell.bookid, dbo.booksell.userid, dbo.booksell.description, dbo.booksell.addtime, dbo.booksell.returnkey, dbo.booksell.num, dbo.userinfo.pwd, dbo.userinfo.email, dbo.userinfo.address, dbo.userinfo.postalcode, dbo.userinfo.tel, dbo.userinfo.idcard, dbo.userinfo.rmb, dbo.userinfo.periodofvalidity, dbo.userinfo.serialnumber, dbo.useriegral, dbo.userinfo.usertype_name, dbo.userinfo.userstatusid, dbo.userinfo.usertype_id, dbo.userinfo.userstatus, dbo.userinfo.authentication, dbo.userinfo.discount, dbo.userinfo.sex, dbo.booksell.orderid, dbo.booksell.discount as dis, dbo.booksell.operatorid, dbo.booksell.statu, dbo.bookinfo.costfrom dbo.booksell inner join dbo.bookinfo on dbo.booksell.bookid = dbo.bookinfo.bookid left outer join dbo.userinfo on dbo.booksell.userid = dbo.userinfo.id2. 视图booksell_userinfo_bookinfoiii. 存储过程1. 会员搜索的实现由于会员有很多的属性,包括性别,编号,添加日期,会员组,会员状态等等,同时又要实现分页显示, 所以该存储过程必须能根据条件来进行不同的查询,同时要返回符合条件的记录总数和某一页(用户需求)的记录,以供前台调用显示.首先声明了需要进行判断的参数,然后对用户传参进行判断,如果保持默认值表示不需要对该条件进行添加,否则必须加上该条件.以此类推,直到对所有条件进行判断. 然后因为要实现分页显示,必须计算从哪一条记录开始,选取多少页,这里就应该是选择pagesize条记录,应该从pagesize*(pageindex-1)这里开始选取,这里在返回符合条件的总记录数的时候碰到了问题,因为在存储过程中每次exec执行后,都会将结果返回到客户端,所以获取总条数不能调用这个方法,这里我采用了一个投机取巧的办法勉强实现了,因为对某些函数不熟悉,所以下次还是需要好好摸索下.实现代码:-set ansi_nulls onset quoted_identifier ongoalter procedure dbo.searchuser (idcard nvarchar(50)=-1,username nvarchar(50)=-1,serialnumber nvarchar(50)=-1,usertype int=-1,userstatus int=-1,addtime1 nvarchar(50)=1900-01-01,addtime2 nvarchar(50)=2900-01-01,pageindex int=1,pagesize int=15,mycount int=0 out)asdeclare sql nvarchar(2000)declare sql_count nvarchar(2000)set sql=select top +cast(pagesize as varchar(32)+ * from userinfo where 10set sql_count=update user set wanttoread=1 where 10if idcard-1beginset sql=sql+ and idcard like %+cast( idcard as nvarchar)+%set sql_count=sql_count+ and idcard like %+cast( idcard as nvarchar)+%end if username-1beginset sql=sql+ and username like %+cast( username as nvarchar)+%set sql_count=sql_count+ and username like %+cast( username as nvarchar)+%end if serialnumber-1beginset sql=sql+ and serialnumber like %+cast( serialnumber as nvarchar)+%set sql_count=sql_count+ and serialnumber like %+cast( serialnumber as nvarchar)+%end if usertype-1beginset sql=sql+ and usertype_id=+cast(usertype as nvarchar)set sql_count=sql_count+ and usertype=+cast(usertype as nvarchar)endif userstatus-1beginset sql=sql+ and userstatusid=+cast(userstatus as nvarchar)set sql_count=sql_count+ and status=+cast(userstatus as nvarchar)endif addtime1-1 and addtime2-1beginset sql=sql+ and addtime+convert(varchar(50),addtime1,120)+ and addtime+convert(varchar(50),addtime1,120)+ and addtime0if idcard-1beginset sql=sql+ and idcard like %+cast( idcard as nvarchar)+%end if username-1beginset sql=sql+ and username like %+cast( username as nvarchar)+%end if serialnumber-1beginset sql=sql+ and serialnumber like %+cast( serialnumber as nvarchar)+%end if usertype-1beginset sql=sql+ and usertype_id=+cast(usertype as nvarchar)endif userstatus-1beginset sql=sql+ and userstatusid=+cast(userstatus as nvarchar)endif addtime1-1 and addtime2-1beginset sql=sql+ and addtime+convert(varchar(50),addtime1,120)+ and addtime+convert(varchar(50),addtime2,120)+endset sql=sql+ order by addtime desc) order by addtime desc exec ( sql) print(sql)print(sql_count)return-接收返回值 -declare rows int - exec rows = sptest-2. 图书搜索的实现(同会员搜索)3. 图书插入- set ansi_nulls onset quoted_identifier ongoalter procedure dbo.insertbook( isbn varchar(50), bo

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论