vb.net图书管理系统

Part8 VB.net编程程序设计
——图书借阅管理系统

一、问题引入
学校原本使用人工管理模式进行借阅。现需要将原有借阅模式改革,引入计算机借阅模式。可以管理借书、还书等流程。

二、需求分析
由于时间原因,系统已实现主要功能为目的。采用最简化开发模式。
功能描述:
1、当学校新进了教师或学生时,可以添加读者。
2、当管理员不清楚读者借阅权限和已借数量时,可以进行查询。
3、图书馆买了新书时,可以进行添加。
4、淘汰旧书时,可以删除。
5、管理员可以对读者类别进行管理。
6、可以进行借书和还书操作。
7、根据实际情况添加相关需求。

需求分析:
根据功能要求,主要需要实现对三种功能,读者管理、图书管理、借阅管理。并据此建立相关关系。

功能分析:
如图

概念模型设计:

如图
关系模型
根据E-R模型进行关系模型设计:
1、将中文实体转化为英文标识的命名符号:
读者:Reader;读者编号:RID;姓名:Rname;读者类型:Type;已借数量:Lendnum
图书:Book;图书编号:BID;书名:Bname;作者:Author;出版社:PudComp;
出版日期:PubDate;定价:Price
借阅:Borrow;借期:LendDate;还期:ReturnDate;限期:SReturnDate;超期天数:ExtDays
2、将概念模型转换为关系模型:
读者与图书的联系是多对多的,借阅联系转换为一个Borrow关系模型,读者实体的主码RID和图书实体的主码BID和联系本身的属性构成关系Borrow的属性。
得到如下的关系模型
实体(读者):Reader(RID,Rname,Type,Lendunm)
PK:RID
联系(借阅):Borrow(RID,BID,LendDate,ReturnDate,SReturnDate,ExtDays)
PK:RID,BID,LendDate
FK:RID,BID
实体(图书):Book(BID,Bname,Author,PubComp,PubDate,Price)
PK:BID
在借阅系统中,不同类型的读者可以借阅的图书有区别,因此,在读者实体的Type属性中,还应该包括读者类型TypeID、读者类型名称TypeName、限借数量LimitNum、限借天数LimitDays属性。
读者实体进行转化后为:
Reader(RID,Rname,Lendnum,TypeID,Typename,LimitNum,LimitDays)
转化后的关系中存在函数依赖传递,不满足3NF原则。需要对Reader进行拆分。
拆分后的关系如下:
ReaderType(TypeID,TypeName,LimitNum,LimitDays)
PK:TypeID
Reader(RID,Rname,TypeID,Lendunm)
PK:RID
FK:TypeID
Borrow(RID,BID,LendDate,ReturnDate,SReturnDate,ExtDays)
PK:RID,BID,LendDate
FK:RID,BID
Book(BID,Bname,Author,PubComp,PubDate,Price)
PK:BID
据此建立数据库:Libdb
数据库

二、具体操作
1、数据库建立
(1)利用SQL软件,建立新的数据库Libdb。
(2)利用设计器建立表格Book、Reader、Borrow、ReaderType
(3)在需要建立外键FK的表格中添加关系。
具体操作:在设计界面,右键点击需要建立外键的属性名,在弹出菜单上点击关系,打开“外键关系”窗口,如图所示:
在这里插入图片描述
点击添加按钮,将会添加一个新的关系,在相应的右侧内窗体内,点击表和列规范。打开表和列窗体,如图所示:
在这里插入图片描述
将逐渐表改为要建立外部联系的表格名称及数据项,外键表为当前表格名称及数据项。如下图所示:关系名会改变为FK_本表格名称_建立联系表格名称
在这里插入图片描述
2、界面设计:
(1)建立MDI主界面
(2)建立数据源
(3)利用数据源建立各个窗体界面

3、代码设计:
完整代码:
Imports System.Windows.Forms

Public Class MDIParent1
Private Sub CascadeToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
Me.LayoutMdi(MdiLayout.Cascade)
End Sub

Private Sub TileVerticalToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
    Me.LayoutMdi(MdiLayout.TileVertical)
End Sub

Private Sub TileHorizontalToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
    Me.LayoutMdi(MdiLayout.TileHorizontal)
