数据库课程设计工资管理系统Word格式文档下载.docx

上传人:b****2 文档编号:3857839 上传时间:2023-05-02 格式:DOCX 页数:14 大小:56.89KB
下载 相关 举报
数据库课程设计工资管理系统Word格式文档下载.docx_第1页
第1页 / 共14页
数据库课程设计工资管理系统Word格式文档下载.docx_第2页
第2页 / 共14页
数据库课程设计工资管理系统Word格式文档下载.docx_第3页
第3页 / 共14页
数据库课程设计工资管理系统Word格式文档下载.docx_第4页
第4页 / 共14页
数据库课程设计工资管理系统Word格式文档下载.docx_第5页
第5页 / 共14页
数据库课程设计工资管理系统Word格式文档下载.docx_第6页
第6页 / 共14页
数据库课程设计工资管理系统Word格式文档下载.docx_第7页
第7页 / 共14页
数据库课程设计工资管理系统Word格式文档下载.docx_第8页
第8页 / 共14页
数据库课程设计工资管理系统Word格式文档下载.docx_第9页
第9页 / 共14页
数据库课程设计工资管理系统Word格式文档下载.docx_第10页
第10页 / 共14页
数据库课程设计工资管理系统Word格式文档下载.docx_第11页
第11页 / 共14页
数据库课程设计工资管理系统Word格式文档下载.docx_第12页
第12页 / 共14页
数据库课程设计工资管理系统Word格式文档下载.docx_第13页
第13页 / 共14页
数据库课程设计工资管理系统Word格式文档下载.docx_第14页
第14页 / 共14页
亲,该文档总共14页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

数据库课程设计工资管理系统Word格式文档下载.docx

《数据库课程设计工资管理系统Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《数据库课程设计工资管理系统Word格式文档下载.docx(14页珍藏版)》请在冰点文库上搜索。

数据库课程设计工资管理系统Word格式文档下载.docx

(部门号)

char

8

主关键字

department_name

(部门名)

15

depart_manage

(部门经理)

6

depart_people

(部门人数)

int

②staff(职工)

staff_no

(职工号)

10

staff_name

(职工姓名)

20

staff_sex

(职工姓别)

25

默认

”男”

Enducational

(学历)

dapartment_no(部门号)

(部门名称)

③salary(工资)

(职工工号)

外键

m_salary

(月薪)

默认3000

Allowance

(津贴)

默认0

out_days

(出勤天数)

2

out_days<

=31andout_days>

=0

work_overtim

(加班时间)

datetime

w_overtime_days

(加班天数)

w_overtime_days>

=0andw_overtime_days<

=31

Deduct

(事故扣薪)

4

issue_salary

(应发薪水)

iss_salary

(实发薪水)

Int

①建库

createdatabasesalary_manage

on

(name=salary_manage_data,

filename='

d:

\salary_manage_data.mdf'

size=25,

maxsize=35,

filegrowth=5)

logon

(name=manage_log,

\salary_manage_data.ldf'

②建表

/建立职工表/

createtablestaff

(staff_nochar(10)primarykey,/*职工工号*/

staff_namechar(20)notnull,/*职工姓名*/

staff_sexchar(25)notnulldefault'

男'

check(staff_sexin('

'

女'

)),/*性别*/

enducationalchar(10)default'

本科'

/*学历*/

dapartment_nochar(8)notnull,/*部门编号*/

department_namechar(15))/*部门名称*/

/*建立工资表*/

createtablesalary

(staff_nochar(10)notnullforeignkeyreferencesstaff(staff_no),/*职工工号*/

m_salaryintdefault3000,/*月薪*/

allowanceintdefault0,/*津贴*/

out_daysintnotnullcheck(out_days<

=0),/*出勤天数*/

work_overtimedatetime(10),/*加班时间*/

w_overtime_daysintdefault0check(w_overtime_days>

=31),/*加班天数*/

deductintdefault0,/*事故扣薪*/

add_moneyintdefault0,/*加班费*/

issue_salaryint(4)notnull,/*应发薪水*/

iss_salaryint(4)notnull)/*实发薪水*/

/*建立部门表*/

createtabledepartment

(department_nochar(8)primarykey,/*部门编号*/

department_namechar(15)notnull,/*部门名称*/

depart_managechar(6)notnull,/*部门经理*/

depart_peopleint(6)/*部门人数*/

③添加记录

insertintodepartment

values('

071011'

A部门'

王经理'

100);

071012'

B部门'

李经理'

200);

071013'

C部门'

张经理'

insertintostaff

0610'

李明'

);

0613'

张三'

专科'

0611'

刘丽'

0612'

张新'

insertintosalary

3000,100,30,'

2011-10-8'

2,50,0,3000,3200);

3000,0,20,'

'

0,0,500,3000,2500);

3000,100,31,'

2011-10-10'

1,50,0,3000,3150);

四、功能处理

1、查询

①表查询

select*fromdepartment/*查询部门表*/

select*fromstaff/*查询职工表*/

select*fromsalary/*查询工资表*/

②数据查询

selectsalary.staff_no,staff_name,issue_salary,iss_salary

fromsalary,staff

whereiss_salary>

3000andsalary.staff_no=staff.staff_no

orderbysalary.staff_no

selectstaff_no,staff_namefromstaff

wherestaff_namelike'

刘%'

;

2、数据更新

①插入(前面已插入)

②修改

updatesalary

setiss_salary=1.2*iss_salary

whereiss_salary<

2600;

③删除

deletefromstaff

whereenducational='

3.索引

①建立索引

createindexj

onsalary(staff_no,issue_salary,iss_salary)

createuniqueindexindex_staff

onstaff(staff_name)

createuniqueindexindex_depart

ondepartment(depart_people)

②查询索引

execsp_helpindexsalary

execsp_helpindexstaff

execsp_helpindexdepartment

③修改索引

execsp_rename'

salary.j'

salary_index'

④删除索引

dropindexindex

4.视图

①创建视图

createviewtable_salary(staff_no,staff_name,issue_salary,iss_salary)

asselectsalary.staff_no,staff_name,issue_salary,iss_salary

wheresalary.staff_no=staff.staff_no

②查找视图

select*fromtable_salary

③/*修改视图*/

Alterviewtable_salary

(staff_no,staff_name,department_name,issue_salary,iss_salary)

asselectsalary.staff_no,staff_name,department_name,issue_salary,iss_salary

wheresalary.staff_no=staff.staff_no;

④删除视图

dropviewtable_salary

5.存储过程

①创建存储过程。

createprocedurepro_staff

(@staff_nochar(10),

@staff_namechar(25),

@staff_sexchar(25),

@enducationalchar(10),

@department_nochar(8),

@department_namechar(15))

as

insertintostaffvalues

(@staff_no,@staff_name,@staff_sex,@enducational,@department_no,@department_name)

updatedepartment

setdepart_people=depart_people+1

wheredepartment_no=@department_no

createprocedurepro_salary

as

(@m_salaryint,

@allowanceint,

@add_moneyint,

@deductint

updatesalary

setiss_salary=(@m_salary+@allowance+@add_money-@deduct)

wherem_salary=@m_salaryandallowance=@allowanceandadd_money=@add_moneyanddeduct=@deduct

②查看存储过程

execsp_helptextpro_staff

execsp_helptextpro_salary

③执行存储过程

execpro_staff@staff_no='

0614'

@staff_name='

王敏'

@staff_sex='

@enducational='

科'

@department_no='

@department_name='

④删除存储过程

dropprocedurepro_staff

6.触发器

①创建触发器

createtriggerm

onsalary

forupdate

ifupdate(m_salary)

begin

rollbacktransaction

print'

月薪不能修改,请联系财务科'

end

CREATETRIGGERTRI_salary

ONsalary

FORupdate,insert

AS

BEGIN

updatesalarysetadd_money=(w_overtime_days*50)

updatesalarysetissue_salary=m_salary

updatesalarysetiss_salary=(m_salary+allowance+add_money-deduct)

END

createtriggertri_department

ondepartment

forinsert

declare@staff_nochar(8)

declare@department_nochar(15)

createtriggertri_change

onstaff

fordelete

delete

fromsalary

wheresalary.staff_no=any(selectstaff_nofromdeleted)

setdepart_people=depart_people-1

wheredepartment_no=any(selectdepartment_nofromdeleted)

②触发器的删除

droptriggertri_department;

7.用户与权限

/*创建登陆账号*/

execsp_addlogin'

zhangsan'

1234'

salary_manage'

null

/*把用户加入到数据库中*/

execsp_adduser'

/*删除登陆账号*/

execsp_droplogin'

/*系统权限*/

grantcreatetable

tozhangsan

/*收回系统权限*/

revokecreatetable

fromzhangsan

/*对象权限*/

grantall

withgrantoption

grantselect

topublic

/*收回系对象权限*/

revokeselectonsalary

五.实验总结

本报告主要介绍的是对自建的一个工资管理系统数据库,利用在数据库中的表、存储过程、视图、约束等组合,设计出比较实用的应用软件代码;

对表中的信息能够进行简单的查询,子查询,视图的创建、修改与删除,与约束的创建,存储过程与触发器的创建与删除等基本操作,加深对SQLServer数据库的进一步研究。

通过这次实训,是我对SQL有了进一步了解,虽然在此期间遇到过麻烦,但通过查阅资料与尝试解决问题,使我更加了解SQL的基础知识,从中学到了新知识。

六.心得体会

通过这次的课程设计实验,我发现自己对数据库课程的兴趣有了很大提高,而且对课本的知识更加的了解并有了一定的掌握,通过实验我懂得了如何创建索引、视图、存储过程以及触发器。

以前不懂为何要创建触发器、视图等,现在终于知道它们的优点了。

在自己没做数据库课程设计以前,总是觉得自己什么都不懂什么都不会,但是现在做出来了,所以我觉得自己还是有能力做一些实际操作方面的东西。

我相信以后通过自己自学其它课程,我一定会做出一个更好的数据库。

七、参考资料

1.陈志泊编。

数据库原理与应用教程(第二版)。

人民邮电出版社

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 医药卫生 > 基础医学

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2