资源描述
数据库课程设计学生信息管理系统
一、概述
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 &nb sp; Char 200 可为空
Other Char 200 可为空
Grade Char 3 不为空
Class Char 3 不为空
exam
Column Name Date Type Width 空值情况
Sno Char 20 主关键字
Cno&nb sp; Char 20 不为空
Score Char 3 可为空
course
Column Name Date Type Width 空值情况
Cno Char 20 主关键字
Cname Char 10 不为空
Teacher & nbsp;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&nb sp;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 & lt;> 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()
控件datawindowdataobject属性: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())
commandbu tton(text属性:删除)clicked事件代码:dw_1.DeleteRow(dw_1.GetRow())
窗口(w_scoreinput)
Open事件代码:
dw_1.SetTransObject(SQLCA)
dw_1.Retrieve()
控件datawindowdataobject属性: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)
控件statictexttext属性:“请输入学号:”
控件groupbox包含24个statictext控件,它们text属性分别对应info表字段名和查询结果
控件SingleLineEdittext属性为null
commandbutton(text属性:查询)clicked事件代码:
Connect;
if SQLCA.SQLCode<0 then
MessageBox("连接错误",SQLCA.SQLErrText,Exclamation!)
end if
//Mess ageBox("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)功效为取得输入年级/班级编号
控件CommandBu tton(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号 文静
12月20日
展开阅读全文