End Sub

Private Sub ArrangeIconsToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
    Me.LayoutMdi(MdiLayout.ArrangeIcons)
End Sub

Private m_ChildFormNumber As Integer

Private Sub 退出ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 退出ToolStripMenuItem.Click
    Global.System.Windows.Forms.Application.Exit()
End Sub

Private Sub 添加读者信息ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 添加读者信息ToolStripMenuItem.Click
    Dim form As New Form1
    form.MdiParent = Me
    form.Show()
End Sub

Private Sub 查询读者信息ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 查询读者信息ToolStripMenuItem.Click
    Dim form As New Form2
    form.MdiParent = Me
    form.Show()
End Sub

Private Sub 新书上架ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 新书上架ToolStripMenuItem.Click
    Dim form As New Form3
    form.MdiParent = Me
    form.Show()
End Sub

Private Sub 添加读者类型ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 添加读者类型ToolStripMenuItem.Click
    Dim form As New Form4
    form.MdiParent = Me
    form.Show()
End Sub


Private Sub 查询读者类型ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 查询读者类型ToolStripMenuItem.Click
    Dim form As New Form5
    form.MdiParent = Me
    form.Show()
End Sub

Private Sub 旧书淘汰ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 旧书淘汰ToolStripMenuItem.Click
    Dim form As New Form6
    form.MdiParent = Me
    form.Show()
End Sub

Private Sub 图书信息修改ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 图书信息修改ToolStripMenuItem.Click
    Dim form As New Form7
    form.MdiParent = Me
    form.Show()
End Sub

Private Sub 图书信息查询ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 图书信息查询ToolStripMenuItem.Click
    Dim form As New Form8
    form.MdiParent = Me
    form.Show()
End Sub

Private Sub 借书ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 借书ToolStripMenuItem.Click
    Dim form As New Form9
    form.MdiParent = Me
    form.Show()
End Sub

Private Sub 还书ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 还书ToolStripMenuItem.Click
    Dim form As New Form10
    form.MdiParent = Me
    form.Show()
End Sub

End Class

添加读者信息代码
Imports System.Data.SqlClient
Public Class Form1

Private Sub ReaderBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs)
    Me.Validate()
    Me.ReaderBindingSource.EndEdit()
    Me.TableAdapterManager.UpdateAll(Me.LibdbDataSet)

End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    'TODO: 这行代码将数据加载到表“LibdbDataSet.Reader”中。您可以根据需要移动或删除它。
    Me.ReaderTableAdapter.Fill(Me.LibdbDataSet.Reader)

End Sub
Dim conn As SqlConnection
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Try
        conn = New SqlConnection
        conn.ConnectionString = "Server=(local);database=libdb;UID=sa;PWD=Sa123"
        conn.Open()
        Dim str1 As String
        str1 = "insert into Reader(RID,Rname,TypeID,LendNum,Email) values('" & RIDTextBox.Text & "','" & RnameTextBox.Text & "','" & TypeIDTextBox.Text & "','" & LendNumTextBox.Text & "','" & EmailTextBox.Text & "')"
        Dim comm As New SqlCommand(str1, conn)
        comm.ExecuteNonQuery()
        conn.Close()
        MsgBox("添加读者信息成功!")
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
End Sub

End Class

查询读者信息代码
Public Class Form2

Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    'TODO: 这行代码将数据加载到表“LibdbDataSet.Reader”中。您可以根据需要移动或删除它。
    Me.ReaderTableAdapter.Fill(Me.LibdbDataSet.Reader)

End Sub

Private Sub FillByToolStripButton_Click(sender As Object, e As EventArgs) Handles FillByToolStripButton.Click
    Try
        Me.ReaderTableAdapter.FillBy(Me.LibdbDataSet.Reader, RidToolStripTextBox.Text)
    Catch ex As System.Exception
        System.Windows.Forms.MessageBox.Show(ex.Message)
    End Try

End Sub

Private Sub FillBy1ToolStripButton_Click(sender As Object, e As EventArgs) Handles FillBy1ToolStripButton.Click
    Try
        Me.ReaderTableAdapter.FillBy1(Me.LibdbDataSet.Reader, RnameToolStripTextBox.Text)
    Catch ex As System.Exception
        System.Windows.Forms.MessageBox.Show(ex.Message)
    End Try

