资源描述:
《人力资源管理数据库设计与实现》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、模块一:Createdatabasestaff2createtableinformation(yidintidentity(1,1)primarykey,info_namechar(20),info_sexchar(2),info_cardchar(20),info_statechar(25),info_adresschar(50),);select*frominformationcreatetablewage(yidtinyintidentity(1,1)primarykey,wage_name_idintnotnull,wage_totlefloat(20),/*本月总工资*/wage
2、_payfloat(15),/*本月已发工资*/wage_pay_datechar(15)notnull);select*fromwageCreatetablestate(state_idtinyintidentity(1,1)primarykey,state_namevarchar(16)UNIQUE);select*fromstate模块二/*查询员工基本信息的视图*/Createviewinformation_view(info_id,info_name,info_sex,info_card,info_state,info_adress)asselect*frominformatio
3、n/*查询员工工资的视图*/createviewwage(wage_id,wage_name,wage_totle,wage_pay,wage_pay_date)asselect*fromwage/*查询员工等级表*/createviewstate(state_id,state_name)asselect*fromstate/*建立索引*/createuniqueindexinfo_nameindexoninformation(info_name)execsp_helpindexinformation模块四:/*建立触发器*/当删除information中某项基本信息,触发wage表,删除
4、相应的记录createtriggerinformation_deleteoninformationfordeleteasdeclare@idintselect@id=idfromdeleteddeletewagewhereid=@id/*创建各个存储过程*//*在information插入一条新记录*/createprocedureinfo_pro2(@idint,@namechar(20),@info_sexchar(2),@info_cardchar(20),@info_statechar(25),@info_adresschar(50))asinsertintoinformation
5、values(@id,@name,@info_sex,@info_card,@info_state,@info_adress)执行:execinfo_pro2@id=20,@name='萍媛',@info_sex='女',@info_card='536819900221',@info_state='经理',@info_adress='江西'/*创建一个查询存储过程*/createprocedureinfo_prodasselect*frominformationexecinfo_prod/*创建一个删除存储过程*/createprocedureinfo_prod3asselect*from
6、information模块五:select*fromwage/*创建一表格,用于实现工资差记录*/createtables_wage(wage_name_idchar(20),s_wagemoney)/*实现工资差的记录*/createproceduremy_pro_swageasbegindeclare@idchar(20)declaremycursorcursorforselectwage_name_idfromwageopenmycursorfetchnextfrommycursorinto@idwhile@@fetch_status=0begindeclare@wage_totle
7、money,@wage_paymoneyselect@wage_totle=wage_totle,@wage_pay=wage_payfromwagewherewage_name_id=@idinsertintos_wagevalues(@id,@wage_totle-@wage_pay)fetchnextfrommycursorinto@idendclosemycursordeallocatemycursorend/*