訂單銷(xiāo)售數(shù)據(jù)庫(kù)設(shè)計(jì)_第1頁(yè)
訂單銷(xiāo)售數(shù)據(jù)庫(kù)設(shè)計(jì)_第2頁(yè)
訂單銷(xiāo)售數(shù)據(jù)庫(kù)設(shè)計(jì)_第3頁(yè)
訂單銷(xiāo)售數(shù)據(jù)庫(kù)設(shè)計(jì)_第4頁(yè)
訂單銷(xiāo)售數(shù)據(jù)庫(kù)設(shè)計(jì)_第5頁(yè)
已閱讀5頁(yè),還剩5頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、. word 文檔五、邏輯設(shè)計(jì)5.1 er 圖5.2 關(guān)系模型供應(yīng)商 (供應(yīng)商編號(hào),名稱(chēng),地址,聯(lián)系電話(huà)) 產(chǎn)品 (產(chǎn)品編號(hào),產(chǎn)品名稱(chēng),產(chǎn)品類(lèi)別,售價(jià),出廠價(jià),存貨量) 供應(yīng) (供應(yīng)商編號(hào),產(chǎn)品編號(hào)) 訂購(gòu) (產(chǎn)品編號(hào),訂單編號(hào),數(shù)量) 客戶(hù) (客戶(hù)編號(hào),姓名,通信地址,電話(huà)) 訂單 (訂單編號(hào),日期,客戶(hù)編號(hào),雇員編號(hào)) 雇員 (雇員編號(hào),姓名,聯(lián)系電話(huà),工資) 供應(yīng)商供應(yīng)產(chǎn)品訂購(gòu)訂單管理雇員下發(fā)客戶(hù)名稱(chēng)地址聯(lián)系電話(huà)客戶(hù)編號(hào)姓名通信地址電話(huà)產(chǎn)品編號(hào)供應(yīng)商編號(hào)產(chǎn)品產(chǎn)品名稱(chēng)產(chǎn)品類(lèi)型產(chǎn)品編號(hào)訂單編號(hào)訂單編號(hào)雇員編號(hào)姓名聯(lián)系電話(huà)供應(yīng)商編號(hào)售價(jià)出廠價(jià)存貨量數(shù)量日期雇員編號(hào)工資客戶(hù)編號(hào). word 文檔

2、注:有下劃線(xiàn)的表示該屬性為主碼。六、物理設(shè)計(jì)6.1 表匯總表名功能說(shuō)明表 suppliers 供應(yīng)商表,存儲(chǔ)供應(yīng)商的編號(hào)等信息表 product 產(chǎn)品表,存儲(chǔ)產(chǎn)品的編號(hào)、數(shù)量等信息表 sp 供應(yīng)商產(chǎn)品供應(yīng)表,存儲(chǔ)供應(yīng)商所供應(yīng)的產(chǎn)品對(duì)應(yīng)信息表 orders 訂單表,存儲(chǔ)訂單的編號(hào)、日期等信息表 po 產(chǎn)品訂購(gòu)表,存儲(chǔ)產(chǎn)品訂購(gòu)的對(duì)應(yīng)信息表 employee 雇員表,存儲(chǔ)雇員的編號(hào)等信息表 customer 客戶(hù)表,存儲(chǔ)客戶(hù)的編號(hào)等信息6.2 表1: suppliers表(供應(yīng)商表 ) 表名suppliers (供應(yīng)商表)數(shù)據(jù)庫(kù)用戶(hù)sa 主鍵snumber 其他排序字段無(wú)索引字段無(wú)序號(hào)字段名稱(chēng)數(shù)據(jù)類(lèi)

3、型 (精度范圍)允許為空 y/n 唯一y/n 區(qū)別度默認(rèn)值約束條件 / 說(shuō)明1 snumber char(12) ny 高無(wú)主鍵 /供應(yīng)商號(hào)2 sname char(30) nn 中無(wú)供應(yīng)商名稱(chēng)3 saddress char(30) yn 中無(wú)供應(yīng)商地址4 stelnum int yn 高無(wú)供應(yīng)商電話(huà)sql 腳本- 建立供應(yīng)商表create table suppliers -供應(yīng)商表(snumber char(12) primary key,-供應(yīng)商編號(hào),主碼sname char(30) not null,-姓名saddress char(30), -地址stelnum int -電話(huà));.

