国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

MySQL數(shù)據(jù)庫(kù)期末項(xiàng)目 圖書(shū)館管理系統(tǒng)

這篇具有很好參考價(jià)值的文章主要介紹了MySQL數(shù)據(jù)庫(kù)期末項(xiàng)目 圖書(shū)館管理系統(tǒng)。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

1 項(xiàng)目需求分析

1.1 項(xiàng)目名稱

圖書(shū)館管理系統(tǒng)

1.2 項(xiàng)目功能

在以前大多部分圖書(shū)館都是由人工直接管理,其中每天的業(yè)務(wù)和操作流程非常繁瑣復(fù)雜,紙質(zhì)版的登記信息耗費(fèi)了大量的人力物力。因此圖書(shū)館管理系統(tǒng)應(yīng)運(yùn)而生,該系統(tǒng)采用智能化設(shè)計(jì),在業(yè)務(wù)流程的實(shí)現(xiàn)方面更加注重智能化、規(guī)范化、流程化,極大地提高圖書(shū)館的管理效率及服務(wù)質(zhì)量。

其中管理員負(fù)責(zé)圖書(shū)的信息錄入和類型歸納,以及讀者借閱圖書(shū)和歸還圖書(shū)時(shí)的信息登記;圖書(shū)信息和圖書(shū)類型為管理員或讀者們查找所需要的圖書(shū)時(shí)提供便捷;圖書(shū)借閱負(fù)責(zé)記錄讀者的借閱信息并對(duì)借閱信息做一個(gè)統(tǒng)籌處理;圖書(shū)歸還負(fù)責(zé)讀者歸還圖書(shū)后的信息的記錄;讀者信息方便圖書(shū)的借閱與歸還,憑借讀者信息可以直接在網(wǎng)上進(jìn)行借閱和歸還。這樣的流程大大降低了圖書(shū)館管理員的工作量,也提高了圖書(shū)館的管理效率。

1.3 項(xiàng)目系統(tǒng)結(jié)構(gòu)圖

圖書(shū)館管理系統(tǒng)分為三部分,管理員部分負(fù)責(zé)管理員信息的增刪改查,圖書(shū)管理部分主要包括圖書(shū)信息、類型、借閱和歸還,而讀者管理負(fù)責(zé)讀者信息的修改、增加、查詢和修改。

MySQL數(shù)據(jù)庫(kù)期末項(xiàng)目 圖書(shū)館管理系統(tǒng)

2 數(shù)據(jù)庫(kù)的設(shè)計(jì)

2.1 概念結(jié)構(gòu)設(shè)計(jì)

(一)實(shí)體之間的聯(lián)系如下:

一個(gè)管理員可以整理多本圖書(shū)信息,因此管理員和圖書(shū)信息具有一對(duì)多的聯(lián)系,用整理來(lái)表示管理員和圖書(shū)信息的關(guān)系。

一個(gè)管理員可以對(duì)多種圖書(shū)類型進(jìn)行歸類,因此管理員和圖書(shū)類型具有一對(duì)多的聯(lián)系,用歸類來(lái)表示管理員和圖書(shū)類型的關(guān)系。

一個(gè)管理員可以管理多個(gè)圖書(shū)借閱信息,因此管理員和圖書(shū)借閱信息具有一對(duì)多的聯(lián)系,用管理來(lái)表示管理員和圖書(shū)借閱信息的關(guān)系。

一個(gè)管理員可以管理多個(gè)圖書(shū)歸還信息,因此管理員和圖書(shū)歸還信息具有一對(duì)多的聯(lián)系,用管理來(lái)表示管理員和圖書(shū)歸還信息的關(guān)系。

一個(gè)管理員可以管理多個(gè)讀者信息,因此管理員和讀者信息具有一對(duì)多的聯(lián)系,用管理來(lái)表示管理員和讀者信息的關(guān)系。

一本圖書(shū)可由多個(gè)讀者借閱,一個(gè)讀者也可借閱多本圖書(shū),因此讀者和圖書(shū)借閱具有多對(duì)多的聯(lián)系,用借閱來(lái)表示讀者和圖書(shū)借閱的關(guān)系。

一本圖書(shū)可由多個(gè)讀者歸還,一個(gè)讀者也可歸還多本圖書(shū),因此讀者和圖書(shū)歸還具有多對(duì)多的聯(lián)系,用歸還來(lái)表示讀者和圖書(shū)歸還的關(guān)系。

(二)E-R圖設(shè)計(jì)如下:

MySQL數(shù)據(jù)庫(kù)期末項(xiàng)目 圖書(shū)館管理系統(tǒng)

2.2 邏輯結(jié)構(gòu)設(shè)計(jì)

將E-R圖轉(zhuǎn)換為關(guān)系模型如下:

管理員(ID編號(hào)、管理員名稱、管理員密碼)

圖書(shū)信息(ID編號(hào)、圖書(shū)編號(hào)、書(shū)名、作者、價(jià)格、出版社)

圖書(shū)類型(圖書(shū)編號(hào)、書(shū)名、數(shù)量、類型、所在書(shū)架)

圖書(shū)借閱(讀者編號(hào)、圖書(shū)編號(hào)、讀者姓名、借書(shū)時(shí)間、歸還時(shí)間、是否歸還)

圖書(shū)歸還(讀者編號(hào)、圖書(shū)編號(hào)、讀者姓名、歸還時(shí)間)

