课程
设计
领导形象设计圆作业设计ao工艺污水处理厂设计附属工程施工组织设计清扫机器人结构设计
要求:
1.对各个系统进行系统功能需求分析
2. 数据库设计分析阶段,进行详细的数据库需求分析,进行概念数据库的设计,画出数据库的E-R图(局部和整体E-R图)
3. 设计出详细的逻辑数据库结构,将各个实体和联系转化为相应的二维表即关系模式,指定各个关系的主关键字和外部关键字,并对各个关系的约束加以限定
4. 通过企业管理器或是查询分析器实现各个二维关系(建议最好用SQL代码实现),要求建立相关的索引
5. 根据系统功能需求设计相应的查询视图
6. 要求根据系统功能需求建立存储过程
7. 根据功能需求建立相应的触发器以保证数据的一致性
8. 通过建立用户和权限分配实现数据库一定的安全性,考虑数据库的备份与恢复(此内容选作)
需求分析
企业的工资管理是公司管理的一个重要内容。随着科学技术的发展,一些公司的规模也越来越大,职工的数量也在不断的增加,企业的管理工作也变得越来越复杂。工资管理既涉及到企业劳动人事的管理,同时也是企业财务的重要组成部分。面对如此大的信息量,单凭传统的
表格
关于规范使用各类表格的通知入职表格免费下载关于主播时间做一个表格详细英语字母大小写表格下载简历表格模板下载
、手工操作已不能满足实际的需要。因此,我设计工资管理系统来提高财务管理方面的效率。通过这个系统可以使信息的管理更加规范,统计更科学。
模块功能分析:
(1)部门模块:用来管理部门;
(2)工资模块:用来管理员工的工资;
(3)职工模块:用来管理工厂的职工信息;
二、概念结构设计
经分析,本系统的e-r图如下:
SHAPE \* MERGEFORMAT
三、逻辑结构设计
工资管理基本信息表
①department(部门)
列名
数据类型
长度
是否允许空
备注
department_no
(部门号)
char
8
否
主关键字
department_name
(部门名)
char
15
否
depart_manage
(部门经理)
char
6
否
depart_people
(部门人数)
int
6
否
② staff(职工)
列名
数据类型
长度
是否允许空
备注
staff_no
(职工号)
char
10
否
主关键字
staff_name
(职工姓名)
char
20
否
staff_sex
(职工姓别)
char
25
否
默认
”男”
Enducational
(学历)
char
10
否
dapartment_no(部门号)
char
8
否
department_name
(部门名称)
char
15
否
③salary(工资)
列名
数据类型
长度
是否允许空
备注
staff_no
(职工工号)
char
10
否
外键
m_salary
(月薪)
int
6
否
默认3000
Allowance
(津贴)
int
10
是
默认0
out_days
(出勤天数)
int
2
否
out_days<=31 and out_days>=0
work_overtim
(加班时间)
datetime
10
是
w_overtime_days
(加班天数)
int
2
否
默认0
w_overtime_days>=0 and w_overtime_days<=31
Deduct
(事故扣薪)
int
4
否
默认0
issue_salary
(应发薪水)
int
4
否
iss_salary
(实发薪水)
Int
4
否
①建库
create database salary_manage
on
(name=salary_manage_data,
filename='d:\salary_manage_data.mdf',
size=25,
maxsize=35,
filegrowth=5)
log on
(name=manage_log,
filename='d:\salary_manage_data.ldf',
size=25,
maxsize=35,
filegrowth=5)
②建表
/建立职工表/
create table staff
(staff_no char(10) primary key,/*职工工号*/
staff_name char(20) not null,/*职工姓名*/
staff_sex char(25) not null default '男'check( staff_sex in('男','女')),/*性别*/
enducational char(10) default '本科',/*学历*/
dapartment_no char(8) not null,/*部门编号*/
department_name char(15))/*部门名称*/
/*建立工资表*/
create table salary
(staff_no char(10) not null foreign key references staff(staff_no),/*职工工号*/
m_salary int default 3000,/*月薪*/
allowance int default 0,/*津贴*/
out_days int not null check(out_days<=31 and out_days>=0),/*出勤天数*/
work_overtime datetime(10),/*加班时间*/
w_overtime_days int default 0 check(w_overtime_days>=0 and w_overtime_days<=31),/*加班天数*/
deduct int default 0,/*事故扣薪*/
add_money int default 0,/*加班费*/
issue_salary int(4) not null,/*应发薪水*/
iss_salary int(4) not null)/*实发薪水*/
/*建立部门表*/
create table department
(department_no char(8) primary key,/*部门编号*/
department_name char(15) not null,/*部门名称*/
depart_manage char(6) not null,/*部门经理*/
depart_people int(6)/*部门人数*/
③添加记录
insert into department
values('071011','A部门','王经理',100);
insert into department
values('071012','B部门','李经理',200);
insert into department
values('071013','C部门','张经理',100);
insert into staff
values('0610','李明','男','本科','071011','A部门');
insert into staff
values('0613','张三','男','专科','071011','A部门');
insert into staff
values('0611','刘丽','女','本科','071012','B部门');
insert into staff
values('0612','张新','男','本科','071013','C部门');
insert into salary
values('0610',3000,100,30,'2011-10-8',2,50,0,3000,3200);
insert into salary
values('0611',3000,0,20,'',0,0,500,3000,2500);
insert into salary
values('0612',3000,100,31,'2011-10-10',1,50,0,3000,3150);
四、功能处理
查询
① 表查询
select * from department /*查询部门表*/
select * from staff /*查询职工表*/
select * from salary /*查询工资表*/
② 数据查询
select salary.staff_no,staff_name,issue_salary,iss_salary
from salary,staff
where iss_salary>3000 and salary.staff_no=staff.staff_no
order by salary.staff_no
select staff_no,staff_name from staff
where staff_name like '刘%';
2、数据更新
① 插入(前面已插入)
② 修改
update salary
set iss_salary =1.2*iss_salary
where iss_salary<2600;
③ 删除
delete from staff
where enducational='专科';
3.索引
① 建立索引
create index j
on salary(staff_no,issue_salary,iss_salary)
create unique index index_staff
on staff(staff_name)
create unique index index_depart
on department(depart_people)
② 查询索引
exec sp_helpindex salary
exec sp_helpindex staff
exec sp_helpindex department
③ 修改索引
exec sp_rename 'salary.j','salary_index'
④ 删除索引
drop index index
4.视图
① 创建视图
create view table_salary(staff_no ,staff_name,issue_salary,iss_salary)
as select salary.staff_no,staff_name,issue_salary,iss_salary
from salary,staff
where salary.staff_no=staff.staff_no
② 查找视图
select * from table_salary
③/*修改视图*/
Alter view table_salary
(staff_no ,staff_name ,department_name,issue_salary,iss_salary)
as select salary.staff_no,staff_name,department_name,issue_salary,iss_salary
from salary,staff
where salary.staff_no=staff.staff_no;
④ 删除视图
drop view table_salary
5.存储过程
① 创建存储过程。
create procedure pro_staff
(@staff_no char(10),
@staff_name char(25),
@staff_sex char(25),
@enducational char(10),
@department_no char(8),
@department_name char(15))
as
insert into staff values
(@staff_no,@staff_name,@staff_sex,@enducational,@department_no,@department_name)
update department
set depart_people=depart_people+1
where department_no=@department_no
create procedure pro_salary
as
(@m_salary int,
@allowance int,
@add_money int,
@deduct int
)
as
update salary
set iss_salary = (@m_salary + @allowance+@add_money- @deduct )
where m_salary=@m_salary and allowance=@allowance and add_money=@add_money and deduct=@deduct
② 查看存储过程
exec sp_helptext pro_staff
exec sp_helptext pro_salary
③ 执行存储过程
exec pro_staff @staff_no='0614',@staff_name='王敏',@staff_sex='女', @enducational='本
科',@department_no='071011', @department_name='A部门';
④删除存储过程
drop procedure pro_staff
6.触发器
① 创建触发器
create trigger m
on salary
for update
as
if update(m_salary)
begin
rollback transaction
print'月薪不能修改,请联系财务科'
end
CREATE TRIGGER TRI_salary
ON salary
FOR update,insert
AS
BEGIN
update salary set add_money=(w_overtime_days*50)
update salary set issue_salary = m_salary
update salary set iss_salary = (m_salary+allowance+add_money - deduct )
END
create trigger tri_department
on department
for insert
as
declare @staff_no char(8)
declare @department_no char(15)
update department
set depart_people=depart_people+1
where department_no=@department_no
create trigger tri_change
on staff
for delete
as
begin
delete
from salary
where salary.staff_no=any(select staff_no from deleted)
update department
set depart_people=depart_people-1
where department_no=any(select department_no from deleted)
end
② 触发器的删除
drop trigger tri_department;
7.用户与权限
/*创建登陆账号*/
exec sp_addlogin 'zhangsan','1234','salary_manage',null
/*把用户加入到数据库中*/
exec sp_adduser 'zhangsan'
/*删除登陆账号*/
exec sp_droplogin 'zhangsan'
/*系统权限*/
grant create table
to zhangsan
/*收回系统权限*/
revoke create table
from zhangsan
/*对象权限*/
grant all
on staff
to zhangsan
with grant option
grant select
on salary
to public
/*收回系对象权限*/
revoke select on salary
from zhangsan
五.实验
总结
初级经济法重点总结下载党员个人总结TXt高中句型全总结.doc高中句型全总结.doc理论力学知识点总结pdf
本
报告
软件系统测试报告下载sgs报告如何下载关于路面塌陷情况报告535n,sgs报告怎么下载竣工报告下载
主要介绍的是对自建的一个工资管理系统数据库,利用在数据库中的表、存储过程、视图、约束等组合,设计出比较实用的应用软件代码;对表中的信息能够进行简单的查询,子查询,视图的创建、修改与删除,与约束的创建,存储过程与触发器的创建与删除等基本操作,加深对SQL Server数据库的进一步研究。
通过这次实训,是我对SQL 有了进一步了解,虽然在此期间遇到过麻烦,但通过查阅资料与尝试解决问
题
快递公司问题件快递公司问题件货款处理关于圆的周长面积重点题型关于解方程组的题及答案关于南海问题
,使我更加了解SQL的基础知识,从中学到了新知识。
六.心得体会
通过这次的课程设计实验,我发现自己对数据库课程的兴趣有了很大提高,而且对课本的知识更加的了解并有了一定的掌握,通过实验我懂得了如何创建索引、视图、存储过程以及触发器。以前不懂为何要创建触发器、视图等,现在终于知道它们的优点了。
在自己没做数据库课程设计以前,总是觉得自己什么都不懂什么都不会,但是现在做出来了,所以我觉得自己还是有能力做一些实际操作方面的东西。我相信以后通过自己自学其它课程,我一定会做出一个更好的数据库。
七、参考资料
1.陈志泊编。数据库原理与应用教程(第二版)。人民邮电出版社
职工
属于
部门
职工姓名型
性别
学历
职工号
部门编号
部门名称
部门名称
部门经理
部门人数
部门编号
获得
工资
应发薪水
事故扣薪
实发薪水
加班天数
加班时间
职工号
月薪
津贴
出勤天数
加班费