4、word 文檔6.3 表2: product表(產(chǎn)品表 ) 表名product (產(chǎn)品表)數(shù)據(jù)庫(kù)用戶(hù)sa 主鍵pnumber 其他排序字段無(wú)索引字段無(wú)序號(hào)字段名稱(chēng)數(shù)據(jù)類(lèi)型(精度范圍)允許為空y/n 唯一y/n 區(qū)別度默認(rèn)值約束條件 /說(shuō)明1pnumber char(12) n y 高無(wú)主鍵 /產(chǎn)品編號(hào)2 pname char(30) n y 高無(wú)產(chǎn)品名稱(chēng)3 pcategory char(15) y n 低無(wú)產(chǎn)品類(lèi)別4 pprice int y n 中無(wú)產(chǎn)品售價(jià)5 pex_price real y n 中無(wú)產(chǎn)品出廠價(jià)6 pinventory real y n 中無(wú)產(chǎn)品庫(kù)存量sql 腳本- 建立產(chǎn)

5、品表create table product -產(chǎn)品表(pnumber char(12) primary key, -產(chǎn)品編號(hào) ,主碼pname char(30) not null, -產(chǎn)品名稱(chēng)pcategory char(15), -產(chǎn)品類(lèi)別 - pprice int, - 售價(jià) - pex_price real, - 出廠價(jià) - pinventory real -存貨量 - );6.4 表3: sp 表(供應(yīng)商產(chǎn)品供應(yīng)表) 表名sp(供應(yīng)商產(chǎn)品供應(yīng)表)數(shù)據(jù)庫(kù)用戶(hù)sa 主鍵snumber,pnumber 其他排序字段無(wú)索引字段無(wú)序號(hào)字段名稱(chēng)數(shù)據(jù)類(lèi)型(精度范圍)允許為空y/n 唯一y/n 區(qū)別

6、度默認(rèn)值約束條件 /說(shuō)明1 snumber char(12) n y 高無(wú)主鍵 /供應(yīng)商號(hào)2 pnumber char(12) n y 高無(wú)主鍵 /產(chǎn)品編號(hào). word 文檔sql 腳本- 建立供應(yīng)商產(chǎn)品供應(yīng)表create table sp- 供應(yīng)商供應(yīng)產(chǎn)品表- (snumber char(12),-供應(yīng)商編號(hào),外碼pnumber char(12),-產(chǎn)品編號(hào),外碼primary key(snumber,pnumber),-聯(lián)合主碼foreign key (pnumber) references product(pnumber) on delete cascade on update casc

7、ade, foreign key (snumber) references suppliers(snumber) on delete cascade on update cascade );6.5 表4: orders表(訂單表 ) 表名orders (訂單表)數(shù)據(jù)庫(kù)用戶(hù)sa 主鍵onumber 其他排序字段無(wú)索引字段無(wú)序號(hào)字段名稱(chēng)數(shù)據(jù)類(lèi)型(精度范圍)允許為空y/n 唯一y/n 區(qū)別度默認(rèn)值約束條件 /說(shuō)明1 onumber char(12) n y 高無(wú)主鍵 /訂單號(hào)2 odate date n n 低無(wú)訂單日期3 enumber char(12) y n 中無(wú)雇員號(hào)4 cnumber ch

