2024年1月22日发(作者:)

科 技 学 院

课程设计报告

( 2013-- 2014年度第2学期)

名 称:

数据库原理课程设计

院 系:

班 级:

学 号:

学生姓名:

指导教师:

设计周数: 1

成 绩:

《数据库原理》课程设计

任 务 书

一、

目的与要求

1. 这门课是为计算机科学与技术专业的学生在学习数据库原理后,为培养更好的解决问题和实际动手能力而设置的实践环节。通过这个环节,使学生拥有能够应用数据库原理对数据库系统进行设计的能力。为后继课程和毕业设计打下良好基础。

2. 通过该实验,培养学生在建立数据库系统过程中使用关系数据理论的能力。

3. 通过一个学生并不陌生的完整系统的设计,可以培养学生对需求分析、方案设计、系统编码、界面设计和软件调试等各方面的能力。是一门综合考查学生数据库原理、面向对象设计方法、软件工程和信息系统分析与设计等涉及多课程的综合实验。

二、 主要内容

信息管理系统的设计与实现是针对一个实际中小型系统(见题目附录)进行的数据库设计,它需要管理的内容有实体以及实体之间的联系。

1. 首先要求完成需求的理解和实体的设计:

a)

b)

设计实体的属性和码,以及该实体的实体完整性、用户自定义的完整性。

设计实体的之间的联系,包括联系的类型和联系的属性,即设计实体参照完整性。最后画出完整的E-R图。

2.根据设计好的E-R图及关系数据库理论知识设计数据库模式:

2.1 将E-R图转换为关系模式。

2.2 设计关系模式间的参照完整性。

2.3 用SQL语言实现数据库模式的设计。

3.实现信息管理系统所需的各种操作:

3.1 用SQL语言实现信息的录入、删除和修改。

3.2 以视图的形式完成各类查询,包括单表、多表、单条件、多条件等。

4.权限的设计:

4.1 授权操作;

4.2 收回权限的操作。

5.界面的设计、加密的设计。

三、 进度计划

序号

1

设计(实验)内容

根据任务书完成信息模型的设计,并将该信息模型在选用的DBMS中实现,并录入数据

根据任务书完成各种数据操作,并以视图的形式保留SQL语句。并开始界面的设计与编码

使用可视化开发工具开发学生工作管理系统(C/S或者B/S模式)

界面设计,权限设计和调试

系统的完善与验收

完成时间

1天

备注

2 1天

3

4

5

1天

1天

1天

四、 设计(实验)成果要求

1. 在DBMS(如SQL Server,DB2等)上完成完整的数据库的设计;

2. 使用可视化开发平台完成该系统,并要可以求正确的运行;

3. 完成实验报告。

五、 考核方式

1. 在微机上检查数据库设计的模式的设计、完整性的设计等;

2. 在微机上检查系统的运行结果,并请学生解释所使用的技术;

3. 实验报告的检查。

六、 题目附录

1. 学生信息管理信息系统

2. 学生成绩管理信息系统

3. 图书管理信息系统

4. 物资管理信息系统

5. 汽车销售管理信息系统

6. 超市管理信息系统

7. 通讯录管理信息系统

8. 工资管理信息系统

9. 酒店管理信息系统

10. 小区物业管理信息系统

学生姓名:

指导教师:

年 月 日

一、课程设计(综合实验)的目的与要求

1.这门课是为计算机科学与技术专业的学生在学习数据库原理后,为培养更好的解决问题和实际动手能力而设置的实践环节。通过这个环节,使学生拥有能够应用数据库原理对数据库系统进行设计的能力。为后继课程和毕业设计打下良好基础。

2.通过该实验,培养学生在建立数据库系统过程中使用关系数据理论的能力。

3.通过一个学生并不陌生的完整系统的设计,可以培养学生对需求分析、方案设计、系统编码、界面设计和软件调试等各方面的能力。是一门综合考查学生数据库原理、面向对象设计方法、软件工程和信息系统分析与设计等涉及多课程的综合实验。

二、设计(实验)正文

1.E-R图设计

1.1 图书信息实体