讀者(讀者編號(hào)、姓名、性別、職業(yè)、出生日期、證件號(hào)碼、電話、電子郵箱)

對(duì)關(guān)系模型進(jìn)行規(guī)范化,最終規(guī)范為第三范式。

2.3 物理結(jié)構(gòu)設(shè)計(jì)

(1)manager(管理員信息表)

列名

數(shù)據(jù)類型

長(zhǎng)度

約束

說(shuō)明

Id

Char(10)

10

Not null primary key

ID編號(hào)

Name

Varchar(30)

30

Not null

管理員名稱

Password

Varchar(30)

30

Not null

管理員密碼

(2)bookinfo(圖書(shū)信息表)

列名

數(shù)據(jù)類型

長(zhǎng)度

約束

說(shuō)明

Id

Char(10)

10

Not null foreign key

ID編號(hào)

Bookname

Varchar(60)

60

Not null

書(shū)名

Author

Varchar(60)

60

Not null

作者

BookId

Char(10)

10

Not null primary key

圖書(shū)編號(hào)

Price

Decimal(10,2)

30

Not null

價(jià)格

Publish

Varchar(30)

30

Not null

出版社

(3)booktype(圖書(shū)類型表)

列名

數(shù)據(jù)類型

長(zhǎng)度

約束

說(shuō)明

BookId

Char(10)

10

Not null primary key

圖書(shū)編號(hào)

Bookname

Varchar(60)

60

Not null

書(shū)名

Quantity

Char(20)

20

Not null

數(shù)量

Type

Varchar(30)

30

Not null

類型

Shelf

Varchar(20)

20

Not null

所在書(shū)架

(4)bookborrow(圖書(shū)借閱表)

列名

數(shù)據(jù)類型

長(zhǎng)度

約束

說(shuō)明

ReaderId

Char(10)

10

Not null primary key

讀者編號(hào)

ReaderName

Varchar(10)

10

Not null

讀者姓名

BookId

Char(10)

10

Not null foreign key

圖書(shū)編號(hào)

BorrowTime

Date

Not null

借書(shū)時(shí)間

BackTime

Date

Not null

歸還時(shí)間

IfBack

Varchar(10)

10

Not null

是否歸還

(5)bookback(圖書(shū)歸還表)

列名

數(shù)據(jù)類型

長(zhǎng)度

約束

說(shuō)明

ReaderId

Char(10)

10

Not null primary key

讀者編號(hào)

ReaderName

Varchar(10)

10

Not null

讀者姓名

BookId

Char(10)

10

Not null foreign key

圖書(shū)編號(hào)

BackTime

Date

Not null

歸還時(shí)間

(6)readerinfo(讀者信息表)

列名

數(shù)據(jù)類型

長(zhǎng)度

約束

說(shuō)明

ReaderId

Char(10)

10

Not null primary key

讀者編號(hào)

ReaderName

Varchar(10)

10

Not null

姓名

Sex

Varchar(10)

10

Not null

性別

Vocation

Varchar(30)

30

Not null

職業(yè)

Birthday

Date

Not null

出生日期

Identify

Varchar(20)

20

Not null

證件號(hào)碼

Tel

Varchar(20)

20

Not null

電話

Email

Varchar(20)

20

Not null

電子郵箱

3 數(shù)據(jù)庫(kù)的實(shí)現(xiàn)

3.1 數(shù)據(jù)庫(kù)

數(shù)據(jù)庫(kù)名

定義數(shù)據(jù)庫(kù)語(yǔ)句

說(shuō)明

library_lwl

create database library_lwl;

創(chuàng)建數(shù)據(jù)庫(kù)

3.2 表

表名

定義表語(yǔ)句

說(shuō)明

manager

create table manager(

Id char(10) not null primary key,

Name varchar(30) not null,

Password varchar(30) not null );

創(chuàng)建manager(管理員信息表)

bookinfo

create table bookinfo(

Id char(10) not null,

Bookname varchar(60) not null,

Author varchar(60) not null,

BookId char(10) not null primary key,

Price Decimal(10,2) not null,

Publish varchar(30) not null,

constraint bookinfo_fk foreign key (Id) references manager(Id) );

創(chuàng)建bookinfo(圖書(shū)信息表)

booktype

create table booktype(

BookId char(10) not null primary key,

Bookname varchar(60) not null,

Quantity char(20) not null,

Type varchar(30) not null,

Shelf varchar(20) not null );

創(chuàng)建booktype(圖書(shū)類型表)

bookborrow

create table bookborrow(

ReaderId char(10) not null primary key,

ReaderName varchar(10) not null,

BookId char(10) not null,

BorrowTime date not null,

BackTime date not null,

IfBack varchar(10) not null,

constraint bookborrow_fk foreign key (BookId) references bookinfo(BookId) );

創(chuàng)建bookborrow(圖書(shū)借閱表)

bookback

create table bookback(

ReaderId char(10) not null primary key,

ReaderName varchar(10) not null,

BookId char(10) not null,

BackTime date not null,

constraint bookback_fk foreign key (BookId) references bookinfo(BookId) );

創(chuàng)建bookback(圖書(shū)歸還表)

readerinfo

create table readerinfo(

ReaderId char(10) not null primary key,

ReaderName varchar(10) not null,

Sex varchar(10) not null,

Vocation varchar(30) not null,

Birthday date not null,

Identify varchar(20) not null,

Tel varchar(20) not null,

Email varchar(20) not null );

