收藏 分销(赏)

《数据库原理》课程设计-图书管理系统.doc

上传人:仙人****88 文档编号:7044786 上传时间:2024-12-25 格式:DOC 页数:55 大小:1.29MB
下载 相关 举报
《数据库原理》课程设计-图书管理系统.doc_第1页
第1页 / 共55页
《数据库原理》课程设计-图书管理系统.doc_第2页
第2页 / 共55页
《数据库原理》课程设计-图书管理系统.doc_第3页
第3页 / 共55页
《数据库原理》课程设计-图书管理系统.doc_第4页
第4页 / 共55页
《数据库原理》课程设计-图书管理系统.doc_第5页
第5页 / 共55页
点击查看更多>>
资源描述

1、一、需求分析 1.问题描述: 随着网络化时代的到来,图书出租信息的网络化可以大大节约人工和时间。为此可以开发出图书管理系统,广泛的应用于学校和工业、商业、企业、事业和行政等单位。实际上,该系统的实用性还是比较强的。2.系统功能描述(1)系统功能描述一个图书出租管理系统应该提供包括客户信息管理、图书信息管理、出版社信息管理、用户信息管理、租还书、综合查询等功能。1) 客户、图书、用户信息的数据模块提供增加、删除、改变和查询、浏览等基本的数据维护功能。2) 综合查询模块可以通过用户选择的数据表和相应的查询条件来查询相关内容。3) 客户租还书模块是图书出租管理系统的核心功能,实现客户和图书出租的交互

2、。(2)功能模块划分图书出租管理系统的数据库功能主要体现在对各种信息的提供、保存、更新和查询操作上,包括图书信息、用户信息、客户信息和租借信息,各个部分的数据内容又有内在联系。针对该系统的数据特点,可以总结出如下的需求。A、用户和客户具有不同的身份。B、用户信息记录用户资料。C、客户信息记录客户的详细信息。D、图书信息记录图书的名称、出版社等信息。E、租借信息记录客户租借图书的信息。图书出租管理系统应该具有客户信息管理、图书信息管理、租还书和综合查询等功能。根据系统功能的需求分析,我们把该系统的功能划分为5个模块。A、客户信息维护模块B、图书信息维护模块C、用户信息管理模块D、客户租还书管理模

3、块E、综合查询模块图书出租管理系统的功能模块如图所示系统管理员租书还书客户用户信息管理用户图书出租管理系统客户租还书信息管理综合查询图书信息维护客户信息维护其中,客户租还书管理模块包括以下3个子模块:A、租借图书B、归还图书C、查询租借信息客户信息维护模块包括以下5个子模块:A、增加客户信息B、删除客户信息C、修改客户信息D、查询客户信息E、遍历客户信息该模块图如下图所示:客户信息维护模块查询客户信息遍历客户信息删除客户信息修改客户信息增加客户信息同理,如图书信息管理、用户信息管理模块也被类似的分为增加、删除、修改、查询和遍历5个模块。(3)系统流程分析图书出租管理系统的开发首先要设计一个登录

4、系统,用户只有输入了正确的用户名和密码方可进入系统内部。系统流程图如下图所示图书出租管理系统登录判断用户类型系统管理员客户信息维护租书还书客户用户信息管理用户图书信息维护客户租还书信息管理综合查询(4)数据流程图系统管理员用户客户查询用户表图书表客户表租借信息表增加修改删除查询查询(5)系统功能分析和需求总结后,设计如下的数据项和数据结A、图书信息,包括图书编号、图书名称、作者等数据项B、租书信息,包括客户编号、图书编号、租借日期等数据项。C、客户信息,包括客户编号、姓名、密码等数据项。D、用户信息,包括用户编号、密码、分类等数据项。3.系统使用权限方面该信息管理系统的角色可以分为3类:(1)

5、普通用户:拥有客户信息维护、图书信息管理以及客户租还书管理、报表显示和综合查询的权限。(2)系统管理员:拥有客户信息维护、图书信息管理、用户信息管理以及客户租还书管理和综合查询权限。但其主要功能还是用户信息管理。(3)客户:租书和还书。二、数据库概念结构设计得到上面的数据项和数据结构后,就可以设计满足需求的各种实体及相互关系,再用实体-关系图,及E-R(Entiry-Relationship)图将这些内容表达出来,为后面的逻辑结构设计打下基础。在这个系统中,所存在的实体有:图书信息实体、租书信息实体、出版社信息实体、客户信息实体和用户信息实体,它们之间的关系如图所示。BookIDBookRem

6、ainBookNameBookAmountBookBookSortBookWriterBookPriceBookPublishBookPublishDate图书信息实体E-R图BorrowBookFactReturnDateReaderIDReturnDateBookIDBorrowDate租借书信息关系的属性E-RReaderReaderEmailReaderIDReaderPhoneNoReaderNameReaderBorrowBooksReaderPassword客户信息实体E-R图用户信息实体E-R图UserSortUserPasswordUserUserIDn管理查询与管理租借书书

7、查询与管理用户客户1n实体及其联系的E-R图m1n1n三、逻辑结构设计1.模式设计: (1)关系模式:Book(BookID、BookName、BookWriter、BookPublish、BookPublishDate、BookPrice、BookSort、BookAmount、BookRemain)BorrowBook(ReaderID、BookID、BorrowDate、ReturnDate、FactReturnDate)Reader(ReaderID、ReaderName、ReaderPassword、ReaderPhoneNo、ReaderEmail、ReaderBorrowBook

8、s)User(UserID、UserPassword、UserSort)(2)数字字典:图书表(Book)编号字段名称数据结构说明1BookIDnvarchar(50)图书编号2BookNamenvarchar(50)图书名称3BookWriternvarchar(20)图书作者4BookPublishnvarchar(50)出版社5BookPublishDatedatetime出版日期6BookPricefloat图书定价7BookSortnvarchar(50)图书分类8BookAmountint图书库存数量9BookRemainint现在库存数量租借信息表(BorrowBook)编号字段

9、名称数据结构说明1ReaderIDchar(6)客户编号2BookIDnvarchar(50)图书编号3BorrowDatedatetime租借日期4ReturnDatedatetime应归还日期5FactReturnDatedatetime实际归还日期客户表(Reader)编号字段名称数据结构说明1ReaderIDchar(6)客户编号2ReaderNamevarchar(20)客户姓名3ReaderPasswordvarchar(10)客户密码4ReaderPhoneNovarchar(15)电话号码5ReaderEmailvarchar(50)电子邮箱6ReaderBorrowedBoo

10、ksint借书数量用户表(User)编号字段名称数据结构说明1UserIDchar(10)用户编号2UserPasswordchar(10)用户密码3UserSortvarchar(10)用户分类在建立完所有数据表后,要根据数据表之间的关系在属性页中添加关系。为Book表和BorrowBook表之间添加FK_BorrowBook_Book关系,为Book表和PublishCompany之间添加FK_Book_PublishCompany关系,为Reader表和BorrowBook表之间添加FK_BorrowBook_Reader关系。同时在两关系中实现表间的级联更新和级联删除。(2)子模式设计

11、:1)视图在图书出租管理系统中,为便于浏览目前客户租借图书的信息,创建了一个Borrow视图来显示租借记录中客户和所租借图书的一些详细信息以便以后综合浏览。该视图涉及到Book表、BorrowBook表和Reader表,三表间的联系及其各自想要显示的字段,如下图所示。a)三表间的联系b)数据字典2)存储过程在图书出租管理系统中,创建实现在客户租还书时对客户表中的客户所借书目和图书表中图书库存量的改变的存储过程和客户借书之前查询客户租借图书数目和图书库存量的存储过程。 图书出租管理系统中,需要创建6个存储过程,分别为:a) ReaderBorrowedNumber 存储过程 该存储过程负责获取客

12、户已经租借的图书数目。其目的是为了在客户租借图书之前判断此客户是否达到借书数目的上限。b) BookNumber 存储过程 此存储过程的功能是根据输入的图书编号得到该图书现在的库存数量。c) BorrowReader 存储过程 当客户租借某种图书后,该存储过程向客户表的客户的目前所借图书一项添加1。d) BorrowBook 存储过程 当客户租借某种图书后,该存储过程向图书表的相应的图书库现存量中减去1。e) ReturnReader存储过程 当客户归还所借的图书时,该存储过程在客户表中把客户所借的图书数量减1。f) ReturnBook存储过程 当客户归还所借的图书时,该存储过程在图书表中相

13、应的图书现存量中增加1。四、数据库的物理设计为了提高在表中搜索元组的速度,于是在各表中分别建立关于主键升序的索引,如下:1.User表的PK_User索引(以UserID的升序建立的)2.Reader表的PK_Reader索引(以ReaderID的升序建立的)3.BorrowBook表的PK_BorrowBook索引(以ReaderID、BookID的升序建立的)4.Book表的PK_Book索引(以BookID的升序建立的)五、数据库设计实现及运行开发工具:SQL Sever 20001.数据库的创建create database BOOKMANAGEMENT;2.数据表的创建(可同时在创建

14、时定义相关的约束)T-SQL语句:User表:create table User( UserID char(10) primary key, UesrPassword char(10), UserSort varchar(10);Reader表:create table Reader( Reader UserID char(6) primary key,ReaderName varchar(20),ReaderPassword varchar(10),ReaderPhoneNo varchar(15),ReaderEmail varchar(50),ReaderBorrowedbooks in

15、t);BorrowBook表:create table ManagerUser( ReaderID char(6), BookID nvarchar(50), BorrowDate datatime, ReturnDate datatime, FactReturnDate datatime, primary key(ReaderID,BookID), foreign key(ReaderID) references from Reader(ReaderID), foreign key(BookID ID) references from BookID (BookID ID);Book表:cre

16、ate table Book(BookID nvarchar(50) primary key,BookName nvarchar(50),BookWriter nvarchar(20),BookPublish nvarchar(50),BookPublishDate datetime,BookPrice float,BookSort nvarchar(50),BookAmount int,BookRemain int);3.视图的创建Borrow视图:CREATE VIEW dbo.BorrowASSELECT dbo.BorrowBook.ReaderID, dbo.Reader.Reade

17、rName, dbo.Reader.ReaderPhoneNo, dbo.BorrowBook.BookID, dbo.Book.BookName, dbo.Book.BookWriter, dbo.BorrowBook.BorrowDate, dbo.BorrowBook.ReturnDateFROM dbo.Book INNER JOIN dbo.BorrowBook ON dbo.Book.BookID = dbo.BorrowBook.BookID INNER JOIN dbo.Reader ON dbo.BorrowBook.ReaderID = dbo.Reader.ReaderI

18、D4.存储过程实现1)ReaderBorrowedNumber 存储过程CREATE PROCEDURE dbo.StoredProcedureReaderBorrowNumber(ReaderID char(10),BorrowedNumber int OUTPUT)ASselect BorrowedNumber=count(*) from BorrowBook where ReaderID=ReaderIDRETURNGO2)BookNumber 存储过程CREATE PROCEDURE dbo.StoredProcedureBookNumber (BookID char(10),Book

19、Number int OUTPUT)ASselect BookNumber=BookRemain from Book where BookID=BookIDRETURN GO3)BorrowReader 存储过程CREATE PROCEDURE dbo.StoredProcedureBorrowReader(ReaderID char(6)ASupdate Readerset ReaderBorrowedBooks=ReaderBorrowedbooks+1where ReaderID=ReaderID;RETURN GO4)BorrowBook 存储过程CREATE PROCEDURE db

20、o.StoredProcedureBorrowBook(BookID char(10)ASupdate Book set BookRemain=BookRemain-1where BookID=BookID;RETURN GO5)ReturnReader存储过程CREATE PROCEDURE dbo.StoredProcedureReturnReader(ReaderID char(6) )ASupdate Readerset ReaderBorrowedBooks=ReaderBorrowedbooks-1where ReaderID=ReaderID;RETURN GO6)ReturnB

21、ook存储过程CREATE PROCEDURE dbo.StoredProcedureReturnBook(BookID char(10) )ASupdate Book set BookRemain=BookRemain+1where BookID=BookID;RETURN GO六、界面与数据库的连接代码区中加入如下代码:this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();this.sqlConnection1.ConnectionString = server=.;database=BookManagement;I

22、ntegrated Security=true;this.sqlConnection1.FireInfoMessageEventOnUserErrors = false;七、界面的实现(模块中的功能实现)【开发工具:Visual Studio 2008】(代码及可执行文件见附录)运行程序后,进入登陆界面,输入用户名及密码,截图如下:代码:/ Login 的摘要说明。public class LoginForm : System.Windows.Forms.Formprivate System.Windows.Forms.Button btnCancel;private System.Windo

23、ws.Forms.TextBox textUserID;private System.Windows.Forms.TextBox textUserPassword;private System.Windows.Forms.Button btnOk;private System.Data.SqlClient.SqlConnection sqlConnection1;private System.Windows.Forms.Label lblUser; private System.Windows.Forms.Label lblPassword;/ 必需的设计器变量。private System.

24、ComponentModel.Container components = null;public LoginForm()/ Windows 窗体设计器支持所必需的InitializeComponent();/ TODO: 在InitializeComponent 调用后添加任何构造函数代码/ 清理所有正在使用的资源。protected override void Dispose( bool disposing )if( disposing )if(components != null)components.Dispose();base.Dispose( disposing );#region

25、 Windows 窗体设计器生成的代码/ / 设计器支持所需的方法- 不要使用代码编辑器修改/ 此方法的内容。/ private void InitializeComponent() System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LoginForm); this.lblUser = new System.Windows.Forms.Label(); this.lblPassword = new System.

26、Windows.Forms.Label(); this.btnCancel = new System.Windows.Forms.Button(); this.textUserID = new System.Windows.Forms.TextBox(); this.textUserPassword = new System.Windows.Forms.TextBox(); this.btnOk = new System.Windows.Forms.Button(); this.sqlConnection1 = new System.Data.SqlClient.SqlConnection()

27、; this.SuspendLayout(); / / lblUser / this.lblUser.BackColor = System.Drawing.Color.Transparent; this.lblUser.Font = new System.Drawing.Font(宋体, 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, (byte)(134); this.lblUser.Location = new System.Drawing.Point(40, 56); this.lblUs

28、er.Name = lblUser; this.lblUser.Size = new System.Drawing.Size(72, 23); this.lblUser.TabIndex = 1; this.lblUser.Text = 用户名:; / / lblPassword / this.lblPassword.BackColor = System.Drawing.Color.Transparent; this.lblPassword.Font = new System.Drawing.Font(宋体, 12F, System.Drawing.FontStyle.Regular, Sys

29、tem.Drawing.GraphicsUnit.Point, (byte)(134); this.lblPassword.Location = new System.Drawing.Point(40, 104); this.lblPassword.Name = lblPassword; this.lblPassword.Size = new System.Drawing.Size(72, 23); this.lblPassword.TabIndex = 2; this.lblPassword.Text = 密 码:; / / btnCancel / this.btnCancel.BackCo

30、lor = System.Drawing.Color.Transparent; this.btnCancel.Location = new System.Drawing.Point(144, 152); this.btnCancel.Name = btnCancel; this.btnCancel.Size = new System.Drawing.Size(64, 24); this.btnCancel.TabIndex = 3; this.btnCancel.Text = 重置; this.btnCancel.UseVisualStyleBackColor = false; this.bt

31、nCancel.Click += new System.EventHandler(this.btnCancel_Click); / / textUserID / this.textUserID.Location = new System.Drawing.Point(112, 56); this.textUserID.Name = textUserID; this.textUserID.Size = new System.Drawing.Size(96, 21); this.textUserID.TabIndex = 0; / / textUserPassword / this.textUser

32、Password.Location = new System.Drawing.Point(112, 104); this.textUserPassword.Name = textUserPassword; this.textUserPassword.PasswordChar = *; this.textUserPassword.Size = new System.Drawing.Size(96, 21); this.textUserPassword.TabIndex = 1; / / btnOk / this.btnOk.BackColor = System.Drawing.Color.Tra

33、nsparent; this.btnOk.Location = new System.Drawing.Point(40, 152); this.btnOk.Name = btnOk; this.btnOk.Size = new System.Drawing.Size(64, 24); this.btnOk.TabIndex = 6; this.btnOk.Text = 登录; this.btnOk.UseVisualStyleBackColor = false; this.btnOk.Click += new System.EventHandler(this.btnOk_Click); / /

34、 sqlConnection1 / this.sqlConnection1.ConnectionString = server=.;database=BookManagement;Integrated Security=true; this.sqlConnection1.FireInfoMessageEventOnUserErrors = false; / / LoginForm / this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.BackColor = System.Drawing.Color.Blue; this.

35、BackgroundImage = (System.Drawing.Image)(resources.GetObject($this.BackgroundImage); this.ClientSize = new System.Drawing.Size(250, 194); this.Controls.Add(this.btnOk); this.Controls.Add(this.textUserPassword); this.Controls.Add(this.textUserID); this.Controls.Add(this.btnCancel); this.Controls.Add(

36、this.lblPassword); this.Controls.Add(this.lblUser); this.Icon = (System.Drawing.Icon)(resources.GetObject($this.Icon); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = LoginForm; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = 图书出租管理系统; this.Load

37、+= new System.EventHandler(this.Login_Load); this.ResumeLayout(false); this.PerformLayout();#endregionstatic void Main() Application.Run(new LoginForm(); /撤销之前的输入private void btnCancel_Click(object sender, System.EventArgs e)this.textUserID.Text=;this.textUserPassword.Text=; /确认输入,并与数据库建立连接,判断是否为合法用

38、户,以及判断该用户的权限private void btnOk_Click(object sender, System.EventArgs e)if(UserCheck(this.textUserID.Text,this.textUserPassword.Text)=system)this.Visible=false;Form mainform=new MainForm(this.textUserID.Text,system);mainform.ShowDialog();this.Close();else if(UserCheck(this.textUserID.Text,this.textUs

39、erPassword.Text)=user)this.Visible=false;Form mainform=new MainForm(this.textUserID.Text,user);mainform.ShowDialog();this.Close();elseif(MessageBox.Show(输入用户密码有误,是否重新登陆,输入有误,MessageBoxButtons.OKCancel,MessageBoxIcon.Question)=DialogResult.OK)this.textUserID.Clear();this.textUserPassword.Clear();/this.textUserID.();elsethis.Close(); /判断是否为合法用户string UserCheck(string username,string userpassword)string txtSql,usersort;usersort=nobody;txtSql = SELECT * FROM User;SqlCommand check

展开阅读全文
部分上传会员的收益排行 01、路***(¥15400+),02、曲****(¥15300+),
03、wei****016(¥13200+),04、大***流(¥12600+),
05、Fis****915(¥4200+),06、h****i(¥4100+),
07、Q**(¥3400+),08、自******点(¥2400+),
09、h*****x(¥1400+),10、c****e(¥1100+),
11、be*****ha(¥800+),12、13********8(¥800+)。
相似文档                                   自信AI助手自信AI助手
搜索标签

当前位置:首页 > 学术论文 > 其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服