版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、mysql图书馆图书馆管理系管理系统统的的数数据据库库数数据据库库 library操作员表 operator书库 books学生信息表 students_information操作过程表 process操作操作员员表表 operatorfieldtypenullkeydefaultextraidChar(9)nopriNullnameVarchar(10) nonull操作操作员员表表 operatorcreate table operator(id char(9) not null primary key,name varchar(10) not null);insert into oper
2、ator values (100001230,aa),(100001231,bb),(100001232,cc),(100001233,dd),(100001234,ee),(100001235,ff);书库书库 booksfieldtypenullkeydefault extratitlevarchar(20) nonulldate_of_publicationdateyesnullauthorvarchar(15) nonullISBNchar(13)noprinullnumber_of_copiesintnonullpositionvarchar(30) yesnull书库书库 book
3、screate table books(title varchar(20) not null,date_of_publication date,author varchar(15) not null,ISBN char(13) not null primary key,number_of_copies int not null,position varchar(30);insert into books values (没有任何借口,2008-11-01,杰伊.瑞芬博瑞,9787500683858,20,二楼 成功/激励),(钢铁是怎样炼成的,1997-05-12,奥斯特洛夫斯基,978753
4、0125403,25,二楼 成功/激励),(水浒传,1998-11-15,施耐庵,9787530112454,10,一楼文学类),(小时代,2009-11-15,郭敬明,9782345612454,1,一楼文学类);学学生信息表生信息表 students_informationfieldtypenull keydefault extraidvarchar(9)noprinullnamevarchar(10) nonullsexchar(2)yesnullphone_numberchar(11)yesnulldepartment varchar(11) yesnull学学生信息表生信息表 stu
5、dents_informationcreate table students_information(id char(9) not null primary key,name varchar(10) not null,sex char(2),phone_number char(11),department varchar(10);insert into students_information values (100000001,aa,MM财经),(100000002,bb,GG财经),(100000003,cc,MM/p>
6、,财经),(100000004,dd,MM财经),(100010001,ab,GG计算机科学与运用),(100010002,bc,MM计算机科学与运用),(100010003,cd,GG计算机科学与运用),(100010004,de,MM计算机科学与运用),(100020001,ef,GG土木工程);操作操作过过程表程表 processfieldtypenull keydefault extratitlevarchar(20) yesnul
7、lISBNchar(13)yesnullbgnamevarchar(10) yesnullbg_idchar(9)yesnulloperator_namevarchar(10) yesnulloperator_idchar(9)yesnullbtimevarchar(20) yesnullgtimevarchar(20) yesnullis_giveboolyesnull操作操作过过程表程表 processcreate table process(title varchar(20),ISBN char(13),bgname varchar(10),bg_id char(9),operator_
8、name varchar(10),operator_id char(9),btime varchar(20),gtime varchar(20),is_give bool);insert into process values (书名,isbn号,借/还书人,000000000,操作员姓名,000000000,借书时间,还书时间,1);借书存储过程借书存储过程delimiter |create procedure zj_borrow(in book_id char(13),in b_id char(9),in o_id char(9)begin declare booktitle varcha
9、r(20); declare borrowname varchar(10); declare op_name varchar(10); declare bstime varchar(20); declare num int; set num=1; set bstime=now(); set booktitle=(select title from books where ISBN=book_id); set borrowname=(select name from students_information where id=b_id); set op_name=(select name fro
10、m operator where id=o_id);借书存储过程借书存储过程 if (select number_of_copies from books where ISBN=book_id)=num and book_id in (select ISBN from books) and b_id in (select id from students_information) and o_id in (select id from operator) and (select is_give from process where btime=(select max(btime) from p
11、rocess where bg_id=b_id)=1 or b_id not in (select bg_id from process) then update books set number_of_copies=number_of_copies-1 where ISBN=book_id; insert into process values (booktitle,book_id,borrowname,b_id,op_name,o_id,bstime,null,0); end if;end |delimiter ;检测借书过程检测借书过程call zj_borrow(97875301254
12、03,100000001,100001231);call zj_borrow(9787530125403,100000001,100001231);select select * * from process; from process;select select * * from books; from books;call zj_borrow(9787530125403,100000001,100001231);call zj_borrow(9787530125403,100000001,100001231);call zj_borrow(978753012540call zj_borro
13、w(9787530125404 4,100000001,100001231);,100000001,100001231);call zj_borrow(9787530125403,1call zj_borrow(9787530125403,19 90000001,100001231);0000001,100001231);call zj_borrow(9787530125403,100000001,1call zj_borrow(9787530125403,100000001,19 90001231);0001231);call zj_borrow(9782345612454,10001000
14、2,100001234);call zj_borrow(9782345612454,100010002,100001234);call zj_borrow(9782345612454,100020001,100001232);call zj_borrow(9782345612454,100020001,100001232);创建还书过程创建还书过程delimiter |create procedure zj_give(in b_id char(13),in g_id char(9),in o_id char(9)begin declare stime varchar(20); declare
15、gstime varchar(20); set gstime=now(); set stime=(select max(btime) from process where bg_id=g_id); if (select is_give from process where ISBN=b_id and bg_id=g_id and operator_id=o_id and btime=stime)=0 then update process set gtime=gstime where ISBN=b_id and bg_id=g_id and operator_id=o_id and btime
16、=stime; update process set is_give=1 where ISBN=b_id and bg_id=g_id and operator_id=o_id and btime=stime; update books set number_of_copies=number_of_copies+1 where ISBN=b_id; end if;end |delimiter ;检测还书过程检测还书过程call call zj_givezj_give (9787530125403,100000001,100001231); (9787530125403,100000001,10
17、0001231);select select * * from process; from process;select select * * from books; from books;call call zj_givezj_give (9787530125403,100000001,100001231); (9787530125403,100000001,100001231);call call zj_givezj_give (978753012540 (9787530125404 4,100000001,100001231);,100000001,100001231);call call zj_givezj_give (9787530125
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年教育行业绿色发展专员面试题集及答案参考
- 湖南体育职业学院《形势与政策》2023-2024学年第一学期期末试卷
- 2026届四川成都列五中学高三上学期一诊历史试题含答案
- 2026年投资分析师面试题集专业问题一网打尽
- 生态农业公司规章制度三篇农业生产管理制度
- 幼教介绍教学课件
- 幼师环创培训内容课件
- 宫颈癌患者的康复训练与运动指导
- 2025年护士年终述职报告汇报
- 护理院感管理工作自评报告
- JT∕T 900-2023 汽车售后维修服务客户满意度评价方法
- QBT 2959-2008 钢板网行业标准
- 特种设备管理机构
- 医疗耗材配送服务方案
- 2024年初级会计《初级会计实务》考试训练题(含答案)
- (完整word版)英语四级单词大全
- 井下作业技术油水井措施酸化课件解析
- 劳动教育融入思政课一体化建设路径探索 论文
- 旅游接待业 习题及答案汇总 重大 第1-10章 题库
- 热电有限公司突发事件安全保卫应急预案
- 财务管理形考任务4
评论
0/150
提交评论