創(chuàng)建readerinfo(讀者信息表)

3.3 數(shù)據(jù)操縱

數(shù)據(jù)操縱類型

數(shù)據(jù)操縱語(yǔ)句

說(shuō)明

查詢數(shù)據(jù)

select * from bookborrow,readerinfo where readerinfo.ReaderId = 'R0001' and bookborrow.ReaderId = readerinfo.ReaderId;

查詢讀者編號(hào)為R0001的讀者信息和圖書(shū)借閱信息

插入數(shù)據(jù)

insert into manager values ('001', '李**', 'l123');

insert into manager values ('002', '董**', 'd123');

insert into bookinfo values ('001', 'MySql數(shù)據(jù)庫(kù)', '林某某', '000001', 49.8, '人民郵電出版社');

insert into bookinfo values ('001', 'Java程序設(shè)計(jì)', '趙某某', '000002', 59.0, '機(jī)械工業(yè)出版社');

insert into booktype values ('000001', 'MySql數(shù)據(jù)庫(kù)', 100, '編程書(shū)籍', '1號(hào)書(shū)架');

insert into booktype values ('000002', 'Java程序設(shè)計(jì)', '89', '編程書(shū)籍', '1號(hào)書(shū)架');

insert into bookborrow values ('R0001', '青玉案', '000001', '2022-10-23', '2022-12-10', '是');

insert into bookborrow values ('R0002', '北顧亭', '000001', '2022-10-24', '2022-12-10', '否');

insert into bookback values ('R0001', '青玉案', '000001','2022-12-10');

insert into bookback values ('R0002', '北顧亭', '000001','2022-12-10');

insert into readerinfo values ('R0001', '青玉案', '男', '學(xué)生', '2001-04-12', '411456', '1582476', '297@qq.com');

insert into readerinfo values ('R0002', '北顧亭', '男', '工人', '2001-11-23', '411423', '1352686', '225@qq.com');

在每張表里分別插入兩條數(shù)據(jù)

修改數(shù)據(jù)

update bookinfo set Price = 59.8 where BookId in (select BookId from booktype where Bookname = "MySql數(shù)據(jù)庫(kù)");

通過(guò)圖書(shū)名稱在類型表里查詢圖書(shū)編號(hào),根據(jù)編號(hào)更改信息表里的圖書(shū)價(jià)格

刪除數(shù)據(jù)

delete from bookback where ReaderId = (select ReaderId from readerinfo where ReaderId = 'R0001');

根據(jù)從讀者信息表里查找的讀者編號(hào)在圖書(shū)歸還表里刪除數(shù)據(jù)

3.4 視圖

視圖名

定義視圖和查詢視圖語(yǔ)句

說(shuō)明

readerinfo_v

create view readerinfo_v (讀者編號(hào),姓名,性別,職業(yè),出生日期,證件號(hào)碼,電話,電子郵箱)as select ReaderId,ReaderName,Sex,Vocation,Birthday,Identify,Tel,Emailfrom readerinfo where Vocation = '學(xué)生';

select * from readerinfo_v;

創(chuàng)建視圖readerinfo_v,字段名用中文表示,包含所有學(xué)生的讀者編號(hào)、姓名、性別、職業(yè)、出生日期、證件號(hào)碼、電話和電子郵箱

readerlist_v

create view readerlist_v (ReaderId,ReaderName,Bookname,BorrowTime,BackTime)as select readerinfo.ReaderId,readerinfo.ReaderName,Bookname,BorrowTime,BackTimefrom readerinfo,bookinfo,bookborrow where readerinfo.ReaderId = bookborrow.ReaderId and bookborrow.BookId = bookinfo.BookId;

select * from readerlist_v;

創(chuàng)建視圖readerlist_v,包含讀者編號(hào),姓名,書(shū)名,借書(shū)時(shí)間和歸還時(shí)間

3.5 索引

索引名

定義索引語(yǔ)句

說(shuō)明

manager_index

create index manager_index on manager(Name);

show index from manager;

對(duì)管理員信息表的管理員名稱創(chuàng)建普通索引

bookinfo_index

create unique index bookinfo_index on bookinfo(Bookname);

show index from bookinfo;

對(duì)圖書(shū)信息表中的Bookname創(chuàng)建唯一性索引

combine_index

create index combine_index on readerinfo(ReaderId,ReaderName,Tel);

show index from readerinfo;

對(duì)讀者信息表中的讀者編號(hào)、姓名和電話創(chuàng)建組合索引

3.6 存儲(chǔ)過(guò)程

存儲(chǔ)過(guò)程名

定義及調(diào)用存儲(chǔ)過(guò)程語(yǔ)句

說(shuō)明

select_p

delimiter //

create procedure select_p(in Bid char(10))

begin

select * from bookinfo,bookborrow

where bookinfo.BookId = Bid and bookinfo.BookId = bookborrow.BookId;

end//

delimiter ;

call select_p('000001');

創(chuàng)建存儲(chǔ)過(guò)程,通過(guò)輸入圖書(shū)編號(hào)來(lái)查詢圖書(shū)信息和圖書(shū)借閱信息

update_p

delimiter //

create procedure update_p(in Rid char(10),in Rn varchar(10))

begin

update bookback set ReaderName = Rn where ReaderId = Rid;

end//

delimiter ;

call update_p('R0001',"浪淘沙");

創(chuàng)建存儲(chǔ)過(guò)程,根據(jù)輸入的讀者編號(hào)來(lái)更改圖書(shū)歸還表中的讀者姓名

interval_p

delimiter //

create procedure interval_p(in Date1 date,out Date2 integer)

begin

set Date2 = datediff(curdate(),Date1);

end//

delimiter ;

call interval_p('2022-10-23',@Date2);

select @Date2;

創(chuàng)建存儲(chǔ)過(guò)程,通過(guò)讀者借書(shū)時(shí)間與當(dāng)前時(shí)間比較,得出實(shí)際借閱天數(shù)

compare_p

delimiter //

create procedure compare_p(in b1 char(10),in b2 char(10),out v varchar(30))

begin declare quantity1,quantity2 integer;

select quantity into quantity1 from booktype where BookId = b1;

select quantity into quantity2 from booktype where BookId = b2;

if quantity1>quantity2

then set v = "推薦您讀第一本書(shū)!";

else set v = "推薦您讀第二本書(shū)!" ;

end if;

end//

delimiter ;

call compare_p('000001','000002',@v);

select @v;

創(chuàng)建存儲(chǔ)過(guò)程,通過(guò)比較兩本圖書(shū)的圖書(shū)數(shù)量,來(lái)為讀者推薦所讀書(shū)籍

cursor_p

delimiter //

create procedure cursor_p()

begin

declare ReaderIds char(10);

declare BorrowTimes date;

declare BackTimes date;

declare IfBacks varchar(10);

declare infor_cursor cursor for select ReaderId,BorrowTime,BackTime,IfBack from bookborrow;

declare continue handler for not found set @cur=0;

set @cur=1;

open infor_cursor;

fetch infor_cursor into ReaderIds,BorrowTimes,BackTimes,IfBacks;

while @cur do

select ReaderIds,BorrowTimes,BackTimes,IfBacks;

fetch infor_cursor into ReaderIds,BorrowTimes,BackTimes,IfBacks;

end while;

close infor_cursor;

end//

delimiter ;

call cursor_p();

創(chuàng)建存儲(chǔ)過(guò)程,使用fetch語(yǔ)句檢索數(shù)據(jù),并將游標(biāo)指向從圖書(shū)借閱表里查詢出的結(jié)果集里

3.7 存儲(chǔ)函數(shù)

存儲(chǔ)函數(shù)名

定義及調(diào)用存儲(chǔ)函數(shù)語(yǔ)句

說(shuō)明

count_fun

delimiter //

create function count_fun()

returns char(10)

deterministic

begin

declare sumc char(20);

select count(*) into sumc from bookinfo where Price >= 50;

return sumc;

end //

delimiter ;

select count_fun();

創(chuàng)建存儲(chǔ)函數(shù),返回圖書(shū)價(jià)格不小于50的總數(shù)

total_fun

delimiter //

create function total_fun(Bid char(10))

returns decimal(10,2)

deterministic

begin

declare pri decimal(10,2);

declare qy char(20);

declare totals decimal(10,2);

select Price into pri from bookinfo where BookId = Bid;

select Quantity into qy from booktype where BookId = Bid;

set totals = pri * qy;

return totals;

end //

delimiter ;

select total_fun('000001');

創(chuàng)建存儲(chǔ)函數(shù),通過(guò)輸入的圖書(shū)編號(hào)來(lái)計(jì)算剩余書(shū)本的總價(jià)

select_fun

delimiter //

create function select_fun(Rid char(10))

returns char(10)

deterministic

begin

declare Rne char(10);

select ReaderName into Rne from readerinfo where ReaderId = Rid;

if Rne is null then

set Rne = "未找到該讀者!";

return Rne;

else

return Rne;

end if;

end //

delimiter ;

select select_fun('R0001');

創(chuàng)建存儲(chǔ)函數(shù),通過(guò)輸入的讀者編號(hào)來(lái)查詢讀者姓名,如果為空返回"未找到該讀者!",否則返回讀者姓名

compare_fun

delimiter //

create function compare_fun(Id1 char(10),Id2 char(10))

returns char(20)

DETERMINISTIC

begin

declare Rid1 char(10);

declare Rid2 char(10);

declare pce1 Decimal(10,2);

declare pce2 Decimal(10,2);

declare Bn varchar(60);

select Price into pce1 from bookinfo where BookId = Rid1;

select Price into pce2 from bookinfo where BookId = Rid2;

if pce1 < pce2 then

set Bn = "第一本書(shū)較便宜!";

else

set Bn = "第二本書(shū)較便宜!";

end if;

return Bn;

end//

delimiter ;

select compare_fun('000001','000002');

創(chuàng)建存儲(chǔ)函數(shù),通過(guò)輸入兩個(gè)圖書(shū)編號(hào)來(lái)比較相應(yīng)價(jià)格,為讀者選擇較便宜的書(shū)籍

pric_fun

delimiter //

create function pric_fun(Bid char(10))

returns decimal(10,2)

deterministic

begin

declare p decimal(10,2);

select Price into p from bookinfo where BookId=Bid;

return p;

end //

delimiter ;

select pric_fun('000001');

創(chuàng)建存儲(chǔ)函數(shù),通過(guò)輸入圖書(shū)編號(hào)來(lái)返回對(duì)應(yīng)的圖書(shū)價(jià)格

3.8 觸發(fā)器

觸發(fā)器名

定義及使用觸發(fā)器語(yǔ)句

說(shuō)明

update_trig

delimiter //

create trigger update_trig before update

on readerinfo for each row

begin

update bookborrow set ReaderName=new.ReaderName;

update bookback set ReaderName=new.ReaderName;

end //

delimiter ;

update readerinfo set ReaderName = "望海潮" where ReaderId = 'R0001';

select * from bookborrow where ReaderId = 'R0001';

select * from bookback where ReaderId = 'R0001';

創(chuàng)建觸發(fā)器,修改讀者信息表中的讀者姓名時(shí)同時(shí)修改圖書(shū)借閱表和圖書(shū)歸還表中的讀者姓名

delete_trig

delimiter //

create trigger delete_trig after delete

on readerinfo for each row

begin

delete from bookborrow where ReaderId=old.ReaderId;

delete from bookback where ReaderId=old.ReaderId;

end //

delimiter ;

delete from readerinfo where ReaderId='R0002';

select * from bookborrow where ReaderId = 'R0002';

select * from bookback where ReaderId = 'R0002';

創(chuàng)建觸發(fā)器,刪除讀者信息表中的讀者信息時(shí)同時(shí)把借閱信息與歸還信息全部刪除

insert_trig

delimiter //

create trigger insert_trig before insert

on bookinfo for each row

begin

if new.Price < 20 then signal sqlstate 'HY000' set message_text = '價(jià)格不能低于20!';

end if ;

end //

delimiter ;

insert into bookinfo values ('001', '軟件工程', '張某某', '000003', 19.8, '清華大學(xué)出版社');

創(chuàng)建觸發(fā)器,限制插入數(shù)據(jù),當(dāng)圖書(shū)價(jià)格低于20時(shí)插入失敗并給出提示

drop_trig

delimiter //

create trigger drop_trig after delete

on bookback for each row

begin

if old.ReaderId = 'R0001' then signal sqlstate 'HY000' set message_text = '刪除失敗,你不是管理員!';

end if ;

end //

delimiter ;

delete from bookback where ReaderId = 'R0001';

創(chuàng)建觸發(fā)器,刪除圖書(shū)歸還表中的數(shù)據(jù)時(shí)提示“非管理員,刪除失敗”

3.9 事件

事件名

定義事件語(yǔ)句

說(shuō)明

update_event

set @@global.event_scheduler = true;

delimiter //

create event update_event on schedule every 2 year starts now()

do begin

update bookborrow set IfBack = "黑名單"

where datediff(curdate(),BorrowTime) > datediff(BackTime,BorrowTime)

and IfBack = "否";

end//

delimiter ;

select * from bookborrow;

創(chuàng)建事件,現(xiàn)在開(kāi)始并每?jī)赡陥?zhí)行一次,把逾期未歸還的讀者的IfBack改為黑名單

clean_event

set @@global.event_scheduler = true;

create event clean_event on schedule

every 15 second ends '2022-12-13 16:10:00'

do truncate readerinfo;

select * from readerinfo;

創(chuàng)建事件,清空readerinfo表,現(xiàn)在開(kāi)始并每15S執(zhí)行一次,在規(guī)定時(shí)間終止

blacklist_event

set @@global.event_scheduler = true;

create table blacklist like bookborrow;

delimiter //

create event blacklist_event on schedule every 1 year starts now()

do begin

insert into blacklist select * from bookborrow

where datediff(curdate(),BorrowTime) > datediff(BackTime,BorrowTime)

and IfBack = "否";

end //

delimiter ;

select * from blacklist;

創(chuàng)建事件,現(xiàn)在開(kāi)始并每一年執(zhí)行一次,把逾期未歸還的讀者信息插入blacklist表中

delback_event

set @@global.event_scheduler = true;

delimiter //

create event delback_event on schedule every 1 year starts now()

do begin

delete from bookback

where ReaderId in (select ReaderId from bookborrow where IfBack = "黑名單");

end //

delimiter ;

select * from bookback;

創(chuàng)建事件,現(xiàn)在開(kāi)始并每一年執(zhí)行一次,把變?yōu)楹诿麊蔚膱D書(shū)歸還表信息刪掉

book_total

set @@global.event_scheduler = true;

create table book_total(counts int not null primary key);

delimiter //

create event counts_event on schedule every 1 year starts now()

do begin

insert into book_total select sum(Quantity) from booktype;

end//

delimiter ;

select * from book_total;

創(chuàng)建事件,現(xiàn)在開(kāi)始并每一年執(zhí)行一次,合計(jì)圖書(shū)總數(shù)量

3.10 事務(wù)(在存儲(chǔ)過(guò)程中使用事務(wù))

存儲(chǔ)過(guò)程名

定義及調(diào)用存儲(chǔ)過(guò)程語(yǔ)句

說(shuō)明

delete_aff

delimiter //

create procedure delete_aff(in Rid char(10))

begin

declare exit handler for sqlexception rollback;

start transaction;

delete from bookborrow where bookborrow.ReaderId = Rid;

delete from bookback where bookback.ReaderId = Rid;

commit;

end //

delimiter ;

call delete_aff('R0002');

select * from bookborrow where ReaderId='R0002';

select * from bookback where ReaderId='R0002';