图书信息表用于存放系统图书的信息,一个标准的图书信息实体E-R图

1.2图书管理员信息实体

图书管理员信息实体用于存放管理员的有效信息,一个标准的管理员信息实体E-R图

1.3借阅记录信息实体E-R图

借阅记录信息实体用于记录借阅学生的具体信息,一个标准的借阅信息实体E-R图

1.4 学生信息实体E-R图

学生信息实体用于学生登录借阅图书,一个标准的学生信息实体E-R图

1.5 归还信息实体E-R图

归还信息实体用于消除借阅学生信息,一个标准的归还信息实体E-R图

2.数据库关系模式设计

(一) 书籍类别(种类编号,种类名称)

(二) 借书学生(借书证编号,学生姓名,学生性别,学生性别,学生班级)

(三) 书籍(书籍编号,书籍名称,书籍类别,书记作者,出版社名称)

(四) 借阅(借书学生学号,书籍编号,学生借书时间)

(五) 还书(借书学生学号,书籍编号,学生还书时间)

以上通过关系代数方法的进行运算得到所需要的结果,在实验结果中可以看到。

3. 数据库操作建表

1.图书基本信息表

USE library

Create table book

2.管理员信息表

USE library

Create table manager

3.借阅学生信息表

USE library

Create table student

4.借阅信息表

USE library

Create table borrow

4.可视化界面功能

4.1选择登录页面

学生用户点击学生按钮,管理员用户点击管理员

4.2管理员登录界面

管理员需要正确输入用户名和密码才能登陆,否则会提示“用户名或密码错误,请重新登陆”

4.3管理员可进行的操作的界面

管理员可以进行添加书、学生还书、旧书清理操作

4.4管理员添加书时的界面

管理员需要输入书号、书名、作者、出版社、数量才能成功添加书籍,从而记录到数据库

4.5管理员对归还的书的操作界面

管理员需输入书号和借书人号才能把书归还

4.6管理员清除书的界面

管理员只需输入书号就可清理相应的书籍

4.7

学生登录界面

学生需要输入正确的用户名和密码,才可登陆,否则会提示“用户名或密码错误,请重新登陆”4.8学生登录后可选择的操作的界面

学生可进行查询和借阅操作

4.9学生查询图书信息界面

学生可以输入书名或作者任一一项,点击查询,就可看到相关书籍信息,也可点击借阅,跳转到借阅界面

4.10借阅图书界面

借书人需要输入书号和借阅人号,点击借阅,如果成功会提示“借阅成功”

三、课程设计(综合实验)总结或结论

通过此次数据库的课程设计,是我们学以致用,增强了对数据库方面应用的理解,对自己今后参与开发数据库系统积累了不少经验,在实验过程中,从建立数据开始,对灵据库设计理念及思想上有更高的认识,从需求分析,到概念设计和逻辑设计,E-R图的表示,数据字典的创建,懂得了不少有关数据库开发过程中的知识,在实验中建表,及其关系模式,关系代数的建立及理解,将SQL语的查询语句用得淋漓尽致,增强了自己在数据库中应用SQL语言的灵活性,其中包括,插入、删除、修改、查询,牵涉表和表之间的联系,主建与外主键的定义,约束项的设置,使逻辑更严密。

界面的实现结合VS是我在学习中产生了跟做兴趣在学习过程中,我也能过上网查了不少资料,也看了一些别人设计的图书馆管理信息系统的设计报告,学以致用,自我创新,独立完成了这份自己的报告,从中在学到用,从用又到学,不断修改,系统更新。虽然不能达到完善系统,但也做到了尽善尽美,加强理论学习对完善系统会有很多帮助,不管怎么说,对这次做的课程设计自己觉得还算满意。

四、参考文献

[1] 王珊,《数据库系统概论》.高等教育出版社,第四版.2007-11-01

附录(设计流程图、程序、表格、数据等)

部分代码:

namespace WindowsApplication1

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

using(Form2 form2 = new Form2())

{

y = 0;

alog();

y = 100;

}

}

private void button2_Click(object sender, EventArgs e)

{

using (Form7 form7 = new Form7())

{

y = 0;

alog();

y = 100;

}

}

