图书馆数据库管理系统.docx
《图书馆数据库管理系统.docx》由会员分享,可在线阅读,更多相关《图书馆数据库管理系统.docx(11页珍藏版)》请在冰豆网上搜索。
图书馆数据库管理系统
图书馆数据库管理系统
一、图书馆管理系统E-R图
教师借阅图书期限较长,并且允许借阅的书本量较大。
因此,将教师借阅关系与学生借阅关系分开较为适宜。
二、图书馆管理系统功能实现示意图
由于教师与学生的借阅图书、归还图书等等过程大致相同,在此,仅借学生有关表对象信息来对各存储过程作简要说明:
三、图书馆管理系统功能图例
读者借阅图书
ExecuteRBorrowBook'读者号','图书分类号'
--------------读者借阅图书实例
useLibrarySystem
go
execRBorrowBookT006324,'D630.3L836'--其中T006324以T为标识,代表教师编号
execRBorrowBookS0,'D630.3L836'---其中S0以S为标识,代表学生学号
go
-----结果如下:
读者归还图书
ExecuteRReturnBook'读者号','图书分类号'
----------------读者归还图书实例
useLibrarySystem
go
execRReturnBookT006324,'D630.3L836'
execRReturnBookS0,'D630.3L836'
go-----结果如下:
读者续借图书
ExecuteRRenewBook'读者号','图书分类号'
--------------读者续借图书实例
useLibrarySystem
go
-------读者借阅图书
execRBorrowBookT006324,'D630.3L836'
execRBorrowBookS0,'D630.3L836'
go
waitfordelay'0:
0:
5'
--------读者续借图书
execRRenewBookT006324,'D630.3L836'
execRRenewBookS0,'D630.3L836'
go
-----结果如下:
读者查询借阅图书情况
ExecuteRQueryBook'读者号'
------------读者查询图书借阅情况实例
useLibrarySystem
go
execRQueryBookT006432
execRQueryBookS0
go
-----结果如下:
读者检索图书信息
ExecuteRIndexBook'关键词'
------------读者检索图书信息实例
useLibrarySystem
go
execRIndexBook数据库
go
-------结果如下:
四、图书馆管理系统附加功能
往学生表中插入一列"系部",其值等于学号中代表系部的位的值,再插入一列"专业号",其值等于学号中代表专业的位的值
---------------往学生表S中插入一列"系部",其值等于学号中代表系部的位的值
useLibrarySystem
go
altertableStudent
addSdeptNochar
(2)
go
declare@snochar(10),@totalint,@iint
select@total=count(*),@i=1
fromStudent
while(@i<=@total)
begin
------------查询数据表第@i行数据的SQL语句
selecttop1@sno=SnofromStudentwhereSnonotin(selecttop(@i-1)SnofromStudent)
updateStudent
setSDeptNo=substring(@sno,4,2)
whereSno=@sno
set@i=@i+1
end
select*fromStudent
go
-----------结果如下:
-------------往学生表S中插入一列"专业号",其值等于学号中代表专业的位的值
useLibrarySystem
go
altertableStudent
addSMajorNovarchar(50)
go
declare@snochar(10),@totalint,@iint
select@total=count(*),@i=1
fromStudent
while(@i<=@total)
begin
------------查询数据表第@i行数据的SQL语句
selecttop1@sno=SnofromStudentwhereSnonotin(selecttop(@i-1)SnofromStudent)
updateStudent
setSMajorNo=substring(@sno,4,4)
whereSno=@sno
set@i=@i+1
end
go
-----------结果如下:
查询每个学生对书本的借阅数量
--查询每个学生对书本的借阅数量
useLibrarySystem
go
select学号,Sname姓名,图书分类号,Bname书名
fromStudentBook,Student,Book
where=and=
orderby
computecountby
go
-----------结果如下:
查询各个专业的学生借阅书本的数量
useLibrarySystem
go
declare@tempDepttable(
专业编号char(4)primarykey,
专业varchar(30)notnull,
学生借阅书本数量intdefault0)
Insertinto@tempDept(专业编号,专业)selectMno,MnamefromMajor
declare@iint,@totalint,@nochar(10)
select@total=count(*),@i=1fromStudentBook
while(@i<@total)begin
selecttop1@no=SnofromStudentBookwhereSnonotin(selecttop(@i-1)SnofromStudentBook)
update@tempDept
set学生借阅书本数量=学生借阅书本数量+1
where专业编号=substring(@no,4,4)
set@i=@i+1
end
select*from@tempDept
select@totalas学生借阅书本总量
go-----------结果如下: