From 9ac8a365791491f4acbd880018cbd7723e1795d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B7=AF=E7=8E=B2?= <1516489926@qq.com> Date: Mon, 11 Sep 2023 22:00:51 +0800 Subject: [PATCH] =?UTF-8?q?9=E6=9C=888=E5=8F=B7=E5=9B=BE=E4=B9=A6=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...41\347\220\206\347\263\273\347\273\237.md" | 284 ++++++++++++++---- 1 file changed, 225 insertions(+), 59 deletions(-) diff --git "a/29 \350\267\257\347\216\262/20230907 \345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237.md" "b/29 \350\267\257\347\216\262/20230907 \345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237.md" index 83c8288..b0e421e 100644 --- "a/29 \350\267\257\347\216\262/20230907 \345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237.md" +++ "b/29 \350\267\257\347\216\262/20230907 \345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237.md" @@ -35,110 +35,276 @@ create database t_books charset utf8; use t_books; /*==============================================================*/ /* DBMS name: MySQL 5.0 */ -/* Created on: 2023/9/10 21:16:22 */ +/* Created on: 2023-09-11 20:27:33 */ /*==============================================================*/ -drop table if exists book_borrowing;-- 图书借阅 +drop table if exists bookinfo;-- 书籍具体信息表 -drop table if exists book_retrieval;-- 图书信息 +drop table if exists borrow;-- 借阅信息表 -drop table if exists return_books; -- 归还图书 +drop table if exists floormassage;-- 楼层信息表 -drop table if exists user; -- 用户登录 +drop table if exists gett;-- 接收人 + +drop table if exists library;-- 图书馆表 + +drop table if exists put;-- 放置图书 + +drop table if exists return_book;-- 归还信息表 + +drop table if exists user;-- 用户登录表 + +drop table if exists userinfo;-- 用户信息表 + +drop table if exists work;-- 管理员信息表 /*==============================================================*/ -/* Table: book_borrowing */ +/* Table: bookinfo */ /*==============================================================*/ -create table book_borrowing -- 图书借阅 + +-- 书籍具体信息表 +create table bookinfo ( - bb_id int not null auto_increment, -- 借阅编号 - b_id int not null, -- 用户编号 - borrow_date date not null, -- 借书日期 - expiry_date date not null, -- 终止日期 - primary key (bb_id) + book_ID int not null auto_increment, -- 书籍编号 + ID int not null, -- 楼层编号 + book_name char(20) not null, -- 书籍名称 + author varchar(15) not null, -- 书籍作者 + publish date not null, -- 出版时间 + book_price numeric(10,2) not null, -- 书籍价格 + primary key (book_ID) ); +/*==============================================================*/ +/* Table: borrow */ +/*==============================================================*/ + +-- 借阅信息表 +create table borrow +( + borrow_ID int not null auto_increment, -- 借阅编号 + book_ID int not null, -- 书籍编号 + borrow_date date not null, -- 借阅时间 + return_date date not null, -- 归还时间 + primary key (borrow_ID) +); + +/*==============================================================*/ +/* Table: floormassage */ +/*==============================================================*/ +-- 楼层信息表 +create table floormassage +( + ID int not null auto_increment, -- 楼层编号 + lib_ID int not null, -- 图书馆编号 + floor char(3) not null, -- 楼层 + shelf_ID int not null, -- 书架编号 + linenum int not null, -- 行号 + type char(10) not null, -- 类型 + primary key (ID) +); /*==============================================================*/ -/* Table: book_retrieval */ +/* Table: get */ /*==============================================================*/ -create table book_retrieval -- 图书信息 + +-- 接收人 +create table gett ( - b_id int not null auto_increment, -- 图书编号 - u_id int not null, -- 用户编号 - b_name char(20) not null, -- 书籍名称 - author char(20) not null, -- 作者 - quantity int not null, -- 图书数量 - floor char(5) not null, -- 楼层 - price numeric(20,2), -- 书籍价格 - shelf_number int, -- 书架号 - primary key (b_id) + worker_ID int not null, -- 管理员编号 + return_ID int not null, -- 归还编号 + primary key (worker_ID, return_ID) ); +/*==============================================================*/ +/* Table: library */ +/*==============================================================*/ + +-- 图书馆表 +create table library +( + lib_ID int not null auto_increment, -- 图书馆编号 + user_ID int not null, -- 用户编号 + lib_name varchar(10) not null, -- 图书馆名称 + primary key (lib_ID) +); /*==============================================================*/ -/* Table: return_books */ +/* Table: put */ /*==============================================================*/ -create table return_books -- 归还图书 + +-- 放置图书 +create table put ( - rb_id int not null auto_increment, -- 归还编号 - u_id int not null, -- 用户编号 - b_id int not null, -- 书籍编号 - return_book date, -- 归还日期 - primary key (rb_id) + lib_ID int not null, -- 楼层编号 + worker_ID int not null, -- 管理员编号 + primary key (lib_ID, worker_ID) ); +/*==============================================================*/ +/* Table: "return" */ +/*==============================================================*/ +-- 归还信息表 +create table return_book +( + return_ID int not null auto_increment, -- 归还编号 + user_ID int not null, -- 用户编号 + return_date date not null, -- 归还时间 + primary key (return_ID) +); /*==============================================================*/ /* Table: user */ /*==============================================================*/ -create table user -- 用户登录 + +-- 用户登录表 +create table user +( + user_ID int not null auto_increment, -- 用户编号 + user_name varchar(5) not null, -- 用户姓名 + password varchar(10) not null, -- 密码 + primary key (user_ID) +); + +/*==============================================================*/ +/* Table: userinfo */ +/*==============================================================*/ + +-- 用户信息表 +create table userinfo ( - u_id int not null auto_increment, -- 用户编号 - u_name char(10) not null, -- 用户名称 - u_password char(10) not null, -- 用户密码 - primary key (u_id) + userinfo_ID int not null auto_increment, -- 用户信息编号 + user_ID int not null, -- 用户编号 + userinfo_name varchar(6) not null, -- 用户姓名 + userinfo_sex char(1) not null, -- 用户性别 + college char(10) not null, -- 学院 + major char(15) not null, -- 专业 + grade char(20) not null, -- 年级 + class char(20) not null, -- 班级 + user_tel char(15) not null, -- 用户电话 + primary key (userinfo_ID) ); -alter table book_borrowing add constraint FK_borrow foreign key (b_id) - references book_retrieval (b_id) on delete restrict on update restrict; +/*==============================================================*/ +/* Table: work */ +/*==============================================================*/ + +-- 管理员信息表 +create table work +( + worker_ID int not null auto_increment, -- 员工编号 + worker_name varchar(5) not null, -- 员工姓名 + worker_sex char(1) not null, -- 员工性别 + worker_tel char(12) not null, -- 员工电话 + worker_salary int not null, -- 员工工资 + primary key (worker_ID) +); + +alter table bookinfo add constraint FK_check_book foreign key (ID) + references floormassage (ID) on delete restrict on update restrict; + +alter table borrow add constraint FK_borrow foreign key (book_ID) + references bookinfo (book_ID) on delete restrict on update restrict; + +alter table floormassage add constraint FK_check_floor foreign key (lib_ID) + references library (lib_ID) on delete restrict on update restrict; + +alter table gett add constraint FK_get foreign key (worker_ID) + references work (worker_ID) on delete restrict on update restrict; + +alter table gett add constraint FK_get2 foreign key (return_ID) + references return_book (return_ID) on delete restrict on update restrict; -alter table book_retrieval add constraint FK_check foreign key (u_id) - references user (u_id) on delete restrict on update restrict; +alter table library add constraint FK_check foreign key (user_ID) + references user (user_ID) on delete restrict on update restrict; -alter table return_books add constraint FK_return foreign key (u_id) - references user (u_id) on delete restrict on update restrict; +alter table put add constraint FK_put foreign key (lib_ID) + references library (lib_ID) on delete restrict on update restrict; -alter table return_books add constraint FK_return_books foreign key (b_id) - references book_retrieval (b_id) on delete restrict on update restrict; +alter table put add constraint FK_put2 foreign key (worker_ID) + references work (worker_ID) on delete restrict on update restrict; +alter table return_book add constraint FK_return foreign key (user_ID) + references user (user_ID) on delete restrict on update restrict; --- 添加数据 +alter table userinfo add constraint FK_information foreign key (user_ID) + references user (user_ID) on delete restrict on update restrict; + + ### 用户登录 insert into user values -- 用户登录 -(001,'张三','123'), -(002,'李四','456'), -(003,'王五','789'); +(001,'小梅','123'), +(002,'小晶','456'), +(003,'小芳','789'); + + + ### 用户信息表 +insert into userinfo values +(101,001,'韩梅梅','女','软件工程学院','前端','22级','1班','1234567892'), +(102,002,'郭晶晶','女','软件工程学院','后端','22级','2班','2345678925'), +(103,003,'李静芳','女','软件工程学院','新媒体','22级','10班','1234567894'); + + +### 图书馆信息表 +insert into library values +(201,001,'北京市图书馆'), +(202,002,'龙岩市图书馆'), +(203,003,'厦门市图书馆'); + +### 楼层信息表 +insert into floormassage values +(301,201,'四楼',337,1,'外国著作'), +(302,202,'六楼',338,2,'文学经典'), +(303,203,'五楼',339,3,'仙侠类'); + +### 书籍具体信息表 +insert into bookinfo values -- 图书信息 +(401,301,'战争与和平','列夫托尔斯泰','1869-6-6',45), +(402,302,'活着','余华','1992-12-2',60), +(403,303,'花千骨','果果','2018-12-31',80.8); + + + + + +### 借阅信息表 +insert into borrow values -- 图书借阅 +(501,401,'2023-04-16','2023-05-16'), +(502,402,'2023-04-16','2023-05-16'), +(503,403,'2023-04-16','2023-05-16'); + + + + +### 归还信息表 +insert into return_book values -- 归还图书 +(601,001,'2023-04-25'), +(602,002,'2023-05-10'), +(603,003,'2023-05-16'); + + +### 管理员 +insert into work values +(701,'张三','男','1594628347',5000), +(702,'李四','男','1569821347',4000), +(703,'李雪','女','1634957612',3000); -insert into book_retrieval values -- 图书信息 -(201,001,'水浒传','施耐庵',3,'五楼',99.9,707), -(202,002,'三国演义','罗贯中',2,'五楼',89.9,708), -(203,003,'西游记','吴承恩',4,'五楼',100,709); -insert into book_borrowing values -- 图书借阅 -(301,201,'2023-04-16','2023-05-16'), -(302,202,'2023-04-16','2023-05-16'), -(303,203,'2023-04-16','2023-05-16'); +-- 接受表 +insert into gett values +(701,601), +(702,602), +(703,603); +-- 放置表 +insert into put values +(201,701), +(202,702), +(203,703); -insert into return_books values -- 归还图书 -(401,001,201,'2023-04-25'), -(402,002,202,'2023-05-10'), -(403,003,203,'2023-05-16'); ``` -- Gitee