【正文】
員工編號))1建立工資表create table 工資( 工資編號 char(6) primary key, 員工編號 char(4) not null, 基本工資 money not null, 罰款 money, 獎金 money, 結(jié)算工資 money, 起始時間 datetime, 截止時間 datetime, 發(fā)信日期 datetime, foreign key(員工編號) references 員工(員工編號))第5章 數(shù)據(jù)庫完整性設(shè)計 主鍵及唯一性索引表名主鍵建立唯一性索引員工(員工編號)create index 員工_學(xué)歷_index on 員工(學(xué)歷)個人經(jīng)歷(年份,員工編號)create index 個人經(jīng)歷_任職經(jīng)歷_index on 個人經(jīng)歷(任職經(jīng)歷)家庭關(guān)系(關(guān)系編號)create index 家庭關(guān)系_親屬關(guān)系_index on 家庭關(guān)系(親屬關(guān)系)管理人員(管理員帳號)create index 管理人員_index on 管理人員(級別)出勤(出勤號)create index 出勤_上班日期_index on 出勤(上班日期)刷卡機(刷卡機號)create index 刷卡機_index on 刷卡機(刷卡機號)部門(部門號)create index 部門_領(lǐng)導(dǎo)人員_index on 部門(領(lǐng)導(dǎo)人員)職位調(diào)動(調(diào)動編號)create index 職務(wù)調(diào)動_調(diào)動前職務(wù)_index on 職位調(diào)動(調(diào)動前職務(wù))獎懲記錄(獎懲編號)create index 獎懲記錄_獎懲類型_index on 獎懲記錄(獎懲類型)請假記錄(請假編號)create index 請假記錄_請假天數(shù)_index on 請假記錄(請假天數(shù))工資(工資編號)create index 工資_基本工資_index on 工資(基本工資) 參照完整性設(shè)計 將個人經(jīng)歷表中,將“員工編號”設(shè)置為表的外鍵?!heck約束員工表中,將性別進行check約束:check(性別 in(39。)) 觸發(fā)器設(shè)計在職位調(diào)動表中,建立更改員工職務(wù)的觸發(fā)器create trigger trigger_職務(wù)修改 on 職位調(diào)動 for insertasdeclare new_員工編號 char(10),new_調(diào)動后職務(wù) char(10)select new_員工編號=員工編號,new_調(diào)動后職務(wù)=調(diào)動后職務(wù) from insertedupdate 員工 set 職務(wù)=new_調(diào)動后職務(wù) where 員工編號=new_員工編號在員工表中,建立插入或刪除員工信息時,修改其相應(yīng)部門的人數(shù)create trigger trigger_增加員工 on 員工 for insertasdeclare new_部門號 char(4),new_員工人數(shù) intselect new_部門號=部門號 from insertedselect new_員工人數(shù)=員工人數(shù) from 部門update 部門 set 員工人數(shù)=new_員工人數(shù)+1 where 部門號=new_部門號create trigger trigger_減少員工 on 員工 for deleteasdeclare new_部門號 char(4),new_員工人數(shù) intselect new_部門號=部門號 from deletedselect new_員工人數(shù)=員工人數(shù) from 部門update 部門 set 員工人數(shù)=new_員工人數(shù)1 where 部門號=new_部門號在職位調(diào)動表中,當插入信息時,修改調(diào)動部門的人數(shù)信息create trigger trigger_部門人數(shù)修改 on 職位調(diào)動 for insertasdeclare new_前部門號 char(10),new_現(xiàn)部門號 char(10),new_調(diào)動后部門號 char(4),new_員工人數(shù) int,new_調(diào)動前部門號 char(4)select new_現(xiàn)部門號=調(diào)動后部門號,new_前部門號=調(diào)動前部門號 from insertedselect new_員工人數(shù)=員工人數(shù) from 部門update 部門 set 員工人數(shù)=new_員工人數(shù)+1 where 部門號=new_現(xiàn)部門號update 部門 set 員工人數(shù)=new_員工人數(shù)1 where 部門號=new_前部門號在獎懲記錄表中,更新獎懲信息時,修改工資表中的對應(yīng)的獎金、罰款create trigger trigger_獎金 on 獎懲記錄 for insertasdeclare 獎金 money,獎懲類型 char(2),員工編號 char(4)select 獎金=獎懲金額,員工編號=員工編號,獎懲類型=獎懲類型 from insertedbegin if(獎懲類型=39。通過這次課程設(shè)計發(fā)現(xiàn)這其中需要的很多知識我們沒有接觸過,去圖書館查資料的時候發(fā)現(xiàn)我們前邊所學(xué)到的僅僅是皮毛。我經(jīng)歷了需求分析、概念結(jié)構(gòu)設(shè)計、邏輯結(jié)構(gòu)設(shè)計、物理結(jié)構(gòu)設(shè)計、數(shù)據(jù)庫實施等過程,對數(shù)據(jù)庫的安全性、完整性層層把握,完善數(shù)據(jù)庫的設(shè)計。