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;
目录
相关文章
|
设计模式 消息中间件 传感器
Java 设计模式之观察者模式:构建松耦合的事件响应系统
观察者模式是Java中常用的行为型设计模式,用于构建松耦合的事件响应系统。当一个对象状态改变时,所有依赖它的观察者将自动收到通知并更新。该模式通过抽象耦合实现发布-订阅机制,广泛应用于GUI事件处理、消息通知、数据监控等场景,具有良好的可扩展性和维护性。
1029 8
|
移动开发 监控 小程序
java家政平台源码,家政上门清洁系统源码,数据多端互通,可直接搭建使用
一款基于Java+SpringBoot+Vue+UniApp开发的家政上门系统,支持小程序、APP、H5、公众号多端互通。涵盖用户端、技工端与管理后台,支持多城市、服务分类、在线预约、微信支付、抢单派单、技能认证、钱包提现等功能,源码开源,可直接部署使用。
1029 24
|
安全 前端开发 Java
使用Java编写UDP协议的简易群聊系统
通过这个基础框架,你可以进一步增加更多的功能,例如用户认证、消息格式化、更复杂的客户端界面等,来丰富你的群聊系统。
464 11
|
机器学习/深度学习 人工智能 自然语言处理
Java与生成式AI:构建内容生成与创意辅助系统
生成式AI正在重塑内容创作、软件开发和创意设计的方式。本文深入探讨如何在Java生态中构建支持文本、图像、代码等多种生成任务的创意辅助系统。我们将完整展示集成大型生成模型(如GPT、Stable Diffusion)、处理生成任务队列、优化生成结果以及构建企业级生成式AI应用的全流程,为Java开发者提供构建下一代创意辅助系统的完整技术方案。
615 10
|
人工智能 监控 Java
Java与AI智能体:构建自主决策与工具调用的智能系统
随着AI智能体技术的快速发展,构建能够自主理解任务、制定计划并执行复杂操作的智能系统已成为新的技术前沿。本文深入探讨如何在Java生态中构建具备工具调用、记忆管理和自主决策能力的AI智能体系统。我们将完整展示从智能体架构设计、工具生态系统、记忆机制到多智能体协作的全流程,为Java开发者提供构建下一代自主智能系统的完整技术方案。
1372 4
|
算法 Java 数据库连接
面试疑难点解析——Java数据库开发(九)
本文主要教大家区分悲观锁与乐观锁,帮助大家巩固Java开发性相关知识,提高面试通过率。
面试疑难点解析——Java数据库开发(九)
|
监控 算法 druid
面试疑难点解析——Java数据库开发(八)
本文向同学们介绍数据源的配置以及数据随机抽取方法,帮助大家巩固Java开发性相关知识,提高面试通过率。
|
NoSQL Java 关系型数据库
面试疑难点解析——Java数据库开发(七)
本文介绍事务处理的四个特性:ACID,以及开发中可能见到的事务处理模式。
|
Java 数据库连接 数据库
面试疑难点解析——Java数据库开发(六)
本文通过案例向同学们阐明检测数据库更新的两个误区以及连接池实现原理。
面试疑难点解析——Java数据库开发(六)
|
缓存 负载均衡 NoSQL
面试疑难点解析——Java数据库开发(五)
为什么需要有缓存?缓存的实现有哪些?关于缓存这9个问题,你需要了解~
面试疑难点解析——Java数据库开发(五)