基于Oracle的網(wǎng)上圖書銷售系統(tǒng)數(shù)據(jù)庫設計_第1頁
基于Oracle的網(wǎng)上圖書銷售系統(tǒng)數(shù)據(jù)庫設計_第2頁
基于Oracle的網(wǎng)上圖書銷售系統(tǒng)數(shù)據(jù)庫設計_第3頁
基于Oracle的網(wǎng)上圖書銷售系統(tǒng)數(shù)據(jù)庫設計_第4頁
基于Oracle的網(wǎng)上圖書銷售系統(tǒng)數(shù)據(jù)庫設計_第5頁
已閱讀5頁,還剩14頁未讀 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

1、網(wǎng)上圖書銷售系統(tǒng)數(shù)據(jù)庫的設計在開發(fā)管理信息系統(tǒng)時,最根本的是要考慮兩方面的問題,數(shù)據(jù)以及數(shù)據(jù)加工,這兩項貫穿于整個開發(fā)過程。數(shù)據(jù)庫設計的核心是確定一個合適的數(shù)據(jù)模型,這個數(shù)據(jù)模型應當滿足一下三個要求:(1) 符合用戶的要求。既能包含用戶需要處理的所有數(shù)據(jù),又能支持用戶提出的所有處理功能的實現(xiàn)。(2) 能被某個現(xiàn)有的數(shù)據(jù)庫管理系統(tǒng)(dbms)所接受。(3) 具有較高的質(zhì)量,如抑郁理解、便于維護、沒有數(shù)據(jù)沖突、完整性好、效益高。數(shù)據(jù)庫設計的步驟:數(shù)據(jù)庫設計大致經(jīng)歷概念結構設計、邏輯結構設計、物理結構設計三個階段。第一階段是數(shù)據(jù)庫概念結構設計。在系統(tǒng)分析期間得到的數(shù)據(jù)流圖、數(shù)據(jù)字典的基礎上,結合有關

2、數(shù)據(jù)規(guī)范化的理論,用一個數(shù)據(jù)模型將用戶的數(shù)據(jù)需求明確表達出來,這是數(shù)據(jù)庫設計過程中的一個關鍵。概念數(shù)據(jù)模型是一個面向問題的數(shù)據(jù)模型,它反映了用戶的顯示環(huán)境與數(shù)據(jù)庫的用戶具體實現(xiàn)技術。第二階段是數(shù)據(jù)庫邏輯結構設計。根據(jù)前一階段建立起來的怪年數(shù)據(jù)模型,以及所選定的某一個dbms的特性,按照一定的轉(zhuǎn)換規(guī)則,把怪年數(shù)據(jù)模型轉(zhuǎn)換為這個dbms所能接受的數(shù)據(jù)模型,一般稱為邏輯數(shù)據(jù)庫模型。第三階段是數(shù)據(jù)庫物理結構設計。這一階段根據(jù)所選定的軟硬件運行環(huán)境,權衡各種利弊因素,確定一種高效的物理存儲結構,使之既能節(jié)省存儲空間,又能提高存取速度。但是開發(fā)人員一般不考慮第三階段的設計,而是由dbms自行去處理。下面我

3、就從數(shù)據(jù)庫需求分析、數(shù)據(jù)庫概念結構、數(shù)據(jù)庫邏輯結構進行我的網(wǎng)上圖書銷售系統(tǒng)的設計。1、 數(shù)據(jù)庫需求分析需求分析的任務還不是確定系統(tǒng)怎么樣完成它的工作,而僅僅是確定系統(tǒng)必須完成哪些工作,也就是對目標系統(tǒng)提出完整、準確、清晰、具體的要求。 通過對系統(tǒng)功能的分析,針對一般網(wǎng)上書店的需求,總結了一下的需求信息:1) 使用者分為一般用戶和管理員2) 只有管理員可對一般用戶和書籍進行管理3) 訂單分為單張詳細的訂單和總訂單4) 每一本圖書都從屬于一個類型5) 一個用戶可以購買多本圖書6) 一個用戶對應一張訂單列表7) 一個列表對應多張訂單2、 數(shù)據(jù)庫概念結構設計用一個數(shù)據(jù)模型將用戶的數(shù)據(jù)需求明確表達出來,

