




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、 實(shí)驗(yàn)題目:倉庫管理系統(tǒng)數(shù)據(jù)庫的設(shè)計(jì)與實(shí)現(xiàn) 描述:設(shè)計(jì)一個(gè)倉庫管理系統(tǒng),實(shí)現(xiàn)下列功能:零件信息登記(包括種類,名稱和庫存數(shù)量等信息);零件進(jìn)庫登記(包括種類,名稱和庫存數(shù)量等信息);零件出庫登記(包括種類,名稱和庫存數(shù)量等信息);實(shí)驗(yàn)代碼和實(shí)驗(yàn)結(jié)果和實(shí)驗(yàn)總結(jié): 在實(shí)驗(yàn)代碼中分別應(yīng)用了相關(guān)實(shí)驗(yàn)操作的結(jié)果,通過上一個(gè)結(jié)果截圖與其隨后的結(jié)果截圖和相關(guān)代碼對(duì)比課已看出相關(guān)代碼的作用(主要是各個(gè)觸發(fā)器的作用)。 -數(shù)據(jù)庫的創(chuàng)建create database 倉庫管理系統(tǒng)數(shù)據(jù)庫on primary( name = 倉庫管理系統(tǒng)數(shù)據(jù)庫_data, filename =E:倉庫管理系統(tǒng)數(shù)據(jù)庫_Data.MDF
2、, size = 50, maxsize = 500, filegrowth = 5)log on ( name = 倉庫管理系統(tǒng)數(shù)據(jù)庫_log, filename =E:倉庫管理系統(tǒng)數(shù)據(jù)庫_Log.LDF, size = 10, maxsize = 200, filegrowth = 5)-數(shù)據(jù)表的創(chuàng)建use 倉庫管理系統(tǒng)數(shù)據(jù)庫create table 零件信息登記( 零件代號(hào) char(10) primary key, 名稱 char(10) not null, 種類 char(10) not null , 價(jià)格 numeric(10,2) not null, 庫存數(shù)量 int defau
3、lt 0)create table 零件進(jìn)庫登記( 零件代號(hào) char(10) foreign key references 零件信息登記(零件代號(hào)) , 進(jìn)貨代號(hào) int , 進(jìn)貨人工作號(hào) char(10), 名稱 char(10) not null, 種類 char(10) not null , 價(jià)格 numeric(10,2) not null, 進(jìn)庫數(shù)量 int not null default 0, 存放位置 char(10) not null, 進(jìn)庫時(shí)間 datetime ,primary key (零件代號(hào),進(jìn)貨代號(hào))create table 零件出庫登記( 零件代號(hào) char(
4、10) foreign key references 零件信息登記(零件代號(hào)) , 出貨代號(hào) int , 出貨人工作號(hào) char(10) not null, 名稱 char(10) not null, 種類 char(10) not null , 價(jià)格 numeric(10,2) not null, 出庫數(shù)量 int not null default 0, 取貨單號(hào) char(10) not null, 出庫時(shí)間 datetime , primary key(零件代號(hào),出貨代號(hào)) -通過存儲(chǔ)過程來實(shí)現(xiàn)表中數(shù)據(jù)的輸入create procedure pro_ins1(no char(20), n
5、ame char(20), class char(20), s numeric(10,2), num int)asinsert into 零件信息登記values(no, name, class, s, num)create procedure pro_ins2(no char(20),jno int,wno char(10), name char(20), class char(20), s numeric(10,2), num int, m char(20) )asdeclare time datetimeset time = getdate()insert into 零件進(jìn)庫登記valu
6、es(no, jno ,wno ,name, class, s, num, m, time)create procedure pro_ins3(no char(20),jno int,wno char(10), name char(20), class char(20), s numeric(10,2), num int, m char(20)asdeclare time datetimeset time = getdate()insert into 零件出庫登記values(no,jno ,wno , name, class, s, num, m, time)create procedure
7、 pro_selectasbeginselect * from 零件信息登記select *from 零件進(jìn)庫登記select *from 零件出庫登記end-通過第一個(gè)存儲(chǔ)過程來實(shí)現(xiàn)零件的信息登錄exec pro_ins1 ,螺栓,金屬,5.2,50exec pro_ins1 ,龍頭,金屬,9.3,70exec pro_ins1 ,水杯,塑料,36.8,80exec pro_ins1 ,書包,布料,52,150exec pro_ins1 ,電視,電子,4000,50-當(dāng)零件進(jìn)庫時(shí)通過下面的觸發(fā)器來實(shí)現(xiàn)數(shù)據(jù)的完整性create trigger tri_統(tǒng)一零件管理on 零件進(jìn)庫登記instea
8、d of insertasbegin if(exists (select 零件代號(hào) from 零件信息登記 where 零件代號(hào) = (select 零件代號(hào) from inserted) beginprint 在庫里已經(jīng)此零件,并且放置成功update 零件信息登記set 庫存數(shù)量 = 庫存數(shù)量 + (select 進(jìn)庫數(shù)量 from inserted )where 零件代號(hào) = (select 零件代號(hào) from inserted) end if(not exists (select 零件代號(hào) from 零件信息登記 where 零件代號(hào) = (select 零件代號(hào) from inser
9、ted) beginprint 庫里不存在此零件,已經(jīng)把此零件加入零件信息登記中insert into 零件信息登記select 零件代號(hào),名稱,種類,價(jià)格,進(jìn)庫數(shù)量from insertedinsert into 零件進(jìn)庫登記select 零件代號(hào),進(jìn)貨代號(hào),進(jìn)貨人工作號(hào),名稱,種類,價(jià)格,進(jìn)庫數(shù)量,存放位置,進(jìn)庫時(shí)間from inserted endEnd-對(duì)觸發(fā)器“tri_統(tǒng)一零件管理”的相關(guān)驗(yàn)證信息exec pro_selectexec pro_ins2 ,1120,c2011a,龍頭,金屬,9.3,70,一排號(hào)exec pro_ins2 ,1122,c2011b,電池,金屬,8.3,
10、150,一排號(hào)exec pro_ins2 ,1132,c2011c,水桶,塑料,7.9,130,二排號(hào)exec pro_ins2 ,1134,a2012d,飲料,食品,54,200,二排號(hào)exec pro_select-drop trigger tri_統(tǒng)一零件出庫-當(dāng)零件出庫時(shí)通過下面的觸發(fā)器來實(shí)現(xiàn)數(shù)據(jù)的完整性create trigger tri_統(tǒng)一零件出庫on 零件出庫登記instead of insertasif exists(select 零件代號(hào) from 零件信息登記 where 零件代號(hào) = (select 零件代號(hào) from inserted)begin print 次零件存
11、在 if exists(select 零件代號(hào) from 零件信息登記 where 零件代號(hào) = (select 零件代號(hào) from inserted) and 庫存數(shù)量=(select 出庫數(shù)量 from inserted) begin begin print 零件庫存夠出售 update 零件信息登記 set 庫存數(shù)量 = 庫存數(shù)量 -(select 出庫數(shù)量 from inserted) where 零件代號(hào) = (select 零件代號(hào) from inserted) endinsert into 零件出庫登記select 零件代號(hào),出貨代號(hào),出貨人工作號(hào),名稱,種類,價(jià)格,出庫數(shù)量,取
12、貨單號(hào),出庫時(shí)間from inserted end else begin print 零件庫存數(shù)量不夠,不能出售! end endelsebegin print 倉庫里沒有此零件,請(qǐng)通知公司end-對(duì)觸發(fā)器“tri_統(tǒng)一零件管理”的相關(guān)驗(yàn)證信息exec pro_ins3 ,1120,f112a,龍頭,金屬,9.3,10,東華理工 exec pro_ins3 ,1143,f113a,書包,布料,52,1000,南昌exec pro_ins3 ,1220,f114b,鉛筆,用具,9.3,10,江西exec pro_ins3 ,1128,g112a,鎖,金屬,9.3,10,云南exec pro_se
13、lect-對(duì)“零件進(jìn)庫登記”數(shù)據(jù)更改是觸發(fā)對(duì)“零件信息登記”的更改-同時(shí)防止對(duì)“零件進(jìn)庫登記”信息的非法更改 create trigger tri_up零件進(jìn)庫on 零件進(jìn)庫登記after updateasif exists(select 零件代號(hào) from deleted where 零件代號(hào)=(select 零件代號(hào) from inserted) and 進(jìn)貨代號(hào)=(select 進(jìn)貨代號(hào) from inserted) and 進(jìn)庫數(shù)量(select 進(jìn)庫時(shí)間 from inserted) update 零件信息登記 set 庫存數(shù)量 = 庫存數(shù)量+(select 進(jìn)庫數(shù)量 from in
14、serted)-(select 進(jìn)庫數(shù)量 from deleted)else if exists(select 零件代號(hào) from deleted where 零件代號(hào)=(select 零件代號(hào) from inserted) and 進(jìn)貨代號(hào)=(select 進(jìn)貨代號(hào) from inserted) and 進(jìn)庫數(shù)量=(select 進(jìn)庫時(shí)間 from inserted) update 零件信息登記 set 庫存數(shù)量 = 庫存數(shù)量+(select 進(jìn)庫數(shù)量 from inserted)-(select 進(jìn)庫數(shù)量 from deleted) else beginprint 修改不正確 end-對(duì)觸
15、發(fā)器“tri_up零件進(jìn)庫”的相關(guān)驗(yàn)證信息 update 零件進(jìn)庫登記set 進(jìn)庫數(shù)量= 120where 零件代號(hào)=and 進(jìn)貨代號(hào)=1120update 零件進(jìn)庫登記set 進(jìn)庫數(shù)量 = 5000where 零件代號(hào)= and 進(jìn)貨代號(hào)=2187exec pro_select-對(duì)“零件出庫登記”數(shù)據(jù)更改是觸發(fā)對(duì)“零件信息登記”的更改-同時(shí)防止對(duì)“零件進(jìn)庫登記”信息的非法更改create trigger tri_up零件出庫on 零件出庫登記after updateasif exists(select 零件代號(hào) from deleted where 零件代號(hào)=(select 零件代號(hào) fro
16、m inserted) and 出貨代號(hào) = (select 出貨代號(hào) from inserted) and 出庫數(shù)量(select 出貨代號(hào) from inserted) update 零件信息登記 set 庫存數(shù)量 = 庫存數(shù)量+(select 出庫數(shù)量 from inserted)-(select 出庫數(shù)量 from deleted) else beginprint 修改不正確 end-對(duì)觸發(fā)器“tri_up零件出庫”的相關(guān)驗(yàn)證信息update 零件出庫登記set 出庫數(shù)量 = 20where 零件代號(hào)= and 出貨代號(hào) = 1120update 零件出庫登記set 出庫數(shù)量 = 120where 零件代號(hào)= update 零件出庫登記set 出貨代號(hào) = 620where 零件代號(hào)= exec pro_select-一下代碼為創(chuàng)建相關(guān)規(guī)則、試圖、用戶并授權(quán),來完成數(shù)據(jù)庫的完整性和安全性-相關(guān)的驗(yàn)證信息省略create rule ru_零件數(shù)量as num=0 exec sp_bindrule ru_零件數(shù)量,零件信息登記.庫存數(shù)量 exec sp_bindrule ru_零件數(shù)量,零件進(jìn)庫登記.進(jìn)庫數(shù)量 exec sp_bindrule ru_零件數(shù)量,零件出庫登記.出庫數(shù)量 exec pro_ins1 ,龍頭,金屬,9.3,-10 exec pro_ins2 ,龍頭,
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2026年高考語文作文模擬題4篇
- 2025年晉中市稅務(wù)系統(tǒng)遴選面試真題帶詳解含答案
- 綿竹市文職輔警招聘考試真題
- 臨沂市費(fèi)縣文職輔警招聘考試真題
- 海洋企業(yè)品牌形象塑造
- 老年護(hù)理講課課件
- 老年護(hù)理便秘課件教學(xué)
- 老年健康講座課件
- 2025年百貨商業(yè)市場調(diào)查報(bào)告
- 2025年安全門行業(yè)市場趨勢分析報(bào)告
- 2025年重癥醫(yī)學(xué)科ICU護(hù)理信息化建設(shè)計(jì)劃
- 結(jié)直腸癌腹膜轉(zhuǎn)移診治專家共識(shí)(2025版)解讀
- 風(fēng)電運(yùn)維安全培訓(xùn)內(nèi)容課件
- 保密人員面試題及答案
- 軟件質(zhì)量標(biāo)準(zhǔn)與檢驗(yàn)指南
- DB35T 2192-2024河湖智慧監(jiān)管體系構(gòu)建導(dǎo)則
- 無人機(jī)課程培訓(xùn)大綱
- 車間洗手消毒管理制度
- 腹膜透析飲食知識(shí)
- 感染性疾病分子診斷試劑行業(yè)深度調(diào)研及發(fā)展戰(zhàn)略咨詢報(bào)告
- ISO45001 2024職業(yè)健康安全管理體系要求及使用指南
評(píng)論
0/150
提交評(píng)論