图书管理系统数据库设计
一、系统概述
1、系统简介
图书管理是每个图书馆都需要进行的工作。一个设计良好的图书管理系统数据库能够给图书管理带来很大的便利。
2、需求分析
图书管理系统的需求定义为:
1.学生可以直接通过借阅终端来查阅书籍信息,同时也可以查阅自己的借阅信息。
2.当学生需要借阅书籍时,通过账号密码登陆借阅系统,借阅系统处理学生的借阅,同时修改图书馆保存的图书信息,修改被借阅的书籍是否还有剩余,同时更新学生个人的借阅信息。
3.学生借阅图书之前需要将自己的个人信息注册,登陆时对照学生信息。
4.学生直接归还图书,根据图书编码修改借阅信息
5.管理员登陆管理系统后,可以修改图书信息,增加或者删除图书信息
6.管理员可以注销学生信息。
通过需求定义,画出图书管理系统的数据流图:
数据流图
二、系统功能设计
  画出系统功能模块图并用文字对各功能模块进行详细介绍。
系统功能模块图:
三、数据库设计方案图表
  1、系统E-R模型
总体E-R图:
精细化的局部E-R图:
学生借阅-归还E-R图:
管理员E-R图:
  2、设计表
    给出设计的表名、结构以及表上设计的完整性约束。
student:
列名
数据类型
是否为空/性质
说明
stu_id
int
not null /PK
标明学生唯一学号
stu_name
varchar
not null
学生姓名
stu_sex
varchar
not null
学生性别
stu_age
int
not null
学生年龄
stu_pro
varchar
not null
学生专业
stu_grade
varchar
not null
学生年级
stu_integrity
int
not null/default=1
学生诚信级
图书管理系统数据库设计说明书
book:
列名
数据类型
是否为空/性质
说明
book_id
int
not null / PK
唯一书籍序号
book_name
varchar
not null
书籍名称
book_author
varchar
not null
书籍作者
book_pub
varchar
not null
书籍出版社
book_num
int
not null
书籍是否在架上
book_sort
varchar
not null
书籍分类
book_record
datatime
null
书籍登记日期
book_sort:
列名
数据类型
是否为空/性质
说明
sort_id
varchar
not null / PK
类型编号
sort_name
varchar
not null
类型名称
borrow:存储学生的借书信息
列名
数据类型
是否为空/性质
说明
student_id
varchar
not null / PK
学生编号
book_id
varchar
not null / PK
书籍编号
borrow_date
datatime
null
借书时间
expect_return_date
datetime
null
预期归还时间
return_table:存储学生的归还信息
列名
数据类型
是否为空/性质
说明
student_id
varchar
not null / PK
学生编号
book_id
varchar
not null / PK
书籍编号
borrow_date
datetime
null
借书时间
return_date
datatime
null
实际还书时间
ticket:存储学生的罚单信息
列名
数据类型
是否为空/性质
说明
student_id
varchar
not null / PK
学生编号
book_id
varchar
not null / PK
书籍编号
over_date
int
null
超期天数
ticket_fee
float
null
处罚金额
manager:
列名
数据类型
是否为空/性质
说明
manager_id
varchar
not null / PK
管理员编号
manager_name
varchar
not null
管理员姓名
manager_age
varchar
not null
管理员年龄
manager_phone
varchar
not null
管理员电话
  3、设计索引
给出在各表上建立的索引以及使用的语句。
student
1.为stu_id创建索引,升序排序
sql:create index index_id on student(stu_id asc);
2.为stu_name创建索引,并且降序排序
sql:alter table student add index index_name(stu_name, desc);
插入索引操作和结果如下所示:
mysql> create index index_id on student(stu_id asc);
Query OK, 0 rows affected
Records: 0  Duplicates: 0  Warnings: 0
mysql> alter table student add index index_name(stu_name desc);
Query OK, 0 rows affected
Records: 0  Duplicates: 0  Warnings: 0
mysql>
book:
1.为book_id创建索引,升序排列
sql:create index index_bid on book(book_id);
2.为book_record创建索引,以便方便查询图书的登记日期信息,升序:
sql:create index index_brecord on book(book_record);
插入索引的操作和结果如下所示:
mysql> create index index_bid on book(book_id);
Query OK, 0 rows affected
Records: 0  Duplicates: 0  Warnings: 0
mysql> create index index_brecord on book(book_record);
Query OK, 0 rows affected
Records: 0  Duplicates: 0  Warnings: 0
borrow:
1.为stu_id和book_id创建多列索引:
sql:create index index_sid_bid on borrow(stu_id asc, book_id asc);