数据库课程设计之学生信息管理系统.docx
《数据库课程设计之学生信息管理系统.docx》由会员分享,可在线阅读,更多相关《数据库课程设计之学生信息管理系统.docx(7页珍藏版)》请在冰豆网上搜索。
数据库课程设计之学生信息管理系统
数据库课程设计学生信息治理系统
一、概述
1、项目背景:
数据库原理课程设计
2、编写目的:
掌握数据库设计原理及相关软件的使用
3、软件定义:
学生信息治理系统
4、开发环境:
Power builder 9.0
二、需求分析
1、问题的提出:
为了高效率的完成学生信息的治理,决定开发学生信息治理系统。
2、需完成的功能:
(1)能录入、修改、查询、输出学生的档案信息,这些信息包括学生的差不多情况、简历情况、获得奖励情况、受到处分情况、学生的家庭信息、学生的体检情况等。
(2) 能录入、修改、查询、输出学生的入校成绩、各学期各门课的成绩信息,并支持按年级、班级等条件的统计、查询、报表输出。
3、E-R图:
三、数据表:
info
--------------------------------------------------------------------------------------
|sno|sname|sex|age|depart|price|exp|home|health|grade|class|other|
--------------------------------------------------------------------------------------
course
--------------------------
|cno|cname|teacher|
--------------------------
exam
--------------------
|sno|cno|score|
--------------------
info
Column Name Date Type Width 空值情况
Sno Char 20 主关键字
Sname Char 10 不为空
Sex Char 2 不为空
age Numeric 4 可为空
Depart Char 10 不为空
Prize Char 200 可为空
Home Char 200 可为空
Health Char 200 可为空
Other Char 200 可为空
Grade Char 3 不为空
Class Char 3 不为空
exam
Column Name Date Type Width 空值情况
Sno Char 20 主关键字
Cno Char 20 不为空
Score Char 3 可为空
course
Column Name Date Type Width 空值情况
Cno Char 20 主关键字
Cname Char 10 不为空
Teacher Char 5 不为空
①关于关系模式info(|sno|sname|sex|age|depart|price|exp|home|health|grade|class|other|)假定姓名也具有唯一性,那么info就有两个码,这两个码都由单个属性组成,彼此不相交。
其它属性不存在对码的传递依靠与部分依靠,又因为info中除学号、姓名外没有其它的因素,因此info属于BCNF。
②关于关系模式course(|cno|cname|teacher|)中,它只有一个码,那个地点没有任何属性对课程号部分依靠或传递依靠,同时课程号是唯一的决定因素,因此课程属于BCNF。
③关于关系模式exam(|sno|cno|score|)有两个码,这两个码都由单个属性组成,彼此不相交,其它属性不存在对码的传递依靠与部分依靠,又因为成绩中除学号、课程号外没有其它的决定因素,因此成绩属于BCNF。
四、视图,索引,数据库权限:
create view temp (sno,sname,cname,score)
as select info.sno,info.sname,ame,exam.score
from info,exam,course where info.sno=exam.sno and o=o
CREATE UNIQUE INDEX STUSNO ON info(sno);
GRANT SELECT ON TABLE examTO PUBLIC;
五、软件功能设计
功能表:
|-系统维护(下设系统退出)
|-信息录入(下设学生差不多信息录入|学生成绩录入)
|-信息查询(下设学生差不多信息查询|学生成绩查询*)
|-报表
功能描述:
退出系统:
退出程序。
学生数据输入:
输入学号、姓名、性不、年龄、出生年月等学生差不多信息。
成绩输入:
输入各学期学生考试成绩。
学生信息查询:
查询学生差不多信息。
学生成绩查询:
查询学生考试成绩。
按年级输出报表:
输出全年级学生各科目考试成绩。
按班级输出报表:
输出全班学生各科目考试成绩。
六、程序代码及控件描述
启动封面:
(w_start)
Open事件代码:
SQLCA.dbms="ODBC"
SQLCA.database=""
SQLCA.userid=""
SQLCA.dbpass=""
SQLCA.logid=""
SQLCA.logpass=""
SQLCA.dbparm="ConnectString='DSN=student;UID=dba;PWD=sql'"
SQLCA.lock=""
SQLCA.autocommit=false
connect using SQLCA;
IF SQLCA.Sqlcode <> 0 then
messagebox("无法连接数据库!
",SQLCA.sqlerrtext)
close(w_start)
// else
// open(w_startscc)
end if
CommandButton.text=“进入系统”
CommandButton clicked事件代码:
open(w_main)
close(w_start)
主程序窗口(w_main):
title=“学生信息治理系统 V1.0”
包含菜单m_main
窗口(w_infoinput)
Open事件代码:
dw_1.SetTransObject(SQLCA)
dw_1.Retrieve()
控件datawindow的dataobject属性:
i_info(一个freeform风格的数据窗口对象,显示info表的全部列)
commandbutton(text属性:
保存)clicked事件的代码:
dw_1.Update()
commandbutton(text属性:
取消)clicked事件的代码:
dw_1.Retrieve()
commandbutton(text属性:
插入)clicked事件的代码:
dw_1.InsertRow(dw_1.GetRow())
commandbutton(text属性:
删除)clicked事件的代码:
dw_1.DeleteRow(dw_1.GetRow())
窗口(w_scoreinput)
Open事件代码:
dw_1.SetTransObject(SQLCA)
dw_1.Retrieve()
控件datawindow的dataobject属性:
i_score (一个freeform风格的数据窗口对象,显示exam表的全部列)
commandbutton(text属性:
保存)clicked事件的代码:
dw_1.Update()
commandbutton(text属性:
取消)clicked事件的代码:
dw_1.Retrieve()
commandbutton(text属性:
插入)clicked事件的代码:
dw_1.InsertRow(dw_1.GetRow())
commandbutton(text属性:
删除)clicked事件的代码:
dw_1.DeleteRow(dw_1.GetRow())
窗口(w_query)
控件statictext的text属性:
“请输入学号:
”
控件groupbox包含24个statictext控件,它们的text属性分不对应info表的字段名和查询结果
控件SingleLineEdit的text属性为null
commandbutton(text属性:
查询)clicked事件的代码:
Connect;
if SQLCA.SQLCode<0 then
MessageBox("连接错误",SQLCA.SQLErrText,Exclamation!
)
end if
//MessageBox("done",SQLCA.SQLErrText,Exclamation!
)
int Stu_id
string Stu_name,Stu_xuehao,Stu_sex,Stu_age,Stu_home
string Stu_birth,Stu_depart,Stu_price,Stu_info,Stu_health
Stu_id=Integer(sle_id.Text)
select info.sno,info.sname,info.sex,info.age,
info.depart,info.prize,info.exp,info.home,
info.health,info.grade,info.class,info.other
Into :
Stu_sno,:
Stu_sname,:
Stu_sex,:
Stu_age,
:
Stu_depart,:
Stu_prize, :
Stu_exp,:
Stu_home,
:
Stu_health,:
Stu_grade:
Stu_class, :
Stu_other
; From student Where info.sno=:
Stu_id;
IF SQLCA.SQLCode=100 THEN
MessageBox("学生查询","对不起,没有该学生")
ELSEIF SQLCA.SQLCode>0 THEN
MessageBox("数据库错误",SQLCA.SQLErrText,Exclamation!
)
END IF
窗口(w_squery)
控件groupbox(text属性为:
“选择查询模式”)包含2个RadioButton控件,它们的text属性分不为按年级查询和按班级查询
控件SingleLineEdit(text属性为Null)功能为获得输入的年级/班级编号
控件CommandButton(text属性为确定)的Clicked事件代码:
integer n
integer slen
slen=Len(sle_1.text)
n=asc(sle_1.text)-48
if (slen>1 or slen=0) then
messagebox("错误","数据非法!
")
sle_1.text=""
elseif (n<1 or n>9) then
messagebox("错误","数据非法!
")
end if
connect using SQLCA;
if rb_1.checked=true then
select info.sno,info.sname,o,ame,exam.score
from info,course,exam
where info.sno =exam.sno and ,o =o and info.grade=n
end if
if rb_2.checked=true then
select info.sno,info.sname,o,ame,exam.score
from info,course,exam
where info.sno =exam.sno and ,o =o and info.class=n
end if
窗口(w_table)
控件groupbox(text属性为:
“选择模式”)包含2个RadioButton控件,它们的text属性分不为按年级输出和按班级输出
控件SingleLineEdit(text属性为Null)功能为获得输入的年级/班级编号
控件CommandButton(text属性为确定)的Clicked事件代码:
integer n
integer slen
slen=Len(sle_1.text)
n=asc(sle_1.text)-48
if (slen>1 or slen=0) then
messagebox("错误","数据非法!
")
sle_1.text=""
elseif (n<1 or n>9) then
messagebox("错误","数据非法!
")
end if
connect using SQLCA;
if rb_1.checked=true then
select * from dep_exam,info where info.grade=n
end if
if rb_2.checked=true then
select * from dep_exam,info where info.class=n
主菜单(m_main)代码:
退出系统clicked事件的代码:
close(w_main)
学生差不多信息输入clicked事件的代码:
Open(w_infoinput)
学生成绩输入clicked事件的代码:
Open(w_scoreinput)
学生差不多信息查询clicked事件的代码:
Open(w_query)
学生成绩查询clicked事件的代码:
Open(w_squery)
报表clicked事件的代码:
Open(w_table)
七、设计心得
在这次课程设计中,我尝试了使用PowerBuilder进行数据库软件开发的方法,加深了对数据库课程知识的理解。
由于时刻仓促,技术水平有限,软件还有专门多不足之处,如:
成绩查询部分不够完善,成绩输入模块不支持学生成绩批量输入,软件代码比较冗余、效率不高等等,差不多上对PB操作不熟练,对相关功能缺乏认识造成的。
在今后的学习中我会加强理论与实践的结合,通过不断的摸索来弥补自己在软件制作方面的差距。
计算机0303班01号文静
2005年12月20日