数据库课程设计工资管理系统_第1页
数据库课程设计工资管理系统_第2页
数据库课程设计工资管理系统_第3页
数据库课程设计工资管理系统_第4页
数据库课程设计工资管理系统_第5页
已阅读5页,还剩12页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、课程设计要求:1对各个系统进行系统功能需求分析2.数据库设计分析阶段,进行详细的数据库需求分析,进行概念数据库的设计,画 出数据库的E-R图(局部和整体E-R图)3.设计出详细的逻辑数据库结构,将各个实体和联系转化为相应的二维表即尖系模 式,指定各个尖系的主尖键字和外部尖键字,并对各个尖系的约束加以限定4.通过企业管理器或是查询分析器实现各个二维矢系(建议最好用SQL代码实现),要求建立相矢的索引5.根据系统功能需求设计相应的查询视图6.要求根据系统功能需求建立存储过程7根据功能需求建立相应的触发器以保证数据的一致f生8.通过建立用户和权限分配实现数据库一定的安全性,考虑数据库的备份与恢复 (

2、此内容选作)、需求分析企业的工资管理是公司管理的一个重要内容。随着科学技术的发展,一些公司的规模也越 来越大,职工的数量也在不断的增加,企业的管理工作也变得越来越复杂。工资管理既涉 及到企业劳动人事的管理,同时也是企业财务的重要组成部分。面对如此大的信息量,单 凭传统的表格、手工操作已不能满足实际的需要。因此,我设计工资管理系统来提高财务 管理方面的效率。通过这个系统可以使信息的管理更加规范,统计更科学。模块功能分析:1)部门模块:用来管理部门;2 )工资模块:用来管理员工的工资;3)职工模块:用来管理工厂的职工信息;=概念结构设计经分析本系统的e-r图如下:三、逻辑结构设计职I:1工资管理基

3、本信息表 department (部门)列名数据 类型长度是否 允许 空备注department no(部门号)char8否主尖 键字department name (部门名)char15否depart manage(部门亘理)char6否depart people(部门夭数)int6否staff (职工)列名数据 类型长度是否 允许 空备注staff_no (职工号)char10否主矢 键字staff name(职壬姓名)char20否staff sex(职亍姓别)char25否默认” 男”Enducational(学历)char10否dapartment no (部门号)char8否dep

4、artment name (部门名称)char15否salary (工资)列命数长度是否允许空备注staff no(职工工号)char10否外键m salary (月薪)int6否默认3000Allowance (津贴)int10是默认0out days(嶷天数)int2否out_days=0work overtim (加i班时间)datetime10是w overtime days (予a班天数)int2否默认ow_overtime_days=0 andw overtime days=31Deduct (事故扣薪)int4否默认oissue salary(应发薪水)int4否iss sala

5、ry(实发薪水)Int4否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=vd:salary_manage_datadf;size=25, maxsize=35,filegrowth=5)/建立职工表 / create table staff(staff_no char(10) primary key,/*职工工号 */staff

6、_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(s

7、taff_no)5职广工工号 */m_salary int default 3000,广月薪 */allowance int default 0,广津贝占 */out_days int not null check(out_days=0)5出广勤天数 */work_overtime datetime(10),/*加班时间 */w_overtime_days int default 0 check(w_overtime_days=0 andw_overtime_days3000 and salary,staff_no=staff.staff_no order bysalary.staff_nos

8、elect staff_no5staff_name from staff where staff_name like 刘 %*;2、数据更新 插入(前面已插入) 修改update salaryset iss_salary =1.2*iss_salary where iss_salary2600; 删除delete from staffwhere enducational=f 科3 索引 建立索引create index jon salary(staff_no,issue_salary5iss_salary)create unique index index_staff on staff(sta

9、ff_name)create unique index index_depart on department(depart_people) 查询索引exec sp_helpindex salaryexec sp_helpindex staffexec sp_helpindex department 修改索引exec sp_rename salary.jVsalaryJndex 删除索引drop index index4 视图创建视图 create view table_salary(staff_no 5staff_name,issue_salary5iss_salary) as select

10、salary.staff_no,staff_name5issue_salary5iss_salary from salary,staffwhere salary.staff_no=staff.staff_no 查找视图 select * from table_salary 广修改视图*/Alter view table_salary(staff_no 5staff_name 5department_name5issue_salary5iss_salary)as selectsalary.staff_no5staff_name5department_name5issue_salary5iss_s

11、alary from salary,staffwhere salary.staff_no=staff.staff_no;删除视图 drop view table_salary5 存储过程创建存储过程。create procedure pro_staff(staff_no char(10)5staff_name char(25)5staff_sex char(25),enducational char(10)5department_no char(8), department_name char(15) as insert into staff values (staff_no3staff_na

12、me5staff_sex5enducational5department_n o,department_name)update departmentset depart_people=depart_people+1where department_no=department_no create procedure pro_salary as(m_salary int, allowance int, add_money int, deduct intasupdate salary set iss_salary = (m_salary + allowance+add_money(deduct)wh

13、ere m_salary=m_salary and allowance=allowance and add_money=add_money and deduct=deduct 查看存储过程 exec sp_helptext pro_staff exec sp_helptextpro_salary执行存储过程exec pro_staff staff_no=9614;staff_name=王敏 staff_sex=,女:enducational=本科:department_no=071011; department_name=A 咅E门 删除存储过程 drop procedure pro_staf

14、f6触发器 创建触发器 create trigger m on salary for update as ifupdate(m_salary) begin rollback transaction print* 月薪不能修改,请联 系财务科endCREATE TRIGGER TRI_salaryON salaryFOR update,insertBEGINupdate salary set add_money=(w_overtime_days*50)update salary set issue_salary = m_salaryupdate salary set iss_salary = (

15、m_salary+allowance+add_moneydeduct)ENDcreate trigger tri_departmenton departmentfor insertasdeclare 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 deleteasbegindeletefrom sala

16、rywhere salary.staff_no=any(select staff_no from deleted) update departmentset depart_people=depart_people-1where department_no=any(select department_no from deleted) end 触发器的删除 drop trigger tri_department;7用户与权限/*创建登陆账号*/exec sp_addlogin zhangsarf,1234;salary_manage;null/*把用户加入到数据库中*/ exec sp_addus

17、er hangsan*/*删除登陆账号*/exec sp_droplogin zhangsarT/*系统权限*/grant create tableto zhangsan/* 收回系统权限 */ revoke create table from zhangsan/*对象权限*/grant allon staffto zhangsanwith grant optiongrant selecton salaryto public/* 收回系对象权限 */ revoke select on salaryfrom zhangsan五实验总结 本报告主要介绍的是对自建的一个工资管理系统数据库,利用在数据库中 的表、存储过程、视图、约束等组合,设计出比较实用的应用软件代码;对表中的信息能 够进行简单的查询,子查询,视图的创建、修改与删除,与约束的创建,存储过程与触发 器的创建与删除等基本操作,加深对SQL Server数据库的进步研究。通过这次实训,是我对SQL有了进一步了解,虽然在此期间遇到过麻烦,但通过 查阅资料与尝试解决问题

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论