Java高手速成 | 数据库实训:图书馆管理系统建模

简介: 图书馆管理系统是常见的管理信息系统,考虑到系统的推广性,本系统采用SQL SERVER2000作为数据库。并且采用PowerDesigner进行数据建模,从而自动生成sql脚本。

image.png

01、数据库概念设计

1. 数据库表设计

管理员表admin:管理员编号(admin_id),管理员姓名(admin_name),密码(admin_password),登录次数(logins),最后一次登录时间(lastlogin)和权限(right)。
读者表reader:读者编号(reader_id),读者姓名(reader_name),性别(sex),年龄(age),班级(class),最大借书量(maxborrowed)借书总量(amount)和权限(right)。
书籍表books:书籍编号(book_id),书名(title),作者(author),出版社(book concert),价格(price),出版时间(time),在库总量(amount),剩余量(remain)。
借阅信息表(borrow_information):书籍编号(book_id),读者编号(reader_id),借书时间(borrow_time),到期时间(end_time),归还时间(return_time)。
预订信息表:读者编号(reader_id),书籍编号(book_id),预订时间(reservation_time),取消预订时间(reservationcanceltime)。
书籍类型表booktype:书籍类型编号(type_id),书籍类型名称(type_name)。
用户权限表right:权限(right)。

2. 图书管理系统实体之间的E-R图

image.png


▍图12.13 图书馆管理系统各实体之间的ER图

3. 基于powerdesigner的CDM数据库模型

据库逻辑结构图如下图,该图显示了各实体的属性及各实体之间的关系。

image.png


▍图12.13 数据库逻辑结构图

02、数据字典

1. 图书管理系统数据库表格清单

image.png

2. 图书管理系统数据库表格列清单

image.png


image.png


image.png

3. 表格书库

表格书库的卡片

image.png


实体书库的属性的清单

image.png

4. 表格借还书

表格借还书的卡片

image.png


实体借还书的属性的清单

image.png

5. 表格出版社

表格出版社的卡片

image.png


实体出版社的属性的清单

image.png

6. 表格图书

表格图书的卡片

image.png


实体图书的属性的清单

image.png


  1. 表格管理员

表格管理员的卡片

image.png


实体管理员的属性的清单

image.png

8. 表格读者

表格读者的卡片

image.png


实体读者的属性的清单

image.png


image.png


▍图12.14数据库物理设计

04、数据库物理代码

 
role='FK_BOOK_RELATIONS_PUBLISH') then
    alter table Book
       delete foreign key FK_BOOK_RELATIONS_PUBLISH
end if;
 
if exists(select 1 from sys.sysforeignkey where role='FK_BOOK_RELATIONS_STACK') then
    alter table Book
       delete foreign key FK_BOOK_RELATIONS_STACK
end if;
 
if exists(select 1 from sys.sysforeignkey where role='FK_BORROW B_RELATIONS_READER') then
    alter table "Borrow Book"
       delete foreign key "FK_BORROW B_RELATIONS_READER"
end if;
 
if exists(select 1 from sys.sysforeignkey where role='FK_BORROW B_RELATIONS_BOOK') then
    alter table "Borrow Book"
       delete foreign key "FK_BORROW B_RELATIONS_BOOK"
end if;
 
if exists(
   select 1 from sys.systable
   where table_name='Adminster'
     and table_type in ('BASE', 'GBL TEMP')
) then
    drop table Adminster
end if;
 
if exists(
   select 1 from sys.systable
   where table_name='Book'
     and table_type in ('BASE', 'GBL TEMP')
) then
    drop table Book
end if;
 
if exists(
   select 1 from sys.systable
   where table_name='Borrow Book'
     and table_type in ('BASE', 'GBL TEMP')
) then
    drop table "Borrow Book"
end if;
 
if exists(
   select 1 from sys.systable
   where table_name='Publish'
     and table_type in ('BASE', 'GBL TEMP')
) then
    drop table Publish
end if;
 