4、目前比較實用的方法是e-r(實體-聯(lián)系方法)方法,此方法主要用在數(shù)據(jù)庫設計的一、二階段。在e-r方法中,描述概念數(shù)據(jù)模型的得力工具是e-r圖。e-r圖有三個基本成分:實體、聯(lián)系和屬性。 通過以上的分析我們可以總結出有關的數(shù)據(jù)結構和數(shù)據(jù)項:管理員 包括數(shù)據(jù)項:管理員名,管理員密碼等用戶 包括數(shù)據(jù)項:用戶編號,用戶名,用戶密碼等圖書 包括數(shù)據(jù)項:圖書編號,圖書名稱,作者,分類編號等圖書分類 包括數(shù)據(jù)項:分類編號,分類名稱等訂單 包括數(shù)據(jù)項:訂單編號,用戶編號等訂單列表 包括數(shù)據(jù)項:訂單編號,圖書編號,圖書名,購買數(shù)量等論壇 包括數(shù)據(jù)項:信息編號,用戶名,提交時間,提交內(nèi)容等實體之間關系的e-r圖(

5、1) 管理員信息實體的e-r圖 管理員 用戶名 密碼 用戶名 密碼(2) 用戶信息實體的e-r圖用戶編號 用戶名 密碼 郵箱 用戶. 郵箱(3) 圖書實體信息實體的e-r圖圖書圖書編號圖書名出版社.出版時間(4) 圖書分類信息實體的e-r圖圖書分類圖書種類編號圖書種類(5) 訂單列表實體的e-r圖id訂單編號數(shù)量訂單列表圖書編號用戶編號(6)訂單信息實體的e-r圖訂單id訂單編號是否完成.處理情況數(shù)據(jù)庫中實體之間的e-r圖論壇1管理發(fā)表n1圖書n11n1n管理購買1管理員用戶訂單列表下單對應訂單管理nnn1n說明訂單列表是用戶下單時所對應的數(shù)據(jù)表,在提交完之后形成訂單列表3、 數(shù)據(jù)庫邏輯結構設

6、計 根據(jù)前一階段建立起來的怪年數(shù)據(jù)模型,以及所選定的某一個dbms的特性,按照一定的轉(zhuǎn)換規(guī)則,把怪年數(shù)據(jù)模型轉(zhuǎn)換為這個dbms所能接受的數(shù)據(jù)模型 在邏輯設計結構設計里我主要進行了表結構的設計和一些數(shù)據(jù)表的實現(xiàn),通過運用sql語言建立表和對表進行插入,將邏輯結構的表轉(zhuǎn)換成數(shù)據(jù)庫中的真實的表,為以后的各項操作做好基礎工作。在數(shù)據(jù)庫中創(chuàng)建用戶hysql conn system/systempwdorcl as sysdba已連接。sql create user hy identified by hypwd 2 account unlock;用戶已創(chuàng)建。對用戶授權sql grant create cl

7、uster to hy;授權成功。sql grant create database link,create any index to hy;授權成功。sql grant create materialized view to hy;授權成功。sql grant create procedure,create sequence,create table,create tablespace,create trigger,create type,create view to hy;授權成功。sql grant create synonym to hy;授權成功。sql conn hy/hypwdo

8、rcl已連接。sql select username,privilege,admin_option from user_sys_privs;username privilege adm- - -hy create view nohy create synonym nohy create table nohy create tablespace nohy create session nohy create type nohy create trigger nohy create sequence nohy create cluster nohy create database link noh

