首页 图书管理系统数据库设计-MYSQL实现

图书管理系统数据库设计-MYSQL实现

举报
开通vip

图书管理系统数据库设计-MYSQL实现图书管理系统数据库设计-MYSQL实现图书管理系统数据库设计一、系统概括1、系统简介图书管理是每个图书室都需要进行的工作。一个设计优秀的图书管理系统数据库能够给图书管理带来很大的便利。2、需求剖析图书管理系统的需求定义为:学生能够直接经过借阅终端来查阅书本信息,同时也能够查阅自己的借阅信息。当学生需要借阅书本时,经过账号密码登岸借阅系统,借阅系统办理学生的借阅,同时改正图书室保留的图书信息,改正被借阅的书本能否还有节余,同时更新学生个人的借阅信息。学生借阅图书以前需要将自己的个人信息注册,登岸时比较学生信息。学生直...

图书管理系统数据库设计-MYSQL实现
图书管理系统数据库设计-MYSQL实现图书管理系统数据库设计一、系统概括1、系统简介图书管理是每个图书室都需要进行的工作。一个设计优秀的图书管理系统数据库能够给图书管理带来很大的便利。2、需求剖析图书管理系统的需求定义为:学生能够直接经过借阅终端来查阅书本信息,同时也能够查阅自己的借阅信息。当学生需要借阅书本时,经过账号密码登岸借阅系统,借阅系统办理学生的借阅,同时改正图书室保留的图书信息,改正被借阅的书本能否还有节余,同时更新学生个人的借阅信息。学生借阅图书以前需要将自己的个人信息注册,登岸时比较学生信息。学生直接送还图书,依据图书编码改正借阅信息1图书管理系统数据库设计-MYSQL实现管理员登岸管理系统后,能够改正图书信息,增添或许删除图书信息管理员能够注销学生信息。经过需求定义,画出图书管理系统的数据流图:数据流图2图书管理系统数据库设计-MYSQL实现学生信息注册学生图书信息学生信息借阅信息学生查问登岸借阅学生送还学生借阅信息管理员信息图书信息管理员登岸图书管理学生管理管理员学生信息二、系统功能设计3图书管理系统数据库设计-MYSQL实现画出系统功能模块图并用文字对各功能模块进行详尽介绍。系统功能模块图:图书管理系统借阅者模块管理员模块接见模块增添/查问图书送还图书借阅图书查问图书借阅者登岸管理员登岸查问借阅注信册息个人信息改正图书信息查问借阅删信除息学生信息删除图书三、数据库设计方案图 关于同志近三年现实表现材料材料类招标技术评分表图表与交易pdf视力表打印pdf用图表说话 pdf 1、系统E-R模型整体E-R图:4图书管理系统数据库设计-MYSQL实现学生借阅图书管理管理员精美化的局部E-R图:学生借阅-送还E-R图:学生ID年级年纪性别诚信级学生专业学生ID送还时间图书送还表学生ID图书ID送还借阅图书借阅表图书ID处分表图书ID登记日期借阅时间学生ID处分金额超期图书作者图书ID书名数目第一版社分类管理员E-R图:5图书管理系统数据库设计-MYSQL实现姓名年纪ID号所属单位管理员联系电话管理管理类型编号类又名称学生图书属于图书类型2、设计表给出设计的表名、构造以及表上设计的完好性拘束。student:列名数据种类能否为空/性质说明stu_idintnotnull/PK注明学生独一学号stu_namevarcharnotnull学生姓名stu_sexvarcharnotnull学生性别stu_ageintnotnull学生年纪stu_provarcharnotnull学生专业6图书管理系统数据库设计-MYSQL实现stu_gradevarcharnotnull学生年级stu_integrityintnotnull/default=1学生诚信级book:列名数据种类能否为空/性质说明book_idintnotnull/PK独一书本序号book_namevarcharnotnull书本名称book_authorvarcharnotnull书本作者book_pubvarcharnotnull书本第一版社book_numintnotnull书本能否在架上book_sortvarcharnotnull书本分类book_recorddatatimenull书本登记日期book_sort:列名数据种类能否为空/性质说明sort_idvarcharnotnull/PK种类编号sort_namevarcharnotnull种类名称borrow:储存学生的借书信息列名数据种类能否为空/性质说明student_idvarcharnotnull/PK学生编号book_idvarcharnotnull/PK书本编号7图书管理系统数据库设计-MYSQL实现borrow_datedatatimenull借书时间expect_return_datedatetimenull预期送还时间return_table:储存学生的送还信息列名数据种类能否为空/性质说明student_idvarcharnotnull/PK学生编号book_idvarcharnotnull/PK书本编号borrow_datedatetimenull借书时间return_datedatatimenull实质还书时间ticket:储存学生的罚单信息列名数据种类能否为空/性质说明student_idvarcharnotnull/PK学生编号book_idvarcharnotnull/PK书本编号over_dateintnull超期天数ticket_feefloatnull处分金额manager:列名数据种类能否为空/性质说明manager_idvarcharnotnull/PK管理员编号manager_namevarcharnotnull管理员姓名manager_agevarcharnotnull管理员年纪8图书管理系统数据库设计-MYSQL实现manager_phonevarcharnotnull管理员电话3、设计xx给出在各表上成立的xx以及使用的语句。student:为stu_id创立xx,升序排序sql:createindexindex_idonstudent(stu_idasc);为stu_name创立xx,而且降序排序sql:altertablestudentaddindexindex_name(stu_name,desc);插入xx操作和结果以下所示:mysql>createindexindex_idonstudent(stu_idasc);QueryOK,0rowsaffectedRecords:0Duplicates:0Warnings:0mysql>altertablestudentaddindexindex_name(stu_namedesc);9图书管理系统数据库设计-MYSQL实现QueryOK,0rowsaffectedRecords:0Duplicates:0Warnings:0mysql>book:1.为book_id创立xx,升序摆列sql:createindexindex_bidonbook(book_id);为book_record创立xx,以便方便查问图书的登记日期信息,升序:sql:createindexindex_brecordonbook(book_record);插入xx的操作和结果以下所示:mysql>createindexindex_bidonbook(book_id);QueryOK,0rowsaffectedRecords:0Duplicates:0Warnings:010图书管理系统数据库设计-MYSQL实现mysql>createindexindex_brecordonbook(book_record);QueryOK,0rowsaffectedRecords:0Duplicates:0Warnings:0borrow:1.为stu_id和book_id创立多列xx:sql:createindexindex_sid_bidonborrow(stu_idasc,book_idasc);插入xx的操作和结果以下所示:mysql>createindexindex_sid_bidonborrow(stu_idasc,book_idasc);QueryOK,0rowsaffectedRecords:0Duplicates:0Warnings:011图书管理系统数据库设计-MYSQL实现return_table:1.为stu_id和book_id创立多列xx:sql:createindexindex_sid_bidonreturn_table(stu_idasc,book_idasc);插入xx的操作和结果以下所示:mysql>createindexindex_sid_bid_ronreturn_table(stu_idasc,book_idasc);QueryOK,0rowsaffectedRecords:0Duplicates:0Warnings:0ticket:1.为stu_id和book_id创立多列xx:sql:createindexindex_sid_bidonticket(stu_idasc,book_idasc);插入xx的操作和结果以下所示:12图书管理系统数据库设计-MYSQL实现mysql>createindexindex_sid_bidonticket(stu_idasc,book_idasc);QueryOK,0rowsaffectedRecords:0Duplicates:0Warnings:0manager:1.为manager_id创立xx:sql:createindexindex_midonmanager(manager_id);插入xx的操作和结果以下所示:mysql>createindexindex_midonmanager(manager_id);QueryOK,0rowsaffectedRecords:0Duplicates:0Warnings:04、设计视图给出在各表上成立的视图以及使用的语句。13图书管理系统数据库设计-MYSQL实现1.在表studentxx创立计算机专业(cs)学生的视图stu_cs:sql:createviewstu_csasselect*fromstudentwherepro=‘cs’;操作和结果:mysql>createviewstu_csasselect*fromstudentwherestu_pro='cs';QueryOK,0rowsaffected2.在表student,borrow和bookxx创立借书者的全面信息视图stu_borrow:14图书管理系统数据库设计-MYSQL实现sql:createviewstu_borrowasselectstudent.stu_id,book.book_id,student.stu_name,book.book_name,borrow_date,adddate(borrow_date,30)expect_return_datefromstudent,book,borrowwherestudent.stu_id=borrow.stu_idandbook.book_id=borrow.book_id;操作和结果:mysql>createviewstu_borrowasselectstudent.stu_id,book.book_id,student.stu_name,book.book_name,borrow_date,adddate(borrow_date,30)expect_return_datefromstudent,book,borrowwherestudent.stu_id=borrow.stu_idandbook.book_id=borrow.book_id;QueryOK,0rowsaffected15图书管理系统数据库设计-MYSQL实现创立类型1的所有图书的视图cs_book:sql:createviewcs_bookasselect*frombookwherebook.book_sortin(selectboofrombook_sortwheresort_id=1);操作和结果显示:mysql>createviewcs_bookasselect*frombookwherebook.book_sortin(selectbook_sort.sort_name16图书管理系统数据库设计-MYSQL实现frombook_sortwheresort_id=1);QueryOK,0rowsaffected创立个人所有借书送还纪录视图stu_borrow_return:sql:createviewstu_borrow_returnasselectstudent.stu_id,student.stu_name,book.book_id,book.book_name,return_table.borrow_date,return_table.return_datefromstudent,book,return_tablewherestudent.stu_id=return_table.stu_idandbook.book_id=return_table.book_id;17图书管理系统数据库设计-MYSQL实现5、设计触发器给出在各表上成立的触发器以及使用的语句。设计触发器borrow,当某学生借书成功后,图书表相应的图书不在架上,变成0:sql:createtriggerborrowafterinsertonborrowforeachrowbeginupdatebooksetbook_num=book_num–1wherebook_id=new.book_id;end操作与结果显示:mysql>delimiter$$mysql>createtriggertrigger_borrow18图书管理系统数据库设计-MYSQL实现->afterinsertonborrow->foreachrow->begin->updatebooksetbook_num=book_num-1->wherebook_id=new.book_id;->end->$$QueryOK,0rowsaffected在插入表borrow以前,book_id=1的图书还在架上,为1:学生1借了这本书后,在borrowxx插入了一条 记录 混凝土 养护记录下载土方回填监理旁站记录免费下载集备记录下载集备记录下载集备记录下载 :在borrowxx插入这条记录后,book_id=1的图书,不在架上,为0:19图书管理系统数据库设计-MYSQL实现2.设计触发器trigger_return,还书成功后,对应的书本book_num变成1:sql:createtriggertrigger_returnafterinsertonreturn_tableforeachrowbeginupdatebooksetbook_num=book_num+1wherebook_id=new.book_id;end还书时在return_table插入表项:此时图书送还架上:20图书管理系统数据库设计-MYSQL实现定义准时器(事件)eventJob,每日自动触发一次,扫描视图stu_borrow,若发现目前有预期送还时间小于目前时间,则判断为超期,生成处分记录,这个准时器将每日准时触发储存过程proc_gen_ticket:sql:createeventifnotexistseventJobonscheduleevery1DAY/*每日触发*/oncompletionPRESERVEdocallproc_gen_ticket(getdate());/*调用储存过程*/setglobalevent_scheduler=1;altereventeventJoboncompletionpreserveenable;/*开启准时器*/操作和结果显示:1).学生1借了图书1,生成借书记录stu_borrow视图,以下:2).当他在1月27日前还书时,没有生成罚单:21图书管理系统数据库设计-MYSQL实现3).当他在1月27往后还书时,生成罚单:设计触发器trigger_credit,若处分记录超出30条,则将这个学生的诚信级设置为0,下次不同意借书:sql:createtriggertrigger_creditafterinsertonticketforeachrowbeginif(selectcount(*)fromticketwherestu_id=new.stu_id)>30then22图书管理系统数据库设计-MYSQL实现updatestudentsetstu_integrity=0wherestu_id=new.stu_id;endif;end操作和结果显示,测试时选择插入ticket项大于3,由于30太大了,不简单测试:学生1超出3次超期送还图书后,产生了4条罚单:此时触动触发器trigger_credit,将学生1的诚信级设置为0:四、应用程序设计与编码实现1、系统实现中储存函数和储存过程的设计23图书管理系统数据库设计-MYSQL实现要求给出功能描绘和代码。1.设计储存过程,产生罚单proc_gen_ticket:当天期超出预约送还日期时,产生罚单,并将记录写入表ticketxx,这个储存过程在准时器eventJobxx调用:sql:createprocedureproc_gen_ticket(incurrentdatedatetime)BEGINdeclarecur_datedatetime;setcur_date=currentdate;replaceintoticket(stu_id,book_id,over_date,ticket_fee)selectstu_id,book_id,datediff(cur_date,stu_borrow.expect_return_date),0.1*datediff(cur_date,stu_borrow.expect_return_date)fromstu_borrowwherecur_date>stu_borrow.expect_return_date;24图书管理系统数据库设计-MYSQL实现end操作和结果显示:1).学生1借了图书1,生成借书记录stu_borrow视图,以下:2).当他在1月27日前还书时,没有生成罚单:3).当他在1月27往后还书时,生成罚单:2.设计学生注册信息储存过程:学生注册信息stu_registersql:25图书管理系统数据库设计-MYSQL实现createprocedurestu_register(instu_idint,instu_namevarchar(20),instu_sexvarchar(20),instu_ageint,instu_provarchar(20),instu_gradevarchar(20))begininsertintostudent(stu_id,stu_name,stu_sex,stu_age,stu_pro,stu_grade)values(stu_id,stu_name,stu_sex,stu_age,stu_pro,stu_grade);end设计管理员注册信息储存过程:ma_registersql:createprocedurema_register(inma_idint,inma_namevarchar(20),inma_ageint,inma_phoneint)BEGINinsertintomanagervalues(ma_id,ma_name,ma_age,ma_phone);26图书管理系统数据库设计-MYSQL实现END借书过程的实现:设计储存函数,func_get_credit,返回学生的诚信级:createfunctionfunc_get_credit(stu_idint)returnsintbeginreturn(selectstu_integrityfromstudentwherestudent.stu_id=stu_id);end设计储存函数,func_get_booknum,返回书本能否在架上:createfunctionfunc_get_booknum(book_idint)returnsintbeginreturn(selectbook_numfrombookwherebook.book_idbook_id);end27图书管理系统数据库设计-MYSQL实现3)设计储存过程proc_borrow,调用func_get_credit和func_get_booknum,判断这个学生诚信度和书本能否在架上,若为真,则借书成功,在borrrow表中插入纪录;不然提示失败:createprocedureproc_borrow(instu_idint,inbook_idint,inborrow_datedatetime)beginiffunc_get_credit(stu_id)=1andfunc_get_booknum(book_id)=1theninsertintoborrowvalues(stu_id,book_id,borrow_date);elseselect'failedtoborrow';endif;end实验操作与结果显示:borrow纪录为空:28图书管理系统数据库设计-MYSQL实现履行函数,学生1借图书2:callproc_borrow(1,2,now());学生1的诚信级为0:借书失败:改正学生1诚信级为1:此时借书成功:5.还书储存过程proc_return:29图书管理系统数据库设计-MYSQL实现当还书时,查察能否书能否超期,即查问ticket表项,当发现超期,提示交罚单后再次还书,如没有超期,则纪录送还项目到return_tablexx,而且删除借书纪录(免得还书后准时器仍旧扫描这个纪录):sql:createprocedureproc_return(instu_idint,inbook_idint,inreturn_datedatetime)beginDECLAREborrowdatedatetime;if(selectpayofffromticketwhereticket.stu_id=stu_idandticket.book_id=book_id)=1then/*判断能否交了罚单,1表示没有交*/select'pleasepayofftheticket';else/*纪录送还项目到return_tablexx,而且删除借书纪录*/setborrowdate=(selectborrow_datefromborrowwhereborrow.stu_id=stu_idandborrow.book_id=book_id);insertintoreturn_tablevalues(stu_id,book_id,borrowdate,return_date);30图书管理系统数据库设计-MYSQL实现deletefromborrowwhereborrow.stu_id=stu_idandborrow.book_id=book_id;endif;end实验操作与结果显示:学生1借了图书2:超期产生了罚单,没有交罚单,payoff=1:此时调用还书过程:callproc_return(1,2,now());提示交罚单:交罚单,调用proc_payoff:31图书管理系统数据库设计-MYSQL实现callproc_payoff(1,2);交罚单成功,payoff=0;此时再次调用还书过程:callproc_return(1,2,now());还书成功,在return_table生成了还书纪录:交罚单储存过程:改正罚单xxpayoff段为0,表示罚单已交:createprocedureproc_payoff(instuidint,inbookidint)beginupdateticketsetpayoff=032图书管理系统数据库设计-MYSQL实现whereticket.stu_id=stuidandticket.book_id=bookid;select‘succeed’;end交罚单,调用proc_payoff:callproc_payoff(1,2);交罚单成功,payoff=0;2、功能实现按各功能模块进行描绘。要求:画出流程图并给出实现代码。创立学生一致账户,账户名:student_account,而且授与权限:sql:createuser'student_account'@'localhost';grantinsert,selectonstudentto'student_account'@'localhost';grantselectonbookto'student_account'@'localhost';33图书管理系统数据库设计-MYSQL实现grantinsert,selectonborrowto'student_account'@'localhost';grantinsert,selectonreturn_tableto'student_account'@'localhost';grantselectonticketto'student_account'@'localhost';创立管理员一致账户,账户名:manager_account,而且授与所有权限:sql:createuser'manager_account'@'localhost'identifiedby'123';grantallonlibrary_managementto'manager_account'@'localhost';查问图书信息按书名查找:select*frombookwherebook_name=‘sql’;34图书管理系统数据库设计-MYSQL实现按作者查找:select*frombookwherebook_author=‘author’;借书功能:proc_borrow(instu_idint,inbook_idint,inborrow_datedatetime)假如要接的书还在架上,而且学生的诚信级为1,那么能够借书callproc_borrow(1,1,now());命令行操作:表borrow:视图stu_borrow:表book:35图书管理系统数据库设计-MYSQL实现还书功能:proc_return(instu_idint,inbook_idint,inreturn_datedatetime)callproc_return(1,1,now());命令行操作:表return_table:表borrow:表book:交罚单功能:proc_payoff(instuidint,inbookidint)36图书管理系统数据库设计-MYSQL实现callproc_payoff(1,1);实验操作和结果见上节:“6.交罚单储存过程“管理员增添图书:insertintobookvalues();操作与结果:管理员删除图书:deletefrombookwhere(condition);管理员注销学生信息:deletefromstudentwhere(condition);管理员恢复学生的诚信级:37图书管理系统数据库设计-MYSQL实现updatestudentsetstu_integrity=1where(condition);学生借书-送还流程图:38图书管理系统数据库设计-MYSQL实现开始注册学生信息Callstu_register登入数据库用户名:student_accont查问or送还送还Callproc_return查问查问表ticket按书名/按作者名...无纪录or交完罚单借书:callproc_borrow往表return_table插入纪录在borrow中删除借书纪录成功?触发器return,改正表book成功往表borrow插入纪录结束准时器enventJob触发器borrow,改正表book图书超期?YesCallproc_gen_ticket生成罚单39图书管理系统数据库设计-MYSQL实现管理员管理流程图:开始注册管理员信息Callma_register增添图书改正学生信息Insertintobook事务中心Updatestudent删除图书注销学生信息DeletefromDeletefrombook数据库设计结果:student40图书管理系统数据库设计-MYSQL实现五、实习领会自己写41
本文档为【图书管理系统数据库设计-MYSQL实现】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
个人认证用户
秋天的麦田
本人从事母婴护理工作多年,经验丰富。
格式:doc
大小:1MB
软件:Word
页数:43
分类:
上传时间:2023-02-27
浏览量:1