創(chuàng)建存儲(chǔ)過(guò)程,在其中使用事務(wù),當(dāng)刪除借閱表中的信息同時(shí)刪除歸還表的對(duì)應(yīng)信息

insert_aff

delimiter //

create procedure insert_aff(in Bid char(10),in Bne varchar(60),in Qty char(20),in Tp varchar(30),in Sf varchar(20))

begin

declare exit handler for sqlexception rollback;

start transaction;

insert into booktype values(Bid,Bne,Qty,Tp,Sf);

commit;

end //

delimiter ;

call insert_aff('000003',"C語(yǔ)言程序設(shè)計(jì)",97,"編程書(shū)籍","3號(hào)書(shū)架");

select * from booktype where BookId=000003;

創(chuàng)建存儲(chǔ)過(guò)程,在其中使用事務(wù),向圖書(shū)類型表中插入數(shù)據(jù)

update_aff

delimiter //

create procedure update_aff(in Rne varchar(10),in Rid char(10))

begin

declare exit handler for sqlexception rollback;

start transaction;

update readerinfo set ReaderName = Rne where ReaderId = Rid;

update bookborrow set ReaderName = Rne where ReaderId = Rid;

update bookback set ReaderName = Rne where ReaderId = Rid;

commit;

end //

delimiter ;

call update_aff("燕歌行",'R0002');

select * from readerinfo where ReaderId='R0002';

select * from bookborrow where ReaderId='R0002';

select * from bookback where ReaderId='R0002';

創(chuàng)建存儲(chǔ)過(guò)程,在其中使用事務(wù),當(dāng)修改讀者信息表中的讀者姓名同時(shí)修改借閱表和歸還表中的讀者姓名

3.11 數(shù)據(jù)庫(kù)用戶及權(quán)限分配

用戶名

定義用戶語(yǔ)句

權(quán)限分配與回收語(yǔ)句

說(shuō)明

admin01

create user 'admin01'@'localhost' identified by '123456';

grant select on readerinfo to 'admin01'@'localhost';

grant update on bookinfo to 'admin01'@'localhost';

revoke update on bookinfo from 'admin01'@'localhost';

show grants for admin01@localhost;

創(chuàng)建用戶,授予用戶對(duì)讀者信息表select權(quán)限,對(duì)圖書(shū)信息表update權(quán)限。回收?qǐng)D書(shū)信息表update權(quán)限

admin02

create user 'admin02'@'localhost' identified by '123456';

grant all on manager to 'admin02'@'localhost' identified by '123456' with grant option;

revoke update,delete on manager from 'admin02'@'localhost';

show grants for admin02@localhost;

創(chuàng)建用戶,授予用戶對(duì)管理員信息表的所有權(quán)限,并允許授予其他用戶。回收修改和刪除權(quán)限

3.12 備份與恢復(fù)

操作類型

對(duì)應(yīng)操作的SQL語(yǔ)句

說(shuō)明

備份

mysqldump -u root -p library_lwl >D:\library_lwl_backup.sql

使用mysqldump命令備份library_lwl數(shù)據(jù)庫(kù)中的所有表到D盤(pán)

恢復(fù)

drop table bookback;

mysql -u root -p library_lwl <D:\library_lwl_backup.sql

source D:\library_lwl_backup.sql

select * from bookback;

使用mysql或source命令將備份文件恢復(fù)到數(shù)據(jù)庫(kù)

導(dǎo)出

select * from readerinfo into outfile 'D:/readerinfo.txt'

fields terminated by ' '

optionally enclosed by '"'

lines terminated by ';';

導(dǎo)出讀者信息表的數(shù)據(jù)到D盤(pán),字符用雙引號(hào)標(biāo)注,字段值間用空格隔開(kāi),每行以分號(hào)結(jié)束

導(dǎo)入

create table bk_readerinfo like readerinfo;

select * from bk_readerinfo;

load data infile 'D:/readerinfo.txt' into table bk_readerinfo

fields terminated by ' '

optionally enclosed by '"'

lines terminated by ';';

select * from bk_readerinfo;

創(chuàng)建bk_readerinfo表,將導(dǎo)出的數(shù)據(jù)導(dǎo)入到該表中

4 項(xiàng)目總結(jié)及心得

項(xiàng)目剛開(kāi)始是非常難的,雖然內(nèi)容都是之前講過(guò)的,但是如果只局限于學(xué)過(guò)的內(nèi)容是提高不了自己的能力的,所以每道題我都會(huì)思考很多新的思路,通過(guò)詢問(wèn)老師,與同學(xué)交流,我真的學(xué)到了課堂上沒(méi)有的內(nèi)容。

雖然期間遇到了許許多多的問(wèn)題與錯(cuò)誤,但只要相信自己,一直堅(jiān)持做下去,就一定可以學(xué)會(huì)學(xué)好。通過(guò)這次項(xiàng)目的學(xué)習(xí),真真正正的讓我學(xué)到了好多書(shū)上沒(méi)有的內(nèi)容,老師的耐心解答和同學(xué)們的互幫互助使我受益匪淺,而這次項(xiàng)目也會(huì)成為我積累的經(jīng)驗(yàn),使得我以后的工作可以順利進(jìn)行,并進(jìn)一步提高自己的學(xué)習(xí)能力和思考能力。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-417276.html