if exists(
   select 1 from sys.systable
   where table_name='Reader'
     and table_type in ('BASE', 'GBL TEMP')
) then
    drop table Reader
end if;
 
if exists(
   select 1 from sys.systable
   where table_name='Stack'
     and table_type in ('BASE', 'GBL TEMP')
) then
    drop table Stack
end if;
 
/*==============================================================*/
/* Table: Adminster */
/*==============================================================*/
create table Adminster
(
   AdminID char(8) not null,
   AdminName varchar(8) not null,
   Phonenumber varchar(11) not null,
   AdminPassword varchar(20) not null,
   constraint PK_ADMINSTER primary key (AdminID)
);
 
/*==============================================================*/
/* Table: Book */
/*==============================================================*/
create table Book
(
   BookID char(10) not null,
   PublishName varchar(40) null,
   StackID char(2) null,
   ISBN varchar(20) not null,
   Title varchar(40) not null,
   Author varchar(20) null,
   Price numeric(5,2) not null,
   "Book concern"       varchar(40) null,
   AddTime              date                           not null,
   Amount integer                        not null,
   Remain integer                        not null,
   constraint PK_BOOK primary key (BookID)
);
 
/*==============================================================*/
/* Table: "Borrow Book" */
/*==============================================================*/
create table "Borrow Book" 
(
   ReaderID char(10) null,
   BookID char(10) null,
   BorrowTime date                           null,
   SReturntime date                           null,
   RReturntime date                           null
);
 
/*==============================================================*/
/* Table: Publish */
/*==============================================================*/
create table Publish
(
   PublishName varchar(40) not null,
   Address varchar(40) not null,
   Phone varchar(15) not null,
   "E-mail"             varchar(30) not null,
   constraint PK_PUBLISH primary key (PublishName)
);
 
/*==============================================================*/
/* Table: Reader */
/*==============================================================*/
create table Reader
(
   ReaderID char(10) not null,
   ReaderName varchar(8) not null,
   Sex char(2) null,
   Age integer                        null,
   Class                varchar(10) not null,
   ReaderPassword varchar(20) not null,
   Maxborrowed integer                        not null,
   constraint PK_READER primary key (ReaderID)
);
 
/*==============================================================*/
/* Table: Stack */
/*==============================================================*/
create table Stack
(
   StackID char(2) not null,
   StackName varchar(10) not null,
   StackLocation varchar(20) not null,
   constraint PK_STACK primary key (StackID)
);
 
alter table Book
   add constraint FK_BOOK_RELATIONS_PUBLISH foreign key (PublishName)
      references Publish (PublishName)
      on update restrict
      on delete restrict;
 
alter table Book
   add constraint FK_BOOK_RELATIONS_STACK foreign key (StackID)
      references Stack (StackID)
      on update restrict
      on delete restrict;
 
alter table "Borrow Book"
   add constraint "FK_BORROW B_RELATIONS_READER" foreign key (ReaderID)
      references Reader (ReaderID)
      on update restrict
      on delete restrict;
 
alter table "Borrow Book"
   add constraint "FK_BORROW B_RELATIONS_BOOK" foreign key (BookID)
      references Book (BookID)
      on update restrict
      on delete restrict;