8、ar(12) n n 高無(wú)客戶(hù)號(hào)sql 腳本- 建立訂單表create table orders-訂單表(onumber char(12)primary key,-編號(hào),主碼odate date,-日期enumber char(12),-設(shè)置雇員號(hào) ,外碼cnumber char(12),-設(shè)置客戶(hù)號(hào) ,外碼foreign key (cnumber) references customer(cnumber) on delete cascade on update cascade, foreign key (enumber) references employee(enumber) on del

9、ete cascade on update cascade );. word 文檔6.6 表5: po 表(產(chǎn)品訂購(gòu)表 ) 表名po(產(chǎn)品訂購(gòu)表)數(shù)據(jù)庫(kù)用戶(hù)sa 主鍵pnumber,onumber 其他排序字段無(wú)索引字段無(wú)序號(hào)字段名稱(chēng)數(shù)據(jù)類(lèi)型(精度范圍)允許為空y/n 唯一y/n 區(qū)別度默認(rèn)值約束條件 /說(shuō)明1 pnumber char(12) n y 高無(wú)主鍵 /產(chǎn)品號(hào)2 onumber char(12) n y 高無(wú)主鍵 /訂單號(hào)3 quantity int n n 低無(wú)訂購(gòu)產(chǎn)品數(shù)量sql 腳本- 建立產(chǎn)品訂購(gòu)表create table po-產(chǎn)品訂購(gòu)表(pnumber char(12),

10、-產(chǎn)品編號(hào)onumber char(12),-訂單編號(hào)quantity int,-產(chǎn)品數(shù)量primary key(pnumber,onumber),-聯(lián)合主碼foreign key (pnumber) references product(pnumber)-外碼on delete cascade on update cascade, foreign key (onumber) references orders(onumber)-外碼on delete cascade on update cascade ); 6.7 表6: employee表(雇員表 ) 表名employee (雇員表)數(shù)據(jù)

11、庫(kù)用戶(hù)sa 主鍵enumber 其他排序字段無(wú)索引字段無(wú)序號(hào)字段名稱(chēng)數(shù)據(jù)類(lèi)型(精度范圍)允許為空y/n 唯一y/n 區(qū)別度默認(rèn)值約束條件 /說(shuō)明1 enumber char(12) n y 高無(wú)主鍵 /雇員號(hào)2 ename char(10) n n 中無(wú)雇員名稱(chēng)3 etelnum int n y 高無(wú)雇員電話(huà)4 ewages real n n 低無(wú)雇員薪資. word 文檔sql 腳本- 建立雇員表create table employee-雇員表(enumber char(12) primary key,-編號(hào)ename char(10),- 名字etelnum int,- 電話(huà)ewages

12、 real- 工資);6.8 表7: customer表(客戶(hù)表 ) 表名customer (客戶(hù)表)數(shù)據(jù)庫(kù)用戶(hù)sa 主鍵cnumber 其他排序字段無(wú)索引字段無(wú)序號(hào)字段名稱(chēng)數(shù)據(jù)類(lèi)型(精度范圍)允許為空y/n 唯一y/n 區(qū)別度默認(rèn)值約束條件 /說(shuō)明1 cnumber char(12) n y 高無(wú)主鍵 /客戶(hù)表2 cname char(10) n n 中無(wú)客戶(hù)名稱(chēng)3 caddress char(30) y n 中無(wú)客戶(hù)地址4 ctelnum int y y 高無(wú)客戶(hù)電話(huà)sql 腳本- 建立客戶(hù)表create table customer-客戶(hù)表(cnumber char(12) primar

13、y key,-編號(hào)cname char(10),-姓名caddress char(30),- 地址ctelnum int-電話(huà));6.9 視圖的設(shè)計(jì)1、建立一張雇員信息的視圖目的:屏蔽雇員的工資信息。功能:能夠向管理員提供簡(jiǎn)明,直接的雇員信息展示。意義:有利于數(shù)據(jù)庫(kù)安全的維護(hù),防止任意修改數(shù)據(jù)庫(kù)中的雇員信息。create view view_employee-建立 employee 視圖,屏蔽工資屬性as select enumber,ename,etelnum from employee . word 文檔with check option; 2、建立一張產(chǎn)品信息的視圖目的:屏蔽產(chǎn)品的出廠價(jià)