End Sub

Private Sub FillBy2ToolStripButton_Click(sender As Object, e As EventArgs) Handles FillBy2ToolStripButton.Click
    Try
        Me.ReaderTableAdapter.FillBy2(Me.LibdbDataSet.Reader, New System.Nullable(Of Integer)(CType(TidToolStripTextBox.Text, Integer)))
    Catch ex As System.Exception
        System.Windows.Forms.MessageBox.Show(ex.Message)
    End Try

End Sub

End Class
添加读者类型代码
Imports System.Data.SqlClient
Public Class Form4

Private Sub ReaderTypeBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs)
    Me.Validate()
    Me.ReaderTypeBindingSource.EndEdit()
    Me.TableAdapterManager.UpdateAll(Me.LibdbDataSet)

End Sub

Private Sub Form4_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    'TODO: 这行代码将数据加载到表“LibdbDataSet.ReaderType”中。您可以根据需要移动或删除它。
    Me.ReaderTypeTableAdapter.Fill(Me.LibdbDataSet.ReaderType)

End Sub
Dim conn As SqlConnection
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    conn = New SqlConnection()
    conn.ConnectionString = "Server=(local);database=libdb;UID=sa;PWD=Sa123"
    conn.Open()
    Dim sqlstr As String
    sqlstr = "insert into ReaderType(TypeID,Typename,LimitNum,LimtDays) values('" & TypeIDTextBox.Text & "','" & TypenameTextBox.Text & "','" & LimitNumTextBox.Text & "','" & LimtDaysTextBox.Text & "')"
    Dim comm As New SqlCommand(sqlstr, conn)
    comm.ExecuteNonQuery()
    conn.Close()
    MsgBox("添加读者类型成功!")
End Sub

End Class

查询读者类型代码
Public Class Form5

Private Sub Form5_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    'TODO: 这行代码将数据加载到表“LibdbDataSet.ReaderType”中。您可以根据需要移动或删除它。
    Me.ReaderTypeTableAdapter.Fill(Me.LibdbDataSet.ReaderType)

End Sub

Private Sub FillByidToolStripButton_Click(sender As Object, e As EventArgs) Handles FillByidToolStripButton.Click
    Try
        Me.ReaderTypeTableAdapter.FillByid(Me.LibdbDataSet.ReaderType, CType(IdToolStripTextBox.Text, Integer))
    Catch ex As System.Exception
        System.Windows.Forms.MessageBox.Show(ex.Message)
    End Try

End Sub

Private Sub FillBytnameToolStripButton_Click(sender As Object, e As EventArgs) Handles FillBytnameToolStripButton.Click
    Try
        Me.ReaderTypeTableAdapter.FillBytname(Me.LibdbDataSet.ReaderType, TnameToolStripTextBox.Text)
    Catch ex As System.Exception
        System.Windows.Forms.MessageBox.Show(ex.Message)
    End Try

End Sub

End Class

新书上架
Imports System.Data.SqlClient
Public Class Form3

Private Sub BookBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs)
    Me.Validate()
    Me.BookBindingSource.EndEdit()
    Me.TableAdapterManager.UpdateAll(Me.LibdbDataSet)

End Sub

Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    'TODO: 这行代码将数据加载到表“LibdbDataSet.Book”中。您可以根据需要移动或删除它。
    Me.BookTableAdapter.Fill(Me.LibdbDataSet.Book)

End Sub
Dim conn As SqlConnection
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Try
        conn = New SqlConnection
        conn.ConnectionString = "Server=(local);database=libdb;UID=sa;PWD=Sa123"
        conn.Open()
        Dim str1 As String
        str1 = "insert into Book(BID,Bname,Author,Pubcomp,PubDate,Price,ISBN) values('" & BIDTextBox.Text & "','" & BnameTextBox.Text & "','" & AuthorTextBox.Text & "','" & PubCompTextBox.Text & "','" & PubDateDateTimePicker.Value & "','" & PriceTextBox.Text & "','" & ISBNTextBox.Text & "')"
        Dim comm As New SqlCommand(str1, conn)
        comm.ExecuteNonQuery()
        conn.Close()
        MsgBox("新书上架成功!")
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
End Sub