9、y create materialized view nohy create procedure nohy create any index no已選擇13行。創(chuàng)建表空間hyuser和hytempsql create tablespace hyuser 2 datafile%oracle_home%databasehyuser.dbfsize 50m reuse 3 uniform size 128k;表空間已創(chuàng)建。sql create temporary tablespace hytemp 2 tempfile %oracle_home%databasehytemp.dbfsize 20m

10、reuse 3 uniform size 128k;表空間已創(chuàng)建。sql conn system/systempwdorcl as sysdbasql alter user hy quota unlimited on hyuser;用戶已更改。刪除回收站語句:purge recyclebin;整個系統(tǒng)的數(shù)據(jù)庫由七個表組成:(1)管理員數(shù)據(jù)表(administator)字段名數(shù)據(jù)類型寬度允許空值主鍵備注1adnamevarchar220用戶名2adpwdvarchar210密碼sql create table administator( 2 adname varchar2(20) primary

11、 key, 3 adpwd varchar2(10) not null) 4 storage(initial 100k 5 next 20k 6 minextents 1 7 maxextents 99 8 pctincrease 0) 9 tablespace hyuser 10 pctfree 10 11 pctused 40 12 initrans 2 13 maxtrans 10;表已創(chuàng)建。sql insert into administator(adname,adpwd)values(huyang,2345);已創(chuàng)建 1 行。sql insert into administator(

12、adname,adpwd)values(john,344fgff);已創(chuàng)建 1 行。sql insert into administator(adname,adpwd)values(henry,fr3333);已創(chuàng)建 1 行。sql insert into administator(adname,adpwd)values(ed,4343ff);已創(chuàng)建 1 行。sql insert into administator(adname,adpwd)values(harry,er4567);已創(chuàng)建 1 行。sql select * from administator;adname adpwd- -hu

