【正文】
delete cascade on update cascade )。例如當(dāng)在訂單的中只要知道訂單的編號(hào),就可以知道訂單的產(chǎn)品的名字,產(chǎn)品的數(shù)量(產(chǎn)品的信息),雇員的信息,客戶(hù)的信息。 參考資料表1 參考資料表資料名稱(chēng)作者文件編號(hào)、版本《數(shù)據(jù)庫(kù)系統(tǒng)概論》王珊、薩師煊2006年5月第4版《數(shù)據(jù)庫(kù)設(shè)計(jì)入門(mén)經(jīng)典》鮑威爾2007年3月第1版《數(shù)據(jù)庫(kù)原理》克羅恩科2005年6月第1版 業(yè)務(wù)描述銷(xiāo)售訂單數(shù)據(jù)庫(kù)管理系統(tǒng)的總目標(biāo)是:在計(jì)算機(jī)網(wǎng)絡(luò),數(shù)據(jù)庫(kù)和先進(jìn)的開(kāi)發(fā)平臺(tái)上,利用現(xiàn)有的軟件,配置一定的硬件,開(kāi)發(fā)一個(gè)具有開(kāi)放體系結(jié)構(gòu)的、易擴(kuò)充的、易維護(hù)的、具有良好人機(jī)交互界面的銷(xiāo)售訂單數(shù)據(jù)庫(kù)管理系統(tǒng),實(shí)現(xiàn)訂單的下發(fā),數(shù)據(jù)的查詢(xún)刪除和修改。 需求分析本銷(xiāo)售訂單數(shù)據(jù)庫(kù)管理系統(tǒng)的需求如下,首先在供應(yīng)商表、供應(yīng)表、產(chǎn)品表、訂購(gòu)表、訂單表、客戶(hù)表、雇員表的基本表上建立增、刪、改、查的存儲(chǔ)過(guò)程。在訂購(gòu)的表中知道訂單號(hào)就可以知道訂單中產(chǎn)品的數(shù)量。 表[4]:[ orders表](訂單表)表名orders(訂單表)數(shù)據(jù)庫(kù)用戶(hù)sa主鍵o_number其他排序字段無(wú)索引字段無(wú)序號(hào)字段名稱(chēng)數(shù)據(jù)類(lèi)型(精度范圍)允許為空Y/N唯一Y/N區(qū)別度默認(rèn)值約束條件/說(shuō)明1o_numberchar(32)NY高無(wú)主鍵/訂單號(hào)2timesdateNN低無(wú)訂單日期3e_numberchar(32)YN中無(wú)雇員號(hào)4c_numberchar(32)NN高無(wú)客戶(hù)號(hào)5pnintYN中無(wú)產(chǎn)品種類(lèi)數(shù)sql腳本建立訂單表create table orders 訂單表( o_number char(32) not null primary key, empl_number char(32) not null, c_number char(32) not null, times date, pn int,產(chǎn)品總數(shù) foreign key(c_number)references customer(c_number) on delete cascade on update cascade, foreign key(empl_number)references employee(empl_number) on delete cascade on update cascade )。建立一張訂單視圖信息的視圖目的:用來(lái)查詢(xún)每個(gè)客戶(hù)下的訂單數(shù)和用來(lái)查找下訂單數(shù)最多的客戶(hù)。該訂單不存在39。該客戶(hù)不存在39。39。 elseif exists ( select * from po where p_number=pnumber and o_number =onumber ) print39。 exec procedure_update_suply 39。 else delete from Suppliers where S_number =number 。你輸入的客戶(hù)不存在39。圖16 更新客戶(hù)信息圖1刪除客戶(hù)信息功能:刪除客戶(hù)信息目的:存儲(chǔ)產(chǎn)品的操作意義:下次重復(fù)同樣的動(dòng)作時(shí),可直接執(zhí)行存儲(chǔ)過(guò)程,簡(jiǎn)化操作步驟create procedure procedure_delet_coustome刪除客戶(hù)信息 number char(32) as if not exists(select * from customer where c_number=number ) print39。 exec procedure_update_emp 39。你輸入的雇員不存在39。else if not exists ( select * from customer where c_number=umber ) print39。end。其方法是由系統(tǒng)提供一定的方式讓用戶(hù)標(biāo)識(shí)自己的名字或身份。12339。fanyangcong39。系統(tǒng)每天凌晨自動(dòng)更新系統(tǒng),刪除未銷(xiāo)卡記錄數(shù)據(jù)庫(kù)維護(hù)計(jì)劃非常強(qiáng)大,里面有各式各樣對(duì)數(shù)據(jù)庫(kù)的維護(hù)/備份操作,每樣都可以設(shè)定不同的Schedule,當(dāng)然,每設(shè)定一項(xiàng),在JOB里面就會(huì)自動(dòng)多出來(lái)一條。附錄create table Suppliers供應(yīng)商表( S_number char(32) not null primary key, S_name char(32) not null, S_adress char(32) not null, S_telnub char(32) not null, )。00139。00239。00339。00439。00539。00639。00739。00839。00939。01039。011139。01239。該用戶(hù)不存在39。 exec procedure_update_suply 39。你輸入的供應(yīng)商不存在39。 exec procedure_delet_supply 39。,39。王小39。王小39。謝比39。舒適39。范洋蔥39。凌柳39。琉球39。李丹39。王五39。李四39。張山39。熊富39。凌章39。create table orders 訂單表( o_number char(32) not null primary key, empl_number char(32) not null, c_number char(32) not null, times date, pn int,產(chǎn)品總數(shù) foreign key(c_number)references customer(c_number) on delete cascade on update cascade, foreign key(empl_number)references employee(empl_number) on delete cascade on update cascade )。系統(tǒng)每天凌晨更新后,自動(dòng)備份數(shù)據(jù)庫(kù)。sysadmin39。xx39。還可以通過(guò)建立視圖來(lái)控制對(duì)數(shù)據(jù)的訪(fǎng)問(wèn)。當(dāng)用戶(hù)退訂單的時(shí)候觸發(fā)庫(kù)存量加上訂單退出時(shí)的產(chǎn)品數(shù)量。else if not exists ( select * from employee where empl_number=enumber ) print39。 exec procedure_delet_emp 39。,39。 else delete from customer where c_number=number 。 exec procedure_update_coustome 39。11139。,39。 else if exists ( select * from product where p_inventoryquany and p_number=pnumber ) print39。圖8 插入供應(yīng)商圖插入訂單信息功能:插入訂單信息目的:存儲(chǔ)插入訂單信息的操作意義:下次重復(fù)同樣的動(dòng)作時(shí),可直接執(zhí)行存儲(chǔ)過(guò)程,簡(jiǎn)化操作步驟create procedure procedure_insert_orders插入訂單信息o_number char(32),empl_number char(32),c_number char(32),time date,pn intasif exists ( select * from orders where o_number=o_number ) print39。圖5 查詢(xún)雇員信息圖6更新客戶(hù)信息功能:更新客戶(hù)信息目的:存儲(chǔ)更新客戶(hù)信息的操作意義:下次重復(fù)同樣的動(dòng)作時(shí),可直接執(zhí)行存儲(chǔ)過(guò)程,簡(jiǎn)化操作步驟create procedure update_coustome更新客戶(hù)信息 number char(32), tell char(32), address char(32) as if not exists(select * from customer where c_number=number ) print39。drop view view_orders。意義:有利于數(shù)據(jù)的檢索。 表[6]:[ employee表](雇員表)表名employee(雇員表)數(shù)據(jù)庫(kù)用戶(hù)sa主鍵e_number其他排序字段無(wú)索引字段無(wú)序號(hào)字段名稱(chēng)數(shù)據(jù)