End Class

旧书淘汰
Imports System.Data.SqlClient
Public Class Form6
Private Sub Form6_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: 这行代码将数据加载到表“LibdbDataSet.Book”中。您可以根据需要移动或删除它。
Me.BookTableAdapter.Fill(Me.LibdbDataSet.Book)

End Sub
Private Sub FillBybid1ToolStripButton_Click(sender As Object, e As EventArgs) Handles FillBybid1ToolStripButton.Click
    Try
        Me.BookTableAdapter.FillBybid1(Me.LibdbDataSet.Book, BidToolStripTextBox.Text)
    Catch ex As System.Exception
        System.Windows.Forms.MessageBox.Show(ex.Message)
    End Try

End Sub
Dim conn As SqlConnection
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    If (MessageBox.Show("确认删除记录吗?", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) = Windows.Forms.DialogResult.Yes) Then
        Try
            BindingSource1.RemoveCurrent()
            conn = New SqlConnection
            conn.ConnectionString = "Server=(local);database=libdb;UID=sa;PWD=Sa123"
            conn.Open()
            Dim sqlstr As String
            sqlstr = "delete from Book where BID='" & BidToolStripTextBox.Text & "'"
            Dim comm As New SqlCommand(sqlstr, conn)
            comm.ExecuteNonQuery()
            conn.Close()
            MsgBox("删除记录成功!")
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End If
End Sub

End Class
图书信息修改
Imports System.Data.SqlClient
Public Class Form7

Private Sub Form7_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    'TODO: 这行代码将数据加载到表“LibdbDataSet.Book”中。您可以根据需要移动或删除它。
    Me.BookTableAdapter.Fill(Me.LibdbDataSet.Book)
    'TODO: 这行代码将数据加载到表“LibdbDataSet.Book”中。您可以根据需要移动或删除它。
    Me.BookTableAdapter.Fill(Me.LibdbDataSet.Book)

End Sub

Private Sub BookBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs)
    Me.Validate()
    Me.BookBindingSource.EndEdit()
    Me.TableAdapterManager.UpdateAll(Me.LibdbDataSet)

End Sub
Dim conn As SqlConnection
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Try
        Me.Validate()
        Me.BookBindingSource.EndEdit()
        Me.BookTableAdapter.Update(Me.LibdbDataSet.Book)
        conn = New SqlConnection()
        conn.ConnectionString = "server=(local);database=libdb;UID=sa;PWD=Sa123"
        conn.Open()
        Dim sqlstr As String
        sqlstr = "update Book set Bname='BnameTextBox.text',Author='AuthorTextBox.text',PubComp='PubCompText.text',PubDate='PubDateDateTimePicker.value',Price='PriceTextBox.text',ISBN='ISBNTextBox.text' where BID='BIDTextBox.text'"
        Dim comm As New SqlCommand(sqlstr, conn)
        comm.ExecuteNonQuery()
        conn.Close()
        MsgBox("修改图书信息成功!")
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
End Sub

End Class

图书信息查询
Public Class Form8

Private Sub Form8_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    'TODO: 这行代码将数据加载到表“LibdbDataSet.Book”中。您可以根据需要移动或删除它。
    Me.BookTableAdapter.Fill(Me.LibdbDataSet.Book)

End Sub

Private Sub FillBybidToolStripButton_Click(sender As Object, e As EventArgs) Handles FillBybidToolStripButton.Click
    Try
        Me.BookTableAdapter.FillBybid(Me.LibdbDataSet.Book, BidToolStripTextBox.Text)
    Catch ex As System.Exception
        System.Windows.Forms.MessageBox.Show(ex.Message)
    End Try

End Sub

Private Sub FillBybnameToolStripButton_Click(sender As Object, e As EventArgs)
    Try
        Me.BookTableAdapter.FillBybname(Me.LibdbDataSet.Book)
    Catch ex As System.Exception
        System.Windows.Forms.MessageBox.Show(ex.Message)
    End Try

End Sub

Private Sub FillBybname1ToolStripButton_Click(sender As Object, e As EventArgs) Handles FillBybname1ToolStripButton.Click
    Try
        Me.BookTableAdapter.FillBybname1(Me.LibdbDataSet.Book, BnameToolStripTextBox.Text)
    Catch ex As System.Exception
        System.Windows.Forms.MessageBox.Show(ex.Message)
    End Try

