收藏 分销(赏)

数据库-图书馆管理系统实验报告.doc

上传人:二*** 文档编号:4480892 上传时间:2024-09-24 格式:DOC 页数:28 大小:1.29MB 下载积分:5 金币
下载 相关 举报
数据库-图书馆管理系统实验报告.doc_第1页
第1页 / 共28页
本文档共28页,全文阅读请下载到手机保存,查看更方便
资源描述
(完整word版)数据库_图书馆管理系统实验报告 数据库课程设计报告 专 业: 计算机科学与技术 班 级: 03 组 长: 张云1143041160 组 员: 王冉1143041228 赵承东1143041178 指导教师: 袁道华 成 绩: 2013年12月16日 一、 课程设计概述 1. 课程设计背景 课程需要开发一个图书管理系统,要求在读者登记处可以将读者的信息添加,信息系统中保存,当读者信息发生变化,对计算机内容进行修改,当读者办理退卡手续要删除此读者信息,图书管理负责图书和出版社的管理,读书借还处进行借书管理,还书管理,库存查询,图书排行榜,生成超期未还书的读者,进行通知.给不同用户设置不同权限,供用户访问数据库。 2. 编写目的 熟练掌握mysql中的创建数据库、创建表、显示、查询、select语句、视图、存储过程、创建检索、对表的添加、删除、修改和用户权限的设置等基本运用,并通过编写这个图书管理系统来实际演练。 3. 软件定义 Mysql是目前最流行的开源的中小型关系数据管理系统,目前被广泛的应用于internet上得中小型网站中,它由mysql AB公司开发、发布并支持。本实验用的是mysql 5.1版本 4. 开发环境 本实验用的是mysql 5.1版本,windows2010 二、 需求分析 1. 问题的提出 1:怎么通过mysql和信息之间的关系来创建图书管理系统的数据库及表? 2:怎样来实现对插入读者信息并保存、修改及删除? 3:怎么来实现对图书的管理? 4:怎样实现对借书后在读书借还处添加读者借书信息和还书后删除读者借还处中的借书信息且更新图书管理处的图书数量? 5:怎么实现对超期读者进行罚款操作和生成这些读者的名单,以方便通知? 6:怎样实现图书的借书排行榜和查看库存书量? 7:怎么样来根据不同用户对数据库的等级的不同来设置这些用户的权限? 2. 需要完成的功能及各部分功能概述 1:读者登记建卡处的功能是对读者基本信息进行登记,读者信息发生变化对读者基本信息进行修改,读者要求退还借书卡时对读者信息进行删除等操作。 2:图书管理处的功能是对图书和出版社、作者、书价,数量,剩余书量进行管理更新。 3:图书借还处的功能是对借出书的登记。 4:基于上面3大模块, 进行细分一:1、通过创建存储过程对读者通过insert进行登记 2、通过alter或update来修改和更新读者信息 3、通过delete来对读者信息删除 二:1、对图书的添加、更新和修改也用到存储过程 2、在对图书剩余量的更新是通过图书借还处和图书管理处之间的书号来发生联系,对存储过程对这个字段进行调用达到更新目的 三:1、借书管理都是通过建立存储过程来实现登记处的登记同时也在借书处登记借读信息,同时更新图书的剩余量,还书管理处是根据还书的读者号和书号来选定要清除的借读信息,同时也更新图书剩余量信息,还要根据存储过程传来的read_id和book_id及js_quantity(借书数量)的参数计算出是否超期,超期的天数显示出来。 2、产生超期未还书的读者的名单是通过视图来实现显示 3、对图书排行我也是通过存储过程实现 4: 对图书进行借出量排行,增加图书的热度和知名度和图书的剩余量查询。 5:新建读者用户和管理员用户,对他们分别设置不同的权限,在mysql的安装文件下的bin目录进行登录 项目流程图 功能模块图 E-R图 图中各实体属性如下: 读者档案:学号,读者姓名,性别,借书证号,单位 借书证:借书证号,姓名,性别,办证日期 管理员:操作员编号,管理员姓名,登陆密码 库存信息:书号,图书编号 借出信息:图书编号,借书证号,借书日期,归还日期 图书档案:书号,书名,作者,出版单位,出版日期,单价,类别,藏书册书 图书编号入库日期 三、 部分关键代码 图书借阅: <?php include("navigation.php");?> <table width="776" border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <td valign="top" bgcolor="#FFFFFF"><table width="100%" height="509" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="tableBorder_gray"> <tr> <td align="left" valign="top" style="padding:5px;"> &nbsp; <span class="word_orange">&nbsp;当前位置:图书借还 &gt; 图书借阅&gt;&gt;&gt; </span> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <?php include("conn/conn.php"); error_reporting(E_ALL&~E_NOTICE); if($_REQUEST['barcode']!=null){ $barcode=$_REQUEST['barcode']; $sql=mysql_query("select r.*,t.name as typename,t.number from tb_reader r left join tb_readerType t on r.typeid=t.id where r.barcode='$barcode'" ); $info=mysql_fetch_array($sql); if($info==false){ echo "<script language='javascript'>alert('读者不存在!');window.opener.location.reload();</script>"; } } else{ $sql=mysql_query("select r.*,t.name as typename,t.number from tb_reader r left join tb_readerType t on r.typeid=t.id where r.barcode=000000" ); $info=mysql_fetch_array($sql); } // $info=$_GET('info'); ?> <form name="form1" method="post" action=""> <tr> <td height="72" align="center" valign="top" background="Images/main_booksort_1.gif" bgcolor="#F8BF73"> <br> <table width="96%" border="0" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#9ECFEE" class="tableBorder_grey"> <tr> <td height="33" valign="top" background="Images/bookborr.gif"> <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="33" background="Images/bookborr.gif">&nbsp;</td> </tr> </table> <table width="100%" height="21" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="24%" height="18" style="padding-left:7px;padding-top:7px;"><img src="Images/bg_line.gif" width="132" height="20"></td> <td width="76%" style="padding-top:7px;">读者条形码: <input name="barcode" type="text" id="barcode" size="24" value="<?php if($info!=flase) {echo $info['barcode'];} else{ echo ""; }?>"> &nbsp; <input name="Button" type="button" class="btn_grey" value="确定" onClick="checkreader(form1)"></td> </tr> </table> </td> </tr> <tr> <td height="13" align="left" style="padding-left:7px;"><hr width="90%" size="1"></td> </tr> <tr> <td align="center"><table width="96%" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="27">姓&nbsp;&nbsp;&nbsp;&nbsp;名: <input style="disabled:ture;border:none" name="readername" type="text" id="readername" value="<?php if($info!=flase) {echo $info['name'];} else{ echo "&nbsp"; }?>"> <input style="disabled:ture;border:none" name="readerid" type="hidden" id="readerid" value="<?php if($info!=false) {echo $info['id'];} else{ echo "&nbsp"; }?>"></td> <td>性&nbsp;&nbsp;&nbsp;&nbsp;别: <input style="disabled:ture;border:none" name="sex" type="text" id="sex" value="<?php if($info!=false) {echo $info['sex'];} else{ echo "&nbsp"; }?>"></td> <td>读者类型: <input style="disabled:ture;border:none" name="readerType" type="text" id="readerType" value="<?php if($info!=false) {echo $info['typename'];} else{ echo "&nbsp"; }?>"></td> </tr> <tr> <td height="27">证件类型: <input style="disabled:ture;border:none" name="paperType" type="text" id="paperType" value="<?php if($info!=false) {echo $info['paperType'];} else{ echo "&nbsp"; }?>"></td> <td>证件号码: <input style="disabled:ture;border:none" name="paperNo" type="text" id="paperNo" value="<?php if($info!=false) {echo $info['paperNO'];} else{ echo "&nbsp"; }?>"></td> <td>可借数量: <input style="disabled:ture;border:none" name="number" type="text" id="number" value="<?php if($info!=false) {echo $info['number'];} else{ echo "&nbsp"; }?>" size="17"> 册 &nbsp;</td> </tr> </table></td> </tr> </table></td> </tr> <tr> <td height="32">&nbsp;添加的依据: <input name="f" id="f"type="radio" class="noborder" value="barcode" checked> 图书条形码 &nbsp;&nbsp; <input name="inputkey" type="text" id="inputkey" size="50"> <input name="operator" type="hidden" id="operator" value="<?php echo $barcode; ?>"> <input type="submit" class="btn_grey" id="Submit" onClick=" return checkbook(form1);" value="确定"> <input name="Button2" type="button" class="btn_grey" id="Button2" onClick="window.location.href='bookBorrow.php'" value="退出此次借阅"> </td> </tr> <tr> <td valign="top" bgcolor="#D2E5F1" style="padding:5px"><table width="99%" border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#9ECFEE" bgcolor="#FFFFFF"> <tr align="center" bgcolor="#E2F4F6"> <td width="29%" height="25">图书名称</td> <td width="12%">借阅时间</td> <td width="14%">应还时间</td> <td width="17%">出版社</td> <td width="14%">书架</td> <td colspan="2">定价(元)</td> </tr> <?php if($info!=false){ $readerid=$info['id'];} $sql1=mysql_query("select r.*,borr.borrowTime,borr.backTime,book.bookname,book.price,pub.pubname,bc.name as bookcase from tb_borrow as borr join tb_bookinfo as book on book.id=borr.bookid join tb_publishing as pub on book.ISBN=pub.ISBN join tb_bookcase as bc on book.bookcase=bc.id join tb_reader as r on borr.readerid=r.id where borr.readerid='$readerid' and borr.ifback=0"); $info1=mysql_fetch_array($sql1); $borrowNumber=mysql_num_rows($sql1); //获取结果集中行的数目 do{ ?> <tr> <td height="25" style="padding:5px;">&nbsp;<?php echo $info1['bookname'];?></td>' <td style="padding:5px;">&nbsp;<?php echo $info1['borrowTime'];?></td> <td style="padding:5px;">&nbsp;<?php echo $info1['backTime'];?></td> <td align="center">&nbsp;<?php echo $info1['pubname'];?></td> <td align="center">&nbsp;<?php echo $info1['bookcase'];?></td> <td width="14%" align="center">&nbsp;<?php echo $info1['price'];?></td> </tr> <?php }while($info1=mysql_fetch_array($sql1)); ?> <input name="borrowNumber" type="hidden" id="borrowNumber" value="<?php echo $borrowNumber; ?>"> </table> </td> </tr> </table></td> </tr> <tr> <td height="19" background="Images/main_booksort_2.gif">&nbsp;</td> </tr> </form> <?php error_reporting(E_ALL ^ E_DEPRECATED); require_once 'sqltools.class.php'; error_reporting(E_ALL ^ E_NOTICE); if($_POST['inputkey']!=""){ $f=$_POST['f']; $inputkey=trim($_REQUEST['inputkey']); $barcode=$_REQUEST['barcode']; $readerid=$_REQUEST['readerid']; $borrowTime=date('Y-m-d'); $backTime=date("Y-m-d",(time()+3600*24*30)); //归还图书日期为当前期日期+30天期限 $todayTime=date('Y-m-d',time());//当前时间 $sqltools=new sqltools(); $query=mysql_query("select * from tb_bookinfo where barcode=$inputkey"); $result=mysql_fetch_array($query); // var_dump($result); //检索图书信息是否存在 $sql="select backTime from tb_borrow where readerid=$readerid and ifback=0"; $r=$sqltools->exeute_dql2($sql); // var_dump($r); foreach($r as $key=>$value){ $backDate=$value['backTime']; if($backDate<$todayTime){ echo "<script language='javascript'>alert('您有超期图书!');window.location.href='bookBorrow.php?barcode=$barcode';</script>"; break; } } if($result==false){ echo "<script language='javascript'>alert('该图书不存在!');window.location.href='bookBorrow.php?barcode=$barcode';</script>"; } else{ $query1=mysql_query("select r.*,borr.borrowTime,borr.backTime,book.bookname,book.price,pub.pubname,bc.name as bookcase from tb_borrow as borr join tb_reader as r on borr.readerid=r.id join tb_bookinfo as book on book.id=borr.bookid join tb_publishing as pub on book.ISBN=pub.ISBN join tb_bookcase as bc on book.bookcase=bc.id where borr.bookid=$result[id] and borr.readerid=$readerid and ifback=0"); //检索该读者所借阅的图书是否与再借图书重复 $result1=mysql_fetch_array($query1); if($result1==true){ //如果借阅的图书已被该读者借阅,那么提示不能重复借阅 echo "<script language='javascript'>alert('该图书已经借阅!');window.location.href='bookBorrow.php?barcode=$barcode';</script>"; } else{ //否则,完成图书借阅操作 $bookid=$result['id']; $res=mysql_query("insert into tb_borrow(readerid,bookid,borrowTime,backTime,operator,ifback)values('$readerid','$bookid','$borrowTime','$backTime','$_SESSION[admin_name]',0)"); $sql1="select exist from tb_bookinfo where barcode=$inputkey "; $sqltools=new sqltools(); $res1=$sqltools->exeute_dql2($sql1); foreach($res1 as $key=>$value) { $exist1=$value['exist']; } $exist=$exist1-1; // 图书可借数要减去1 $res2=mysql_query("update tb_bookinfo set exist=$exist where barcode=$inputkey "); error_reporting(E_ALL ^ E_NOTICE); if($res==ture &&$res2=ture){ echo "<script language='javascript'>alert('图书借阅操作成功!');window.location.href='bookBorrow.php?barcode=$barcode';</script>"; } } } } ?> </table></td> </tr> </table> <?php include("copyright.php");?></td> </tr> </table> 图书归还: <?php include("conn/conn.php"); $info=false; error_reporting(E_ALL&~E_NOTICE); if(isset($_REQUEST['barcode'])){ $barcode=$_REQUEST['barcode']; $sql=mysql_query("select borr.id as borrid,borr.borrowTime,borr.backTime,borr.ifback,r.*,t.name as typename,t.number,book.bookname,book.price,pub.pubname,bc.name as bookcase from tb_borrow as borr join tb_reader r on borr.readerid=r.id join tb_readerType t on r.typeid=t.id join tb_bookinfo as book on book.id=borr.bookid join tb_publishing as pub on book.ISBN=pub.ISBN join tb_bookcase as bc on book.bookcase=bc.id where r.barcode='$barcode' and borr.ifback=0"); $info=mysql_fetch_array($sql); $sql1=mysql_query("select * from tb_reader where barcode='$barcode' "); $info1=mysql_fetch_array($sql1); if($info1==false){ echo "<script language='javascript'>alert('读者不存在!');window.opener.location.reload();</script>"; } if($info1!=false && $info==false){ echo "<script language='javascript'>alert('不存在未归还书籍!');window.opener.location.reload();</script>";} } ?> <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td width="33%"><table width="100%" height="74" border="0" cellpa
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 通信科技 > 数据库/数据算法

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服