private void Form1_Load(object sender, EventArgs e)

{

}

}

}

using System;

namespace WindowsApplication1

{

public partial class Form2 : Form

{

public Form2()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

string strcon = "Data Source=(local);Initial Catalog=library;Integrated

Security=True";

string sno = ng();

string spassword = ng();

SqlConnection conn = new SqlConnection(strcon);

();

SqlCommand cmd = new SqlCommand("select * from student where sno=@sno and

spassword=@spassword", conn);

(new SqlParameter("sno", sno));//连接字符串

(new SqlParameter("spassword", spassword));//连接字符串

SqlDataReader dr = eReader();

if (())

{

using (Form3 form3 = new Form3())

{

y = 0;

alog();

y = 100;

}

}

else

= "用户名或密码错误,请重新登陆";

}

private void textBox1_TextChanged(object sender, EventArgs e)

{

}

private void Form2_Load(object sender, EventArgs e)

{

}

}

}

namespace WindowsApplication1

{

public partial class Form3 : Form

{

public Form3()

{

InitializeComponent();

}

private void querry_Click(object sender, EventArgs e)

{

using (Form8 form8 = new Form8())

{

y = 0;

alog();

y = 100;

}

}

private void borrow_Click(object sender, EventArgs e)

{

using (Form9 借阅 = new Form9())

{

y = 0;

借阅.ShowDialog();

y = 100;

}

}

private void Form3_Load(object sender, EventArgs e)

{

}

}

}

public partial class Form4 : Form

{

public Form4()

{

InitializeComponent();

}

private void button2_Click(object sender, EventArgs e)

{

using (Form6 form6 = new Form6())

{

y = 0;

alog();

y = 100;

}

}

private void button1_Click(object sender, EventArgs e)

{

using (Form5 form5= new Form5())

{

y = 0;

alog();

y = 100;

}

}

private void button2_Click_1(object sender, EventArgs e)

{

using (Form6 form6 = new Form6())

{

y = 0;

alog();

y = 100;

}

}

private void button3_Click(object sender, EventArgs e)

{

using (Form10 清理书籍 = new Form10())

{

y = 0;

清理书籍.ShowDialog();

y = 100;

}

}

private void Form4_Load(object sender, EventArgs e)

{

}

}

}

public partial class Form5 : Form

{

public Form5()

{

InitializeComponent();

}

private void textBox1_TextChanged(object sender, EventArgs e)

{

}

private void button1_Click(object sender, EventArgs e)

{

string strconn = "Data Source=(local);Initial Catalog=library;Integrated

Security=True";

//string strsql = "update student set

sname=@sname,sage=@sage,ssex=@ssex,sclass=@sclass where sno=@sno";

string strsql = "insert into book values(@bno,@bname,@bauthor,@bpress,@bamount)";

SqlParameter sp1 = new SqlParameter("@bno", ());

SqlParameter sp2 = new SqlParameter("@bname", ());//trim 去空格

SqlParameter sp3 = new SqlParameter("@bauthor", ());//trim 去空格

SqlParameter sp4 = new SqlParameter("@bpress", ());//trim 去空格

SqlParameter sp5 = new SqlParameter("@bamount", ());//trim 去空格

using (SqlConnection conn4 = new SqlConnection(strconn))

{

();

using (SqlCommand cmd4 = new SqlCommand(strsql, conn4))

{

(sp1);

(sp2);

(sp3);

(sp4);

(sp5);

if (eNonQuery() > 0)//影响的行数

{

("ok");

}

}

}

}

private void Form5_Load(object sender, EventArgs e)

{

}

}

}

public partial class Form6 : Form