End Sub

Private Sub FillByauthorToolStripButton_Click(sender As Object, e As EventArgs) Handles FillByauthorToolStripButton.Click
    Try
        Me.BookTableAdapter.FillByauthor(Me.LibdbDataSet.Book, AuthorToolStripTextBox.Text)
    Catch ex As System.Exception
        System.Windows.Forms.MessageBox.Show(ex.Message)
    End Try

End Sub

End Class
借书
Imports System.Data.SqlClient
Public Class Form9

Private Sub BorrowBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs)
    Me.Validate()
    Me.BorrowBindingSource.EndEdit()
    Me.TableAdapterManager.UpdateAll(Me.LibdbDataSet)

End Sub
Dim conn As SqlConnection
Private Sub Form9_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    'TODO: 这行代码将数据加载到表“LibdbDataSet.Borrow”中。您可以根据需要移动或删除它。
    Me.BorrowTableAdapter.Fill(Me.LibdbDataSet.Borrow)

End Sub


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Try
        conn = New SqlConnection
        conn.ConnectionString = "Server=(local);database=libdb;UID=sa;PWD=Sa123"
        conn.Open()
        Dim str1 As String
        str1 = "insert into Borrow(RID,BID,LendDate) values('" & RIDTextBox.Text & "','" & BIDTextBox.Text & "','" & LendDateDateTimePicker.Value & "')"
        Dim comm As New SqlCommand(str1, conn)
        comm.ExecuteNonQuery()
        conn.Close()
        MsgBox("借书成功!")
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
End Sub

End Class

还书
Imports System.Data.SqlClient
Public Class Form10
Private Sub BorrowBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs)
Me.Validate()
Me.BorrowBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.LibdbDataSet)

End Sub

Private Sub Form10_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    'TODO: 这行代码将数据加载到表“LibdbDataSet.Borrow”中。您可以根据需要移动或删除它。
    Me.BorrowTableAdapter.Fill(Me.LibdbDataSet.Borrow)

End Sub
Dim conn As SqlConnection

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Try
        Me.Validate()
        Me.BorrowBindingSource.EndEdit()
        Me.BorrowTableAdapter.Update(Me.LibdbDataSet.Borrow)
        conn = New SqlConnection()
        conn.ConnectionString = "server=(local);database=libdb;UID=sa;PWD=Sa123"
        conn.Open()
        Dim sqlstr As String
        sqlstr = "update Borrow set Returndate='ReturnDateDateTimePicker.value',ExtDays='ExtDaysTextbox.text',LendDate='LendDateDateTimePicker.value',SReturnDate='SReturnDateDateTimePicker.value' where RID='RIDTextBox.text' and BID='BIDTextBox.text'"
        Dim comm As New SqlCommand(sqlstr, conn)
        comm.ExecuteNonQuery()
        conn.Close()
        MsgBox("还书成功")
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
End Sub

End Class
如需文件压缩包留下邮箱

  • 14
    点赞
  • 87
    收藏
    觉得还不错? 一键收藏
  • 103
    评论