到了這里,關(guān)于MySQL數(shù)據(jù)庫(kù)期末項(xiàng)目 圖書(shū)館管理系統(tǒng)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 數(shù)據(jù)庫(kù)課程設(shè)計(jì)-圖書(shū)館管理系統(tǒng)(3. 用戶軟件,基于QT)

    數(shù)據(jù)庫(kù)課程設(shè)計(jì)-圖書(shū)館管理系統(tǒng)(3. 用戶軟件,基于QT)

    如果對(duì)你有幫助,可以給卑微的博主留個(gè)贊、關(guān)注、收藏? ?(不是)? (騙一下數(shù)據(jù),說(shuō)不定以后面試就過(guò)了,拜謝) 用戶軟件的實(shí)現(xiàn)根據(jù)自己所用語(yǔ)言選擇對(duì)應(yīng)開(kāi)發(fā)工具,c++ 較常用的是QT或者M(jìn)FC。這里使用QT做個(gè)示例,但博主前端屬實(shí)現(xiàn)學(xué)現(xiàn)賣,也就是能用級(jí)別,可以參考一下

    2024年02月09日
    瀏覽(25)
  • 【數(shù)據(jù)庫(kù)課設(shè)】圖書(shū)館資源管理系統(tǒng) 源碼+流程圖+結(jié)構(gòu)設(shè)計(jì)(借還圖書(shū) 逾期罰款 圖書(shū)管理 讀者管理 信息查詢)python實(shí)現(xiàn)

    【數(shù)據(jù)庫(kù)課設(shè)】圖書(shū)館資源管理系統(tǒng) 源碼+流程圖+結(jié)構(gòu)設(shè)計(jì)(借還圖書(shū) 逾期罰款 圖書(shū)管理 讀者管理 信息查詢)python實(shí)現(xiàn)

    一個(gè)管理員編號(hào)對(duì)應(yīng)一個(gè)密碼,且需要有管理員注冊(cè)密匙。 可以在圖書(shū)信息表中錄入、修改、刪除圖書(shū)。 可以在圖書(shū)信息表中查詢書(shū)籍。 可以編輯圖書(shū)借閱、歸還信息。 可以編輯欠款信息。 可以編輯讀者信息表。 圖書(shū)館注冊(cè),獲得讀者編號(hào)。 可以在圖書(shū)信息表中查閱書(shū)籍

    2024年02月10日
    瀏覽(26)
  • JavaWeb期末項(xiàng)目 圖書(shū)館管理系統(tǒng)

    JavaWeb期末項(xiàng)目 圖書(shū)館管理系統(tǒng)

    1 項(xiàng)目基本信息 1.1 項(xiàng)目名稱 圖書(shū)館管理系統(tǒng) 1.2 開(kāi)發(fā)運(yùn)行環(huán)境 Window 10 64位 JDK 1.8.0 Eclipse 4.8版本 MySql 5.5 Tomcat 9.0 2 項(xiàng)目需求分析 2.1 學(xué)生登錄部分 (1)學(xué)生注冊(cè):在進(jìn)入圖書(shū)館前必須要登錄,如果沒(méi)有學(xué)號(hào)則要注冊(cè),注冊(cè)時(shí)系統(tǒng)會(huì)將用戶填寫(xiě)的學(xué)號(hào)與數(shù)據(jù)庫(kù)里面的數(shù)據(jù)對(duì)比,

    2024年02月10日
    瀏覽(31)
  • 【數(shù)據(jù)庫(kù)——MySQL(實(shí)戰(zhàn)項(xiàng)目1)】(1)圖書(shū)借閱系統(tǒng)——數(shù)據(jù)庫(kù)結(jié)構(gòu)設(shè)計(jì)

    【數(shù)據(jù)庫(kù)——MySQL(實(shí)戰(zhàn)項(xiàng)目1)】(1)圖書(shū)借閱系統(tǒng)——數(shù)據(jù)庫(kù)結(jié)構(gòu)設(shè)計(jì)

    經(jīng)過(guò)前期的學(xué)習(xí),我們已經(jīng)掌握數(shù)據(jù)庫(kù)基礎(chǔ)操作,因此是時(shí)候來(lái)做一個(gè)實(shí)戰(zhàn)項(xiàng)目了—— 圖書(shū)借閱系統(tǒng) 。對(duì)于圖書(shū)借閱系統(tǒng),相信大家不難想到至少需要 3 張表,分別是: 借閱人表 , 圖書(shū)表 和 借閱信息表 (當(dāng)然不限于這些表,大家可以根據(jù)自己的想法創(chuàng)建其它表)。 那么

    2024年02月03日
    瀏覽(33)
  • jsp 圖書(shū)銷售系統(tǒng)Myeclipse開(kāi)發(fā)mysql數(shù)據(jù)庫(kù)web結(jié)構(gòu)java編程計(jì)算機(jī)網(wǎng)頁(yè)項(xiàng)目

    jsp 圖書(shū)銷售系統(tǒng)Myeclipse開(kāi)發(fā)mysql數(shù)據(jù)庫(kù)web結(jié)構(gòu)java編程計(jì)算機(jī)網(wǎng)頁(yè)項(xiàng)目

    一、源碼特點(diǎn) ?? ? JSP 圖書(shū)銷售系統(tǒng)是一套完善的java web信息管理系統(tǒng),對(duì)理解JSP java編程開(kāi)發(fā)語(yǔ)言有幫助,系統(tǒng)具有完整的源代碼和數(shù)據(jù)庫(kù),系統(tǒng)主要采用B/S模式開(kāi)發(fā)。開(kāi)發(fā)環(huán)境為 TOMCAT7.0,Myeclipse8.5開(kāi)發(fā),數(shù)據(jù)庫(kù)為Mysql5.0,使用java語(yǔ)言開(kāi)發(fā)。 jsp 圖書(shū)銷售系統(tǒng)Myeclipse開(kāi)發(fā)mys

    2024年02月11日
    瀏覽(20)
  • Android期末大作業(yè):使用AndroidStudio開(kāi)發(fā)圖書(shū)管理系統(tǒng)APP(使用sqlite數(shù)據(jù)庫(kù))

    Android期末大作業(yè):使用AndroidStudio開(kāi)發(fā)圖書(shū)管理系統(tǒng)APP(使用sqlite數(shù)據(jù)庫(kù))

    Android Studio開(kāi)發(fā)項(xiàng)目圖書(shū)管理系統(tǒng)項(xiàng)目視頻展示: 點(diǎn)擊進(jìn)入圖書(shū)管理系統(tǒng)項(xiàng)目視頻 現(xiàn)在是一個(gè)信息高度發(fā)達(dá)的時(shí)代,伴隨著科技的進(jìn)步,文化的汲取,人們對(duì)于圖書(shū)信息的了解與掌握也達(dá)到了一定的高度。尤其是學(xué)生對(duì)于知識(shí)的渴求更是與日俱增。圖書(shū)館作為學(xué)生學(xué)習(xí)知識(shí)的

    2024年02月08日
    瀏覽(30)
  • 【C#項(xiàng)目】圖書(shū)館管理系統(tǒng)-WinForm+MySQL

    【C#項(xiàng)目】圖書(shū)館管理系統(tǒng)-WinForm+MySQL

    圖書(shū)館管理系統(tǒng)主要功能有普通用戶(學(xué)生)借書(shū)、管理員管理圖書(shū)。 1.功能描述 系統(tǒng)中的普通用戶模塊有以下功能: 圖書(shū)查詢:根據(jù)輸入的搜索條件進(jìn)行查詢,可以查找多項(xiàng),也可以查找所有圖書(shū)。 圖書(shū)借閱:提供圖書(shū)借閱證號(hào),可以進(jìn)行圖書(shū)借閱。 系統(tǒng)中的管理員用戶

    2024年02月02日
    瀏覽(33)
  • 安卓期末大作業(yè)-圖書(shū)館借書(shū)系統(tǒng)、圖書(shū)借閱app(附下載鏈接)

    安卓期末大作業(yè)-圖書(shū)館借書(shū)系統(tǒng)、圖書(shū)借閱app(附下載鏈接)

    安卓期末大作業(yè),圖書(shū)借閱APP,老師給了95分,可以注冊(cè)登錄,借閱書(shū)籍,還書(shū),含數(shù)據(jù)庫(kù)存儲(chǔ)借書(shū)記錄,導(dǎo)入AndroidStudio即可使用,代碼注釋詳細(xì) 點(diǎn)我下載項(xiàng)目源碼 進(jìn)入APP界面: 注冊(cè)登錄界面如下所示: 登錄界面: 注冊(cè)部分代碼: @Override protected void onStop() { super.onStop();

    2024年02月03日
    瀏覽(21)
  • 圖書(shū)管理系統(tǒng)2.0——mysql數(shù)據(jù)庫(kù)

    圖書(shū)管理系統(tǒng)2.0——mysql數(shù)據(jù)庫(kù)

    1、使用技術(shù) 原生java+swing+jdbc驅(qū)動(dòng)+mysql 沒(méi)有任何框架 2、簡(jiǎn)要功能 3、 源碼 https://gitee.com/wang-yongyan188/bms.git 1、登錄 代碼運(yùn)行后 ,會(huì)彈出登錄窗口 輸入用戶名(用戶名唯一),賬號(hào)密碼 且密碼不可見(jiàn) 如果輸入正確,會(huì)判斷是管理員還是用戶,進(jìn)入不同頁(yè)面菜單 如果輸入錯(cuò)誤

    2024年02月06日
    瀏覽(23)
  • 4.2 圖書(shū)借閱系統(tǒng)數(shù)據(jù)庫(kù)設(shè)計(jì) --MySQL

    4.2 圖書(shū)借閱系統(tǒng)數(shù)據(jù)庫(kù)設(shè)計(jì) --MySQL

    大家好,我是天罡gg,一個(gè)有十多年豐富經(jīng)驗(yàn)的高級(jí)架構(gòu)師,參與過(guò)很多系統(tǒng)的數(shù)據(jù)庫(kù)設(shè)計(jì),在數(shù)據(jù)庫(kù)設(shè)計(jì)方面有相當(dāng)豐富的經(jīng)驗(yàn)。正趕上這篇實(shí)戰(zhàn)專欄的數(shù)據(jù)庫(kù)設(shè)計(jì),所以今天讓我們來(lái)一起做一下《圖書(shū)借閱系統(tǒng)的數(shù)據(jù)庫(kù)設(shè)計(jì)》,一篇既有理論知識(shí),又能實(shí)戰(zhàn)落地的數(shù)據(jù)庫(kù)

    2023年04月20日
    瀏覽(22)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包