14、信息。功能:能夠向管理員提供簡(jiǎn)明,直接的產(chǎn)品信息展示。意義:有利于數(shù)據(jù)庫(kù)安全的維護(hù),防止任意修改數(shù)據(jù)庫(kù)中的產(chǎn)品信息。create view view_producte-建立 product 視圖,屏蔽出廠價(jià)屬性as select pnumber,pname,pcategory,pprice,pinventory from view_producte with check option;6.10 存儲(chǔ)過(guò)程的設(shè)計(jì)1、查詢(xún)訂單數(shù)量功能:查詢(xún)訂單的數(shù)量目的:存儲(chǔ)查詢(xún)訂單數(shù)量的操作意義:下次重復(fù)同樣的動(dòng)作時(shí),可直接執(zhí)行存儲(chǔ)過(guò)程,簡(jiǎn)化操作步驟create procedure procedure_searc

15、hordersnum -查詢(xún)訂單的存儲(chǔ)過(guò)程as select count(*) 訂單總數(shù) - 查詢(xún)訂單數(shù)量from orders; 2、查詢(xún)客戶(hù)的訂單信息功能:查詢(xún)客戶(hù)的訂單信息目的:存儲(chǔ)查詢(xún)客戶(hù)的訂單信息的操作意義:下次重復(fù)同樣的動(dòng)作時(shí),可直接執(zhí)行存儲(chǔ)過(guò)程,簡(jiǎn)化操作步驟create procedure procedure_customerorders-查詢(xún)某個(gè)客戶(hù)訂單信息cname char(10) as select onumber,odate,enumber from orders,customer where cname like cname and customer.cnumber

16、like orders.cnumber; 3、查詢(xún)訂單最多的客戶(hù)信息功能:查詢(xún)訂單最多的客戶(hù)信息目的:存儲(chǔ)查詢(xún)訂單最多的客戶(hù)信息的操作意義:下次重復(fù)同樣的動(dòng)作時(shí),可直接執(zhí)行存儲(chǔ)過(guò)程,簡(jiǎn)化操作步驟create procedure procedure_searchmaxorders-查詢(xún)訂單最多的客戶(hù)信息as select cnumber,cname,caddress,ctelnum from orders,customer where orders.cnunmer=customer.cnunmer group by cnumber having max(cnumber); 4、查詢(xún)客戶(hù)信息功能:

17、查詢(xún)客戶(hù)信息目的:存儲(chǔ)查詢(xún)客戶(hù)信息的操作意義:下次重復(fù)同樣的動(dòng)作時(shí),可直接執(zhí)行存儲(chǔ)過(guò)程,簡(jiǎn)化操作步驟create procedure procedure_searchcustomer-查詢(xún)某客戶(hù)信息cname char(10) as . word 文檔select * from customer where cname=cname; 5、查詢(xún)雇員信息功能:查詢(xún)雇員信息目的:存儲(chǔ)查詢(xún)雇員信息的操作意義:下次重復(fù)同樣的動(dòng)作時(shí),可直接執(zhí)行存儲(chǔ)過(guò)程,簡(jiǎn)化操作步驟create procedure procedure_searchemployee-查詢(xún)某雇員信息ename char(10) as sele

18、ct * from employee where ename=ename; 6、查詢(xún)某訂單對(duì)應(yīng)的產(chǎn)品信息功能:查詢(xún)某訂單對(duì)應(yīng)的產(chǎn)品信息目的:存儲(chǔ)查詢(xún)某訂單對(duì)應(yīng)的產(chǎn)品信息的操作意義:下次重復(fù)同樣的動(dòng)作時(shí),可直接執(zhí)行存儲(chǔ)過(guò)程,簡(jiǎn)化操作步驟create procedure procedure_searchpo-查詢(xún)某訂單的產(chǎn)品信息onumber char(12) as select onumber,product.pnumber,pname,pcategory,pprice,pex_price,pinventory from product,po where onumber=onumber and

19、po.pnumber=product.pnumber; 7、查詢(xún)產(chǎn)品信息功能:查詢(xún)產(chǎn)品信息目的:存儲(chǔ)查詢(xún)產(chǎn)品信息的操作意義:下次重復(fù)同樣的動(dòng)作時(shí),可直接執(zhí)行存儲(chǔ)過(guò)程,簡(jiǎn)化操作步驟create procedure procedure_searchproduct-查詢(xún)某產(chǎn)品信息pnumber char(12) as select pnumber,pname,pcategory,pprice,pex_price,pinventory,snumber from product,sp where pnumber=pnumber and sp.pnumber=pnumber; 8、插入供應(yīng)商信息功能:插入

