数据库大作业网上书店管理系统

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

《数据库课程设计》设计选题:网上书店管理系统班级:船海1101设计人:郭英豪学号:U201115491辅导教师:董敏钦一、需求分析1.1数据需求网上书店管理信息系统需要完成功能主要有:1.各种书籍基本信息的输入,包括书名,ISBN号,出版年份,价格。2.书籍基本信息的查询、修改,包括书名,ISBN号,出版年份,价格等。3.书籍作者基本信息的输入,包括姓名,地址,个人主页。4.书籍作者基本信息的查询、删除,包括姓名,地址,个人主页等。5.出版社信息的输入,包括出版社名称,地址,电话,网站等。6.出版社基本信息的查询、删除,包括出版社名称,地址,电话,网站等。7.购物车相关信息的输入,包括购物车号,购买数量。8.购物车信息的查询、修改,包括购物车号,购买数量等。9.消费者相关信息的输入,包括姓名,邮箱,地址,电话。10.消费者相关信息的查询、修改,包括姓名,邮箱,地址,电话等。11.仓库相关信息的输入,包括仓库号,地址,电话,存书量。12.仓库相关信息的查询、修改,包括仓库号,地址,电话,存书量等。1.2事物需求(1)在书籍信息管理部分,要求:a.可以浏览书籍、作者及其出版社信息。b.可以对书籍、作者及其出版社信息进行添加及删除的操作。(2)在图书网上销售信息管理部分,要求:a.可以查询消费者的相关信息以及他拥有的购物车和购书量的信息。b.可以对消费者的相关信息以及他拥有的购物车和购书量的信息进行维护,包括添加及删除的操作。(3)在图书仓储管理部分,要求:。a.可以浏览各个仓库的藏书信息。b.可以对仓库藏书信息进行维护操作。二、数据库设计2.1实体模型:11NNNNMM11作者写作购物车图书仓库出版社顾客出版存放购买属于2.2ER图到关系图的转换(其中带下划线的为主属性)stosksshopping-basketcontainsauthorURLnameaddresswritten-byyearpublished-bypublishernamephoneaddressURLbooktitlepriceISBNnumbershopping-basketbasketIDbasket-ofshopping-basketnameaddressemailphonenumberaddressphonecode2.3数据字典Author表book表btoa表btop表Publisher表customer表Shopping-basket表Btos表Warehouse表Btop表三、关系图的建立四、功能实现4.1创建数据库:createdatabasebookshop;4.2创建数据表:(1)book表createtablebook(ISBNintprimarykey,titlechar(20),wyearsmallint,pricereal);(2)author表createtableauthor(namechar(20),waddresschar(40),URLchar(50)primarykey(name,waddress));(3)btoa表createtablebtoa(ISBNintprimarykey,namechar(20),waddresschar(40),foreignkey(ISBN)referencesbook(ISBN),foreignkey(name,waddress)referencesauthor(name,waddress));(4)publisher表createtablepublisher(namechar(20)primarykey,paddresschar(40),phoneint,URLchar(50));(5)btop表createtablebtop(ISBNintprimarykey,namechar(20),foreignkey(ISBN)referencesbook(ISBN),foreignkey(name)referencespublisher(name));(6)customer表createtablecustomer(cemailchar(50)primarykey,namechar(20),caddresschar(40),phoneint);(7)shopping_basket表createtableshopping_basket(basketIDintprimarykey,cemailchar(50),foreignkey(cemail)referencescustomer(cemail));(8)btos表createtablebtos(ISBNint,basketIDint,numbersmallint,primarykey(ISBN,basketID),foreignkey(ISBN)referencesbook(ISBN),foreignkey(basketID)referencesshopping_basket(basketID));(9)warehouse表createtablewarehouse(codesmallintprimarykey,phoneint,whaddresschar(40));(10)btow表createtablebtow(ISBNint,codesmallint,numbersmallint,primarykey(ISBN,code),foreignkey(ISBN)referencesbook(ISBN),foreignkey(code)referenceswarehouse(code));五、数据操作(插入、查询、删除、修改、添加)5.1插入(1)向book表插入信息insertintobookvalues('1644','追风筝的人','2003','25');insertintostudentvalues('28317','致青春','2012','29.8');insertintostudentvalues('838971','了不起的盖茨比','1876','14.8');(2)向author表插入信息insertintoauthorvalues('菲茨杰拉德','华中科技大学',');insertintoauthorvalues('胡塞尼','武汉大学',');insertintoauthorvalues('辛夷坞','华中农业大学',');(3)向btoa表插入信息insertintobtoavalues('1644','胡塞尼','武汉大学');insertintobtoavalues('28317','辛夷坞','华中农业大学');insertintobtoavalues('838971','菲茨杰拉德','华中科技大学');(4)向publisher表插入信息insertintopublishervalues('朝华出版社','北京','63818440',');insertintopublishervalues('航空工业出版社','北京','120',');insertintopublishervalues('人民出版社','上海','110',');(5)向btop表插入信息insertintobtopvalues('1644','人民出版社');insertintobtopvalues('28317','朝华出版社');insertintobtopvalues('838971','航空工业出版社');(6)向customer表插入信息insertintocustomervalues('11111@sina.com','嘻嘻','湖南大学','114');insertintocustomervalues('18665824629@163.com','哈哈','清华大学','911');insertintocustomervalues('365282758@qq.com','郭英豪','华中科技大学','119');(7)向shopping_basket表插入信息insertintoshopping_basketvalues('1','365282758@qq.com');insertintoshopping_basketvalues('2','18665824629@163.com');insertintoshopping_basketvalues('3','11111@sina.com');(8)向btos表插入信息insertintobtosvalues('1644','1','2');insertintobtosvalues('28317','3','4');insertintobtosvalues('838971','2','3');(9)向warehouse表插入信息insertintowarehousevalues('1001','674382','武汉市');insertintowarehousevalues('1002','674383','长沙市');insertintowarehousevalues('1003','674384','上海市');(10)向btow表插入信息insertintobtowvalues('1644','1002','800');insertintobtowvalues('28317','1003','女','10000');insertintobtowvalues('838971','1001','女','500');5.2查询(1)查询价格低于28元的书籍的作者的相关信息:selectauthor.*fromauthor,btoa,bookwherebook.ISBN=btoa.ISBNandbtoa.name=author.nameandbook.ISBNin(selectbook.ISBNfrombookwhereprice28);(2)查询将《致青春》放入购物车的顾客的相关信息selectdistinctcustomer.*fromcustomer,shopping_basket,btos,bookwherebtos.basketID=shopping_basket.basketIDandshopping_basket.cemail=customer.cemailandbtos.ISBN=(selectbook.ISBNfrombookwheretitle='致青春');(3)查询地址在北京的出版社的名称,电话,网页selectname,phone,URLfrompublisherwherepaddress='北京';(4)查询所有书的仓储记录,包括书的名字和仓库的地址,并将结果按仓储量降序排列selectbook.title,btow.*,warehouse.whaddressfrombook,btow,warehousewherebook.ISBN=btow.ISBNandbtow.code=warehouse.codeorderbynumberdesc;(5)查询各个仓库的总仓储量selectcode仓库代号,SUM(number)总仓储量frombtowgroupbycode;(6)查询名字姓“郭”字的顾客的购物车代号selectname姓名,basketID购物车代号fromshopping_basket,customerwherenamelike'郭%'andshopping_basket.cemailin(selectcemailfromcustomerwherenamelike'郭%');5.3创建视图(1)创建所有1001号仓库的藏书记录的视图createviewshitu1(ISBN,书名,数量)asselectbtow.I

1 / 13
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功