{

public Form6()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

string strconn = "Data Source=(local);Initial Catalog=library;Integrated

Security=True";

//string strsql1 = "insert into borrow values(@sno,@bno,@bt,@bbt)";

string strsql1 = "delete from borrow where bno=@bno and sno=@sno ";

SqlParameter sp1 = new SqlParameter("@bno", ());//trim 去空格

SqlParameter sp2 = new SqlParameter("@sno", ());//trim 去空格

//SqlParameter sp3 = new SqlParameter("@bt", 30);//trim 去空格

//SqlParameter sp4 = new SqlParameter("@bbt", ng());//trim 去空格

// SqlParameter sp6 = new SqlParameter("@bno", ());

using (SqlConnection conn4 = new SqlConnection(strconn))

{

();

using (SqlCommand cmd4 = new SqlCommand(strsql1, conn4))

{

(sp1);

(sp2);

//(sp3);

//(sp4);

string strsql2 = "select bamount from book where bno = @bno";

SqlParameter sp5 = new SqlParameter("@bno", ());

using (SqlConnection conn5 = new SqlConnection(strconn))

{

();

using (SqlCommand cmd5 = new SqlCommand(strsql2, conn5))

{

(sp5);

using (SqlDataReader dr = eReader())

{

if (())

{

string strsql3 = "update book set bamount=@bamount where

bno=@bno";

int a = (dr["bamount"].ToString());

SqlParameter sp6 = new SqlParameter("@bamount", a + 1);

SqlParameter sp7 = new SqlParameter("@bno",

());

using (SqlConnection conn6 = new SqlConnection(strconn))

{

();

using (SqlCommand cmd6 = new SqlCommand(strsql3,

conn6))

{

(sp6);

(sp7);

if (eNonQuery() > 0 &&

eNonQuery() > 0)//影响的行数

{

("归还成功");

}

}

}

}

}

}

}

}

}

}

private void Form6_Load(object sender, EventArgs e)

{

}

}

}

public partial class Form7 : Form

{

string strconn = "Data Source=(local);Initial Catalog=library;Integrated

Security=True";

public Form7()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

string strconn = "Data Source=(local);Initial Catalog=library;Integrated

Security=True";

string mno = ng();

string mpassword = ng();

SqlConnection conn = new SqlConnection(strconn);

();

SqlCommand cmd = new SqlCommand("select * from manager where mno=@mno and

mpassword=@mpassword", conn);

(new SqlParameter("mno", mno));//连接字符串

(new SqlParameter("mpassword", mpassword));//连接字符串

SqlDataReader dr = eReader();

if (())

{

using (Form4 form4 = new Form4())

{

y = 0;

alog();

y = 100;

}

}

else

= "用户名或密码错误,请重新登陆";

}

private void Form7_Load(object sender, EventArgs e)

{

}

}

}

public partial class Form8 : Form

{

public Form8()

{

InitializeComponent();

}

private void Form8_Load(object sender, EventArgs e)

{

}

private void button1_Click(object sender, EventArgs e)

{

string strconn = "Data Source=(local);Initial Catalog=library;Integrated

Security=True";

string Bname = ;

string Bauthor = ;

//string strsql = "select * from student where Bname=@name";//@name 参数

//string strsql="select * from student where 1=1";

// if (!OrEmpty(Bname))

// { strsql=strsql+" and Bname=@name" }

string StrSql = "select * from book where 1=1";

DataTable dt = new DataTable();

using (SqlConnection con = new SqlConnection(strconn))

{

();

SqlCommand cmd = new SqlCommand();

using (cmd)

{

/* if (!OrEmpty(Bname))

{

StrSql += " and Bname=@Bname";

SqlParameter SpBname = new SqlParameter("@Bname", Bname);

(SpBname);

}

if (!OrEmpty(Bauthor))

{

StrSql += " and Bauthor=@Bauthor";

SqlParameter SpBauthor = new SqlParameter("@Bauthor", Bauthor);

(SpBauthor);

}*/

if (!OrEmpty(Bname) && OrEmpty(Bauthor))

{

StrSql += " and bname=@bname";

SqlParameter SpBname = new SqlParameter("@bname", Bname);

(SpBname);

}

else if (!OrEmpty(Bauthor) && OrEmpty(Bname))

{

StrSql += " and bauthor=@bauthor";

SqlParameter SpBauthor = new SqlParameter("@bauthor", Bauthor);

(SpBauthor);

}

else if (!OrEmpty(Bauthor) && !OrEmpty(Bname))

{

StrSql += " and bname=@bname";

SqlParameter SpBname = new SqlParameter("@bname", Bname);

(SpBname);

StrSql += " and bauthor=@bauthor";

SqlParameter SpBauthor = new SqlParameter("@bauthor", Bauthor);

(SpBauthor);

}

else

{

urce = '无';

}

dText = StrSql;

tion = con;

using (SqlDataAdapter sda = new SqlDataAdapter(cmd))

{

(dt);

}

}

}

urce = dt;

}

private void button2_Click(object sender, EventArgs e)

{

using (Form9 借阅 = new Form9())

{

y = 0;

借阅.ShowDialog();

y = 100;

}

}

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs

e)