13、yang 2345john 344fgffhenry fr3333ed 4343ffharry er4567已選擇5行。(2) 用戶數(shù)據(jù)表(usertable)字段名數(shù)據(jù)類型寬度允許空值主鍵備注1useridvarchar210用戶編號2usernamevarchar220用戶名3userpwdvarchar210密碼4realnamevarchar220用戶真名5phonevarchar215電話6sexvarchar24*性別7addressvarchar2100地址8postnumber10*郵編9emailvarchar250郵箱sql create table usertable(

14、2 userid varchar2(10) primary key, 3 username varchar2(15) not null unique, 4 userpwd varchar2(10) not null, 5 realname varchar2(15) not null, 6 phone varchar2(15) not null, 7 sex varchar2(2) check(sex in(男,女), 8 address varchar2(100) not null, 9 post number(10), 10 email varchar2(50) not null ) 11

15、storage(initial 100k 12 next 20k 13 minextents 1 14 maxextents 99 15 pctincrease 0) 16 tablespace hyuser; 表已創(chuàng)建。sql alter table books modify(category varchar2(8);表已更改。insert into usertable(userid,username,userpwd,realname,phone,sex,address,post,email) values(00001,陽光,123456,楊光男,北京,10011,

16、);insert into usertable(userid,username,userpwd,realname,phone,sex,address,post,email) values(00002,miss,as1233,張三男,北京,10011,);insert into usertable(userid,username,userpwd,realname,phone,sex,address,post,email) values(00003,莫羅,4546565,李四,1534566677,男,上海,

17、434355,);insert into usertable(userid,username,userpwd,realname,phone,sex,address,post,email) values(00004,水果糖,13434,王五女,山東,276808,);insert into usertable(userid,username,userpwd,realname,phone,sex,address,post,email) values(00005,風入松,14343,張柳,132444567876,男

18、,江蘇,434345,);insert into usertable(userid,username,userpwdrealname,phone,sex,address,post,email) values(00006,朦朧,1556,盧野女,四川,4343434,yluye_345163.com);sql select * from usertable;userid usernam e userpwd realname phone sex address - - - - - - -00001 陽光 123456 楊光 1545678898

19、7 男 北京 00002 miss as1233 張三男 北京 00003 莫羅 4546565 李四男 上海 00004 水果糖 13434 王五女 山東 00005 風入松 14343 張柳 132444567876 男 江蘇 00006 朦朧 1556 盧野 189667565467 女 四川 已選擇6行。(3)圖書數(shù)據(jù)表(books)字段名數(shù)據(jù)類型寬度允許空值主鍵備注1bookidvarchar210圖書編號2booknamevarchar230圖書名稱3categoryvarchar220圖書種類4amou

20、ntint*圖書總量5left-amountint*剩余數(shù)量6isdiscountint*是否特價7pricefloat10*價錢8discountpriefloat10*優(yōu)惠價錢9authorvarchar220*作者10publishvarchar230*出版社11publishdatedate*出版日期注:isdiscount:0表示正常價格圖書,1表示特價圖書。sql create table books( 2 bookid varchar2(10) primary key, 3 bookname varchar2(30) not null, 4 category varchar2(2

21、0), 5 amount int, 6 left_amount int, 7 isdiscount int default 0, 8 price float(10), 9 discountprice float(10), 10 author varchar2(20), 11 publish varchar2(30), 12 publishdate date ) 13 storage(initial 100k 14 next 20k 15 minextents 1 16 maxextents 99 17 pctincrease 0) 18 tablespace hyuser;表已創(chuàng)建。sql s

22、elect * from books;bookid bookname category amount left_amount isdiscount price discountprice author publish publishdate - - 00011 oracle10g數(shù)據(jù)庫 計算機 48 40 0 25 25 肖龍文 清華大學出版社 00012 oracle10g實踐 計算機 23 21 0 13 13 楊欣 清華大學出版社 00022 王長喜英語六級 英語 23 21 0 13 13 楊欣 清華大學出版社 00123 王長喜英語四級 英語 23 21 0 13 13 楊欣 清華大

23、學出版社 00453 英語六級作文 英語 18 16 0 18 18 楊欣 清華大學出版社 00233 物理工程學 物理 18 16 0 18 18 楊欣 清華大學出版社 00435 英語六級突破 英語六級 18 16 0 18 18 楊欣 清華大學出版社 已選擇7行。(4)圖書種類數(shù)據(jù)表(category)字段名數(shù)據(jù)類型寬度允許空值主鍵備注1categoryidvarchar210圖書種類編號2categoryvarchar220圖書種類sql create table category( 2 categoryid varchar2(10) primary key, 3 category v

24、archar2(20) not null 4 ) 5 storage(initial 100k 6 next 20k 7 minextents 1 8 maxextents 99 9 pctincrease 0) 10 tablespace hyuser;表已創(chuàng)建。insert into category(categoryid,category)values(00001,計算機);insert into category(categoryid,category)values(00002,數(shù)學);insert into category(categoryid,category)values(00

25、003,英語六級);insert into category(categoryid,category)values(00004,英語四級);insert into category(categoryid,category)values(00005,土木工程);insert into category(categoryid,category)values(00006,物理);insert into category(categoryid,category)values(00007,醫(yī)學);insert into category(categoryid,category)values(00008,

26、美術);insert into category(categoryid,category)values(00009,音樂);insert into category(categoryid,category)values(00010,化學);insert into category(categoryid,category)values(00011,生物學);sql select * from category;categoryid category- -00001 計算機00002 數(shù)學00003 英語六級00004 英語四級00005 土木工程00006 物理00007 醫(yī)學00008 美術0

27、0009 音樂00010 化學00010 化學00011 生物學已選擇11行。(5) 訂單列表數(shù)據(jù)表(orders)字段名數(shù)據(jù)類型大小允許空值主鍵備注1idvarchar210主鍵2orderidvarchar210訂單編號3bookidvarchar210圖書編號4amountint購買數(shù)量sql create table allorders( 2 id varchar2(10) primary key, 3 orderid varchar2(10) not null, 4 bookid varchar2(10) not null, 5 amount int not null 6 ) 7 s

28、torage(initial 100k 8 next 20k 9 minextents 1 10 maxextents 99 11 pctincrease 0) 12 tablespace hyuser;insert into orders(orderid,bookid,amount)values(00012,03230,3);insert into orders(orderid,bookid,amount)values(00344,03232,2);insert into orders(orderid,bookid,amount)values(04343,04343,1);insert in

29、to orders(orderid,bookid,amount)values(02323,03242,3);insert into orders(orderid,bookid,amount)values(00551,04420,5);insert into orders(orderid,bookid,amount)values(44301,45530,4);sql select * from orders;id orderid bookid amount- - - -00001 00001 02920 100322 00012 03230 300342 00344 03232 2004343

30、04343 04343 100435 00551 04420 5044331 44301 45530 4004333 04343 04343 1已選擇7行。(6) 訂單信息數(shù)據(jù)表(order_list)字段名數(shù)據(jù)類型大小允許空值主鍵備注1orderidvarchar210訂單編號2bookidvarchar210圖書編號3amountint圖書數(shù)量4pricefloat10圖書價錢5usernamevarchar220用戶名6isdoneint是否完成7ordertimedate訂單時間8remarkvarchar250處理情況注:isdone:0表示未完成的訂單,1表示已完成的訂單。sql

31、create table order_list(orderid varchar2(10) primary key, 2 bookid varchar2(10) not null, 3 amount int not null, 4 price float(10) not null, 5 username varchar2(30) not null, 6 isdone int default 0, 7 ordertime date, 8 remark varchar2(50) 9 ) 10 storage(initial 100k 11 next 20k 12 minextents 1 13 ma

32、xextents 99 14 pctincrease 0) 15 tablespace hyuser;表已創(chuàng)建。sql select * from order_list;orderid bookid amount price username isdone ordertime remark- - -044331 44301 4 12 miss 0 14-2月-12 meiyou012345 44444 4 34 miss 0 14-4月-12 meiyou06543 56565 3 16 fddd 0 15-4月-12 meiyou03432 14567 2 16 mfds 0 17-4月-1

33、2 meiyou04567 43201 1 67 mdess 0 18-4月-12 meiyou01278 11101 2 52 mddd 0 16-4月-12 meiyou(7)論壇數(shù)據(jù)表(guest)字段名數(shù)據(jù)類型大小允許空值主鍵備注1idvarchar210信息編號2titlevarchar220信息標題3contentvarchar250信息內(nèi)容4timedate信息日期5usernamevarchar220用戶名6isdoneint是否完成處理7answervarchar220處理信息注:isdone:0表示未完成,1表示已完成。sql create table guest( 2 i

34、d varchar2(10) primary key, 3 title varchar2(20) not null, 4 content varchar2(50) not null, 5 time date not null, 6 username varchar2(20) not null, 7 isdone int default 0, 8 answer varchar2(20), 11 ) 12 storage(initial 100k 13 next 20k 14 minextents 1 15 maxextents 99 16 pctincrease 0) 17 tablespace

35、 hyuser;表已創(chuàng)建。sql select * from guest;id title content time username isdone answer- - -43434 團購 有書要團購大家踴躍參 14-4月-12 jack 0 必須的00040 打折 打折活動即將開始 16-4月-12 張三 0 五一31134 抽獎 書城將舉行抽獎活動 14-4月-12 王五 0 必須的10504 哈哈哈 大家踴躍發(fā)言啊啊 14-4月-12 張柳 0 必須的10034 哎! 沒什么好說的了 14-4月-12 jack 0 必須的建立組合分區(qū)表: 組合分區(qū)方法是在總體上使用范圍分區(qū)的方法對數(shù)據(jù)分

36、區(qū),而在分區(qū)中則使用列表/散列分區(qū)方法,組合分區(qū)很適合與歷史數(shù)據(jù)和條塊數(shù)據(jù),它改善了范圍分區(qū)及其數(shù)據(jù)放置的可管理性,并提供了列表/散列分區(qū)的并行機制的優(yōu)點。創(chuàng)建組合分區(qū)時需要指定:(1) 分區(qū)方法:范圍(by range)。(2) 分區(qū)列(3) 標志分區(qū)邊界的分區(qū)描述(4) 子分區(qū)方法:散列(by hash)或列表(by list)(5) 子分區(qū)列(6) 每個分區(qū)的子分區(qū)數(shù)量或子分區(qū)的描述 下面我將圖書數(shù)據(jù)表創(chuàng)建為一個組合分區(qū)表stock,它包括5個按價格范圍的分區(qū),每個范圍分區(qū)包含4個散列子分區(qū),分區(qū)被放在指定的表空間t1t4中。其中的范圍我們可以以價格為標準,也可以以圖書種類為標準,在本例

37、中我將以價格為標準創(chuàng)建組合分區(qū)表stock。首先先創(chuàng)建表空間t1、t2、t3、t4sql create tablespace t1 2 datafile%oracle_home%databaset1.dbfsize 1m reuse;表空間已創(chuàng)建。sql create tablespace t2 2 datafile%oracle_home%databaset2.dbfsize 1m reuse;表空間已創(chuàng)建。sql create tablespace t3 2 datafile%oracle_home%databaset3.dbfsize 1m reuse;表空間已創(chuàng)建。sql create

38、 tablespace t4 2 datafile%oracle_home%databaset4.dbfsize 1m reuse;表空間已創(chuàng)建。sql conn system/systempwdorcl as sysdba已連接。sql alter user hy quota unlimited on t1;用戶已更改。sql alter user hy quota unlimited on t2;用戶已更改。sql alter user hy quota unlimited on t3;用戶已更改。sql alter user hy quota unlimited on t4;用戶已更改。

39、 其次創(chuàng)建組合分區(qū)表,將子分區(qū)分表放到四個表空間里sql create table stock ( 2 bookid varchar2(10), 3 bookname varchar2(30), 4 category varchar2(20), 5 amount int, 6 left_amount int, 7 isdiscount int, 8 price float(10), 9 discountprice float(10), 10 author varchar2(20), 11 publish varchar2(30), 12 publishdate date ) 13 partit

40、ion by range (price) 14 subpartition by hash(bookid) 15 subpartitions 4 store in (t1,t2,t3,t4) 16 (partition price_20 values less than (20), 17 partition price_30 values less than (30), 18 partition price_50 values less than (50), 19 partition price_100 values less than (100), 20 partition price_max

41、 values less than (maxvalue);表已創(chuàng)建。查看分區(qū)及子分區(qū)的創(chuàng)建結果,下面只截取了部分查詢結果:sql set pagesize 200sql column table_name format a20sql column partition_name format a20sql column subpartition_name format a20sql select table_name,partition_name,subpartition_name 2 from user_tab_subpartitions 3 where table_name=stock 4

42、order by partition_name,subpartition_name;table_name partition_name subpartition_name- - -stock price_100 sys_subp73stock price_100 sys_subp74stock price_100 sys_subp75stock price_100 sys_subp76最后將books表中的數(shù)據(jù)插入到此stock表中sql insert into stock select * from books;已創(chuàng)建7行。sql select * from stock;bookid bookname category amount left_amount isdiscount price discountprice author publish publishdate - - 00011 oracle10g數(shù)據(jù)庫 計算機 48 40 0 25 25 肖龍文 清華大學出版社 00012 oracle10g實踐 計算機 23 21 0 13 13 楊欣 清華大學出版社 00022 王長喜英語六級 英語 23 21 0 13 13 楊欣 清華大學出版社 00123 王長喜英語四級 英語 23 21 0 13 13 楊欣 清華

溫馨提示

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

最新文檔

評論

0/150

提交評論