目录
相关文章
|
6月前
|
安全 关系型数据库 数据管理
阿里云数据库:构建高性能与安全的数据管理系统
阿里云数据库提供RDS、PolarDB、Tair等核心产品,具备高可用、弹性扩展、安全合规及智能运维等技术优势,广泛应用于电商、游戏、金融等行业,助力企业高效管理数据,提升业务连续性与竞争力。
|
8月前
|
SQL 监控 安全
数据库安全审计系统
Next-DBM数据库审计系统助力企业解决数据安全难题,提供统一身份管理、全方位监控、智能风险识别、完整审计追溯及精细化权限管控,有效防范数据泄露与内部威胁,保障企业核心资产安全,满足合规要求,提升运维效率。
|
8月前
|
缓存 NoSQL Linux
在CentOS 7系统中彻底移除MongoDB数据库的步骤
以上步骤完成后,MongoDB应该会从您的CentOS 7系统中被彻底移除。在执行上述操作前,请确保已经备份好所有重要数据以防丢失。这些步骤操作需要一些基本的Linux系统管理知识,若您对某一步骤不是非常清楚,请先进行必要的学习或咨询专业人士。在执行系统级操作时,推荐在实施前创建系统快照或备份,以便在出现问题时能够恢复到原先的状态。
746 79
|
10月前
|
负载均衡 算法 关系型数据库
大数据大厂之MySQL数据库课程设计:揭秘MySQL集群架构负载均衡核心算法:从理论到Java代码实战,让你的数据库性能飙升!
本文聚焦 MySQL 集群架构中的负载均衡算法,阐述其重要性。详细介绍轮询、加权轮询、最少连接、加权最少连接、随机、源地址哈希等常用算法,分析各自优缺点及适用场景。并提供 Java 语言代码实现示例,助力直观理解。文章结构清晰,语言通俗易懂,对理解和应用负载均衡算法具有实用价值和参考价值。
大数据大厂之MySQL数据库课程设计:揭秘MySQL集群架构负载均衡核心算法:从理论到Java代码实战,让你的数据库性能飙升!
|
11月前
|
Java 数据库
jsp CRM客户管理系统(含数据库脚本以及文档)
jsp CRM客户管理系统(含数据库脚本以及文档)
222 10
|
11月前
|
前端开发 数据库
会议室管理系统源码(含数据库脚本)
会议室管理系统源码(含数据库脚本)
194 0
|
12月前
|
存储 监控 数据挖掘
消防行业如何借助时序数据库 TDengine 打造高效的数据监控与分析系统
本篇文章来自“2024,我想和 TDengine 谈谈”征文活动的优秀投稿,深入探讨了如何在消防行业中运用 TDengine 进行业务建模。文章重点介绍了如何通过 TDengine 的超级表、标签设计和高效查询功能,有效管理消防监控系统中的时序数据。作者详细阐述了实时监控、报警系统以及历史数据分析在消防行业中的应用,展示了 TDengine 在数据压缩、保留策略和分布式架构下的强大优势。
347 0
|
12月前
|
前端开发 Java 关系型数据库
基于ssm的社区物业管理系统,附源码+数据库+论文+任务书
社区物业管理系统采用B/S架构,基于Java语言开发,使用MySQL数据库。系统涵盖个人中心、用户管理、楼盘管理、收费管理、停车登记、报修与投诉管理等功能模块,方便管理员及用户操作。前端采用Vue、HTML、JavaScript等技术,后端使用SSM框架。系统支持远程安装调试,确保顺利运行。提供演示视频和详细文档截图,帮助用户快速上手。
482 17
|
12月前
|
前端开发 Java 关系型数据库
基于ssm的台球厅管理系统,附源码+数据库+论文
本项目为新锐台球厅管理系统,支持管理员和会员两种角色。管理员可进行会员管理、台球桌管理、订单管理等;会员可查看台球桌、预约、购买商品等。技术框架基于Java,采用B/S架构,前端使用Vue+HTML+JavaScript+CSS+LayUI,后端使用SSM框架,数据库为MySQL。运行环境为Windows,JDK8+MySQL5.7+Tomcat8.5。提供演示视频及详细文档截图。
|
12月前
|
前端开发 Java 关系型数据库
基于ssm的网络直播带货管理系统,附源码+数据库+论文
该项目为网络直播带货网站,包含管理员和用户两个角色。管理员可进行主页、个人中心、用户管理、商品分类与信息管理、系统及订单管理;用户可浏览主页、管理个人中心、收藏和订单。系统基于Java开发,采用B/S架构,前端使用Vue、JSP等技术,后端为SSM框架,数据库为MySQL。项目运行环境为Windows,支持JDK8、Tomcat8.5。提供演示视频和详细文档截图。
332 10