{

}

}

}

public partial class Form9 : Form

{

public Form9()

{

InitializeComponent();

}

private void Form9_Load(object sender, EventArgs e)

{

}

private void button1_Click(object sender, EventArgs e)

{

string strconn = "Data Source=(local);Initial Catalog=library;Integrated

Security=True";

string strsql1 = "insert into borrow values(@sno,@bno,@bt,@bbt)";

SqlParameter sp1 = new SqlParameter("@bno", ());//trim 去空格

SqlParameter sp2 = new SqlParameter("@sno", ());//trim 去空格

SqlParameter sp3 = new SqlParameter("@bt", 30);//trim 去空格

SqlParameter sp4 = new SqlParameter("@bbt", ng());//trim 去空格

// SqlParameter sp6 = new SqlParameter("@bno", ());

using (SqlConnection conn4 = new SqlConnection(strconn))

{

();

using (SqlCommand cmd4 = new SqlCommand(strsql1, conn4))

{

(sp1);

(sp2);

(sp3);

(sp4);

string strsql2 = "select bamount from book where bno = @bno";

SqlParameter sp5 = new SqlParameter("@bno", ());

using (SqlConnection conn5 = new SqlConnection(strconn))

{

();

using (SqlCommand cmd5 = new SqlCommand(strsql2, conn5))

{

(sp5);

using (SqlDataReader dr = eReader())

{

if (())

{

string strsql3 = "update book set bamount=@bamount where

bno=@bno";

int a = (dr["bamount"].ToString());

SqlParameter sp6 = new SqlParameter("@bamount", a - 1);

SqlParameter sp7 = new SqlParameter("@bno",

());

using (SqlConnection conn6 = new SqlConnection(strconn))

{

();

using (SqlCommand cmd6 = new SqlCommand(strsql3,

conn6))

{

(sp6);

(sp7);

if (eNonQuery() > 0 &&

eNonQuery() > 0)//影响的行数

{

("借阅成功");

}

}

}

}

}

}

}

}

}

/* string strsql2 = "select bamount from book where bno = @bno";

SqlParameter sp5 = new SqlParameter("@bno", ());

using (SqlConnection conn5 = new SqlConnection(strconn))

{

();

using (SqlCommand cmd5 = new SqlCommand(strsql2, conn5))

{

(sp5);

using (SqlDataReader dr = eReader())

{

if (())

{

string strsql3 = "update book set bamount=@bamount where bno=@bno";

int a = (dr["bamount"].ToString());

SqlParameter sp6 = new SqlParameter("@bamount", a-1);

SqlParameter sp7 = new SqlParameter("@bno", ());

using (SqlConnection conn6 = new SqlConnection(strconn))

{

();

using (SqlCommand cmd6 = new SqlCommand(strsql3, conn6))

{

(sp6);

(sp7);

if ( eNonQuery() > 0)//影响的行数

{

("借阅成功");

}

}

}

}

}

}

}*/

}

}

}

public partial class Form10 : Form

{

public Form10()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

string strconn = "Data Source=(local);Initial Catalog=library;Integrated

Security=True";

string strsql = "delete from book where bno=@bno";

SqlParameter sp1 = new SqlParameter("@bno", ());

using (SqlConnection conn4 = new SqlConnection(strconn))

{

();

using (SqlCommand cmd4 = new SqlCommand(strsql, conn4))

{

(sp1);

if (eNonQuery() > 0)

{

("清理完成");

}

}

}

}

private void Form10_Load(object sender, EventArgs e)

{

}

}

}