一 . 学生信息管理系统资源
下载链接学生信息管理.accdb-Access文档类资源-CSDN下载
二.数据库设计
2.1ER图设计
2.2从ER图到关系模式
ER图中存在三个实体:学生、课程、成绩;两个关系:选修和所属。学生与课程n:m联系。课程与学生成绩1:m联系。“选修”和“所属”不单独建立实体集。把“学生”中的学号和“课程”中的课程号设为主键,其他的属性设为外键。学生与成绩可通过课程建立联系。
2.3关系模式的数据字典
学生表
数据项名 | 类型 | 长度 | 精度 | 取值范围 | 默认值 | 是否允许为空 | KEY |
id | char | 255 | NULL | NO | PRI | ||
name | char | 25 | NULL | YES | |||
gender | char | 25 | NULL | YES | |||
class | char | 25 | NULL | YES | |||
address | char | 25 | NULL | YES | |||
age | char | 25 | NULL | YES | |||
Phone number | char | 25 | NULL | YES | |||
password | char | 20 | NULL | YES |
成绩表
数据项名 | 类型 | 长度 | 精度 | 取值范围 | 默认值 | 是否允许为空 | KEY |
student_id | char | 255 | NULL | NO | PRI | ||
class_id | char | 255 | NULL | NO | PRI | ||
score | char | 25 | NULL | YES |
课程表
数据项名 | 类型 | 长度 | 精度 | 取值范围 | 默认值 | 是否允许为空 | KEY |
id | char | 255 | NULL | NO | PRI | ||
name | char | 255 | NULL | YES | |||
point | char | 25 | NULL | YES |
2.4系统开发工具简介
开发工具:access
2.5数据库与表的建立
学生表:student的创建
sql = """CREATE TABLE IF NOT EXISTS student(
id char(255) NOT NULL,
name char(25) default NULL,
gender char(5) default NULL,
class char (25) default NULL,
address char(25) default NULL,
age char(25) default NULL,
phone number char(25) default NULL,
password char(20) default NULL,
PRIMARY KEY (id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8
"""
cursor.execute(sql)
Field | Type | Null | Key | Default |
id | Char(255) | NO | PRI | NULL |
name | Char(25) | YES | NULL | |
gender | Char(25) | YES | NULL | |
class | Char(25) | YES | NULL | |
address | Char(25) | YES | NULL | |
age | Char(25) | YES | NULL | |
Phone number | Char(25) | YES | NULL | |
password | Char(20) | YES | NULL |
课程表的创建:class
sql = """CREATE TABLE IF NOT EXISTS class(
id char(255) NOT NULL,
name char(255) default NULL,
point char(25) default NULL,
PRIMARY KEY (id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8
"""
cursor.execute(sql)
Field | Type | Null | Key | Default |
id | Char(255) | NO | PRI | NULL |
name | Char(255) | YES | NULL | |
point | Char(25) | YES | NULL |
成绩表的创建:score
sql = """CREATE TABLE IF NOT EXISTS score(
stu_id char(255) NOT NULL,
class_id char(255) NOT NULL,
score char(25) default NULL,
PRIMARY KEY (class_id,student_id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8
"""
cursor.execute(sql)
Field | Type | Null | Key | Default |
student_id | Char(255) | NO | PRI | NULL |
class_id | Chat(255) | NO | PRI | NULL |
score | Char(25) | YES | NULL |
管理员表的创建:admin_k
sql = """CREATE TABLE IF NOT EXISTS admin_login_k(
admin_id char(50) NOT NULL,
admin_pass char(50) default NULL,
PRIMARY KEY (admin_id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8
"""
cursor.execute(sql)
Field | Type | Null | Key | Default |
admin_id | Char(50) | NO | NULL | |
admin_pass | Char(50) | YES | NULL |
2.6用户管理权限的实现
2.6.1 登陆界面
页面主要有Visual Basic代码编写,主界面设计关键代码:
Option Compare Database
Private gl As Boolean
Private Sub Option4_Click()
If Me.Option4.Value = -1 Then
Me.Option8.Value = 0
gl = True
End If
End Sub
Private Sub Option8_Click()
If Me.Option8.Value = -1 Then
Me.Option4.Value = 0
gl = False
End If
End Sub
Private Sub 登录_Click()
If IsNull(Me.Option4.Value) And IsNull(Me.Option8.Value) Then MsgBox "请选择角色后再登录", vbExclamation, vbOKOnly: Exit Sub
If IsNull(UserName) Then
MsgBox "用户名不能为空,请重新选择!", vbExclamation + vbOKOnly, "提醒您!" '弹出框
Me.UserName.SetFocus
Exit Sub
Else
If IsNull(Password) Then
MsgBox "注意,您忘了输入密码!", vbExclamation + vbOKOnly, "提醒您!" '弹出框
Me.Password.SetFocus
Exit Sub
End If
If gl Then
If DLookup("管理员密码", "管理员", "管理员名称='" & UserName & "'") = [Password] Then
'验证账号密码
Me.Visible = False
Me.Password = Null
MsgBox "登录成功!", vbExclamation, "提醒您"
StrName = Me.UserName
Else
MsgBox "您输入的密码有误,请重新输入,注意大小写!", vbExclamation + vbOKOnly, "提醒您!"
Exit Sub
End If
'管理员登录
DoCmd.OpenForm ("管理员系统") '登陆成功,打开管理员系统界面
Else
'普通用户登录
If DLookup("密码", "学生", "学号='" & UserName & "'") = [Password] Then
'验证账号密码
Me.Visible = False
Me.Password = Null
MsgBox "登录成功!", vbExclamation, "提醒您" '登陆成功
StrName = Me.UserName
Else
MsgBox "您输入的密码有误,请重新输入,注意大小写!", vbExclamation + vbOKOnly, "提醒您!"
Exit Sub
End If
DoCmd.OpenForm ("学生系统")
End If
'弹出框
Me.Password = Null
Me.Password.SetFocus
End If
End Sub
2.6.2学生系统
Option Compare Database
Private Sub Command1_Click()
On Error GoTo Err_Command1_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "学生信息查询"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub
Private Sub Command2_Click()
On Error GoTo Err_Command1_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "课程查询"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub
Private Sub Command3_Click()
On Error GoTo Err_Command1_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "成绩查询"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub
2.6.3管理员系统
Option Compare Database
Private Sub Command1_Click()
On Error GoTo Err_Command1_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "学生信息管理"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub
Private Sub Command2_Click()
On Error GoTo Err_Command1_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "成绩管理"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub
Private Sub Command3_Click()
On Error GoTo Err_Command1_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "登录"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub
Private Sub Command4_Click()
On Error GoTo Err_Command1_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "采购员信息管理"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub
2.7删除记录
通过宏命令的叠加设计:
2.8修改记录
宏命令:
2.9增加记录
宏命令:
2.10信息查询
宏命令:
三、总结(经验与不足)
数据库管理系统实现的功能:
基本上用所学知识实现了大数据的增删改查,数据比较完整,极易查询,界面清晰,较为简单,操作也相对方便,用户友好度较高界面简洁明了,总体上来说完成度较高,具备了学生信息管理系统的基本功能。
数据库存在的问题:
距离真正投入使用还是存在着较大差距
管理员的管理流程和系统过于简单,容易误改学生信息
学生之间也可以互相查看对方信息,私密性较差
更多推荐
学生信息管理系统(数据库)
发布评论