20、供應(yīng)商信息目的:存儲(chǔ)插入供應(yīng)商信息的操作意義:下次重復(fù)同樣的動(dòng)作時(shí),可直接執(zhí)行存儲(chǔ)過(guò)程,簡(jiǎn)化操作步驟create procedure procedure_insertsuppliers-插入供應(yīng)商信息snumber char(12),sname char(30),saddress char(30),stelnum int as if exists(select * from suppliers where snumber=snumber) print 該供應(yīng)商記錄已經(jīng)存在 else insert into suppliers(snumber,sname,saddress,stelnum) va

21、lues(snumber,sname,saddress,stelnum); . word 文檔9、插入訂單信息功能:插入訂單信息目的:存儲(chǔ)插入訂單信息的操作意義:下次重復(fù)同樣的動(dòng)作時(shí),可直接執(zhí)行存儲(chǔ)過(guò)程,簡(jiǎn)化操作步驟create procedure procedure_insertorders-插入訂單表onumber char(12),odate date,enumber char(12),cnumber char(12) as if exists(select * from orders where onumber=onumber) print 該訂單記錄已經(jīng)存在 else insert

22、into orders(onumber,odate,enumber,cnumber) values(onumber,odate,enumber,cnumber); 10、插入產(chǎn)品訂購(gòu)信息功能:插入產(chǎn)品訂購(gòu)信息目的:存儲(chǔ)插入產(chǎn)品訂購(gòu)信息的操作意義:下次重復(fù)同樣的動(dòng)作時(shí),可直接執(zhí)行存儲(chǔ)過(guò)程,簡(jiǎn)化操作步驟create procedure procedure_insertpo-插入產(chǎn)品訂購(gòu)表pnumber char(12),onumber char(12),quantity int as if exists(select * from po where pnumber=pnumber and onum

23、ber=onumber)-當(dāng)該訂單已經(jīng)訂購(gòu)改產(chǎn)品時(shí)不予重復(fù)訂購(gòu)print 該產(chǎn)品訂購(gòu)訂單記錄已經(jīng)存在 if exists(select * from product where pinventoryquantity)-當(dāng)庫(kù)存量不足時(shí)不予訂購(gòu)print 該產(chǎn)品庫(kù)存不足,無(wú)法訂購(gòu) else insert into po(onumber,pnumber,quantity) values(onumber,pnumber,quantity); 11、插入產(chǎn)品信息功能:插入產(chǎn)品信息目的:存儲(chǔ)產(chǎn)品的操作意義:下次重復(fù)同樣的動(dòng)作時(shí),可直接執(zhí)行存儲(chǔ)過(guò)程,簡(jiǎn)化操作步驟create procedure proced

24、ure_insertproduct -插入產(chǎn)品信息pnumber char(12),pname char(30),pcategory char(15),pprice int,pex_price real,pinventory real as if exists(select * from product where pnumber=pnumber)-若有相同產(chǎn)品,只更新庫(kù)存量update product set pinventory=pinventory+pinventory else insert into product(pnumber,pname,pcategory,pprice,pex_price,pinventory) values(pnumber,pname,pcategory,pprice,pex_price,pinventory); 12、完整的訂單銷(xiāo)售流程功能:插入訂單信息和訂購(gòu)信息以及修改產(chǎn)品庫(kù)存等信息目的:存儲(chǔ)從客戶(hù)下單到訂單訂購(gòu)產(chǎn)品的流程的操作. word 文檔意義:直觀展示訂單銷(xiāo)售流程,使用戶(hù)能夠更簡(jiǎn)明的執(zhí)行完整的訂單銷(xiāo)售流程create procedure procedure_order -完整的訂單銷(xiāo)售流程onumber char(12),odate date,enumber char(12),cnumbe

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論