图书管理系统的数据库设计 一:需求分析: 1:图书管理系统的功能图 2:系统说明: 1. 不同的读者类型对不同的图书类型借阅的天数不同,不同的读者可借阅的图书总数不同 。 2. 当图书借阅超期后、弄污、遗失会有相应的处罚。 3. 同样的图书在管理系统中会 有多本,每本之间可以区分。 4. 用户注册需经系统管理员同意后才可借阅图书。 5. 读者对预约图书有优先的借阅权。 6. 读者可以对自己的联系方式信息进行修改。 7. 图书卡或图书遗失后可申请挂失,挂失后将不能对图书进行借还操作。 3:分析各功能所需要用到的数据。 用户登录: 用户:用户名,密码 用户注册: 用户:用户名,密码,学号,姓名,系、专业,年级,电话号码,邮箱,性别 图书检索: 图书图书号, ISBN号,书名,作者,价格,出版社,出版日期,简介 查询借阅信息: 借阅:图书,借阅时间,应归还时间,归还时间,续借次数 图书续借: 续借:用户名,图书,续借时间 图书挂失: 图书挂失:图书,用户名,挂失时间,取消挂失时间 图书卡挂失: 图书卡挂失:用户名,挂失时间,取消挂失时间 预约图书: 预约:用户名,图书名,预约时间,借书时间,是否取消 图书管理: 系统管理员:帐号,密码,姓名,性别,年龄,职称 图书管理员:帐号,密码,姓名,性别,年龄,职称 同意读者注册: 用户注册:是否同意 罚款管理: 罚款:用户名,图书,罚款金额,处罚原因,罚款时间 借书: 用户,图书,借书时间 还书: 图书,还书时间 书掉了,罚款: 4:分析实体和实体间的联系 实体:读者图书、系统管理员、图书管理员、读者类型、图书类型 联系: 1. 图书类型 图书 属于 2. 读者类型 读者 属于 3. 读者 图书 借阅,预约,挂失,罚款,续借 4. 图书管理员 图书 借,还,罚款 5. 读者 读者 挂失 二:系统的概念模型设计。 每个实体的E-R图(未完)。 不同实体间的联系(未完): 综合的E—R图 三:数据模型的设计: 1、把上面的概念模型转换为关系模型: 实体的转换: 读者类型(类型编号,类型名称,可借阅的图书数) 读者读者号,密码,姓名,系、专业,年级,电话号码,邮箱,性别,类型编 号) 图书类型(类型编号,类型名称) 图书图书号, ISBN号,书名,作者,价格,出版社,出版日期,简介,类型编号) 图书管理员(帐号,密码,姓名,性别,年龄,职称) 系统管理员(帐号,密码,姓名,性别,年龄,职称) 联系的转换: 借阅限制(读者类型编号,图书类型编号,借阅天数) 图书卡挂失(读者号,挂失时间,取消挂失时间) 借阅(读者号,图书号,借阅时间,应归还时间,归还时间,) 借书(,图书号,读者号,借出时间) 还书(图书管理员编号,图书号,还书时间) 续借(读者号,图书号,续借时间) 图书挂失(读者号,图书号,挂失时间,取消挂失时间) 预约(读者号,图书号,预约时间) 罚款(图书管理员,读者号,图书号,罚款时间,罚款金额,罚款原因) 2、关系的优化: 对上述关系模式的优化 图书管理员和系统管理员的关系模式相同,为了减少关系模式把这两个关系模式 合并为一个关系模式。 图书管理员(帐号,密码,姓名,性别,年龄,职称) 系统管理员(帐号,密码,姓名,性别,年龄,职称) 管理员(帐号,密码,姓名,性别,年龄,职称,类型) 借阅的数据处理与三个关系模式:借阅,借书,还书,在借阅的表中包括除了管 理员以外的所有信息,则把这三个关系模式进行合并: 借阅(读者号,图书号,借阅时间,应归还时间,归还时间,) 借书(管理员编号,图书号,读者号,借出时间) 还书(图书管理员编号,图书号,还书时间) 借阅(读者号,图书号,借阅时间,应归还时间,归还时间,借出图书管理 员编号,还出的图书管理员编号) 3、最后的关系模式如下: 1. 读者类型(类型编号,类型名称,可借阅的图书数) 2. 读者读者号,密码,姓名,系、专业,年级,电话号码,邮箱,性别,类型 编号) 3. 图书类型(类型编号,类型名称) 4. 图书图书号, ISBN号,书名,作者,价格,出版社,出版日期,简介,类型编号) 5. 管理员(帐号,密码,姓名,性别,年龄,职称,类型) 6. 借阅限制(读者类型编号,图书类型编号,借阅天数) 7. 借阅(读者号,图书号,借阅时间,应归还时间,归还时间,借出图书管理员 编号,还出的图书管理员编号) 8. 续借(读者号,图书号,续借时间) 9. 图书卡挂失(读者号,挂失时间,取消挂失时间) 10. 图书挂失(读者号,图书号,挂失时间,取消挂失时间) 11. 预约(读者号,图书号,预约时间) 12. 罚款(图书管理员,读者号,图书号,罚款时间,罚款金额,罚款原因) 四:对每一个关系模式的具体定义 每一个关系对应的表名,每一个属性对应的
评论 103
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值