图书管理系统数据库设计-MYSQL实现

  • 格式:docx
  • 大小:551.94 KB
  • 文档页数:21

下载文档原格式

  / 21
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

图书管理系统数据库设计

一、系统概述

1、系统简介

图书管理是每个图书馆都需要进行的工作。一个设计良好的图书管理系统数据库能够给图书管理带来很大的便利。

2、需求分析

图书管理系统的需求定义为:

1.学生可以直接通过借阅终端来查阅书籍信息,同时也可以查阅自己的借阅信息。

2.当学生需要借阅书籍时,通过账号密码登陆借阅系统,借阅系统处理学生的借阅,同时修改图书馆保存的图书信息,修改被借阅的书籍是否还有剩余,同时更新学生个人的借阅信息。

3.学生借阅图书之前需要将自己的个人信息注册,登陆时对照学生信息。

4.学生直接归还图书,根据图书编码修改借阅信息

5.管理员登陆管理系统后,可以修改图书信息,增加或者删除图书信息

6.管理员可以注销学生信息。

通过需求定义,画出图书管理系统的数据流图:

数据流图

三、数据库设计方案图表

1、系统E-R模型

2、设计表

给出设计的表名、结构以及表上设计的完整性约束。

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);

插入索引的操作和结果如下所示:

mysql> create index index_sid_bid on borrow(stu_id asc, book_id asc); Query OK, 0 rows affected

Records: 0 Duplicates: 0 Warnings: 0

return_table:

1.为stu_id和book_id创建多列索引:

sql:create index index_sid_bid on return_table(stu_id asc, book_id asc);

插入索引的操作和结果如下所示:

mysql> create index index_sid_bid_r on return_table(stu_id asc, book_id asc); Query OK, 0 rows affected

Records: 0 Duplicates: 0 Warnings: 0

ticket:

1. 为stu_id和book_id创建多列索引:

sql:create index index_sid_bid on ticket(stu_id asc, book_id asc);

插入索引的操作和结果如下所示:

mysql> create index index_sid_bid on ticket(stu_id asc, book_id asc); Query OK, 0 rows affected

Records: 0 Duplicates: 0 Warnings: 0

manager:

1.为manager_id创建索引:

sql:create index index_mid on manager(manager_id);

插入索引的操作和结果如下所示:

mysql> create index index_mid on manager(manager_id);

Query OK, 0 rows affected

Records: 0 Duplicates: 0 Warnings: 0

4、设计视图

给出在各表上建立的视图以及使用的语句。

1.在表student上创建计算机专业(cs)学生的视图stu_cs:

sql: create view stu_cs as

select *

from student

where pro = ‘cs’;

操作和结果:

mysql> create view stu_cs as

select *

from student

where stu_pro = 'cs';

Query OK, 0 rows affected

2. 在表student, borrow和book上创建借书者的全面信息视图stu_borrow:

sql: create view stu_borrow as

select student.stu_id, book.book_id, student.stu_name, book.book_name, borrow_date,adddate(borrow_date,30) expect_return_date

from student, book, borrow

where student.stu_id = borrow.stu_id and book.book_id = borrow.book_id;

操作和结果:

mysql> create view stu_borrow as

select student.stu_id, book.book_id, student.stu_name, book.book_name, borrow_date,adddate(borrow_date,30) expect_return_date

from student, book, borrow

where student.stu_id = borrow.stu_id and book.book_id = borrow.book_id;