




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、本科實驗報告課程名稱:數(shù)據(jù)庫課程設(shè)計報告姓 名:學(xué) 院:計算機科學(xué)與技術(shù)院 系:計算機科學(xué)與技術(shù)專 業(yè):計算機科學(xué)與技術(shù)年 級:學(xué) 號:指導(dǎo)教師:2007年 9月15日一 . 課程設(shè)計目的和要求1. 熟悉大型數(shù)據(jù)庫管理系統(tǒng)的結(jié)構(gòu)與組成;2. 熟悉數(shù)據(jù)庫應(yīng)用系統(tǒng)的設(shè)計方法和開發(fā)過程;3. 掌握一種大型數(shù)據(jù)庫管理系統(tǒng)(dm5、oracle或sql server)的應(yīng)用技術(shù)和開發(fā)工具的使用;4. 熟悉數(shù)據(jù)庫設(shè)計工具的使用;5. 熟悉數(shù)據(jù)庫安全的相關(guān)知識和技術(shù);6. 熟悉數(shù)據(jù)庫系統(tǒng)的管理和維護。二 . 咚咚圖書銷售系統(tǒng)設(shè)計說明書1.概要說明 本系統(tǒng)開發(fā)平臺: + sql server 2005 本系統(tǒng)
2、采用架構(gòu): petshop 本系統(tǒng)運行環(huán)境: windows xp 或以上版本(安裝iis5.0以上版本) 2.模塊設(shè)計本系統(tǒng)總共劃分以下幾個模塊:a. 圖書編目b. 圖書查找c. 圖書進貨(修改已經(jīng)編目的圖書數(shù)量,同時調(diào)整價格)d. 圖書退貨e. 會員添加/修改/刪除f. 出版社管理g. 會員組管理h. 用戶狀態(tài)管理i. 零售購買j. 零售退貨k. 圖書銷售/退貨統(tǒng)計l. 系統(tǒng)設(shè)置i. 表設(shè)計圖書編目 列名數(shù)據(jù)類型可否為空說明idint(4)not null主鍵、自動增長isbnvchar(20)not null圖書isbn booknamevchar(20)not null圖書名稱auth
3、orvchar(20)null圖書作者editionvchar(20)null圖書版本bookconcernidint(4)not null圖書出版社formatvchar(20)null圖書開本publisttimedatetime(8)null出版日期totalpagesint(4)null總頁數(shù)pricefloatnot null定價summaryvchar(200)null 圖書簡介classvchar(10)not null圖書類別stocksint(4)not null庫存量coverpicvchar(20)null圖書封面圖片cost floatnot null成本levelin
4、t(4)null推薦等級addtimedatetime(8)null圖書編目日期其中bookid為主鍵, bookconcernid是表bookconcern 中convernid的外碼,class是表bookclass中classid 的外碼圖書進貨列名數(shù)據(jù)類型可否為空說明idint(4)not null主鍵、自動增長orderidvchar(20)not null進貨訂單號 concernidvchar(20)not null圖書出版社idnumint(4)not null圖書數(shù)目updatecostfloatnot null修改后的圖書價格addtimedatetimenot null進
5、貨日期agocostfloatnot null圖書以前價格nowcostfloat not null本次進貨價格bookidint(4)not null圖書id其中id為主鍵, bookconcernid是表bookconcern 中convernid的外碼,bookid是表book中bookid 的外碼圖書進貨(主鍵,進貨訂單,圖書出版社id,圖書數(shù)目,進貨日期,圖書以前價格,本次進貨價格,圖書id)圖書退貨列名數(shù)據(jù)類型可否為空說明idint(4)not null主鍵、自動增長orderidvchar(20)not null進貨訂單號 concernidvchar(20)not null圖書
6、出版社idnumint(4)not null圖書數(shù)目addtimedatetimenot null進貨日期costfloatnot null圖書價格bookidint(4)not null圖書id其中id為主鍵, bookconcernid是表bookconcern 中convernid的外碼,bookid是表book中bookid 的外碼圖書退貨(主鍵,進貨訂單編號,圖書出版社id,圖書數(shù)目,進貨日期,圖書價格,本次進貨價格,圖書id)圖書類別列名數(shù)據(jù)類型可否為空說明classidint(4)not null主鍵、自動增長,類別idclassnamevchar(20)not null圖書類別
7、名 parentclassint(4)not null上一級類別的idextravchar(200)null額外信息其中classid為主鍵.圖書出版社列名數(shù)據(jù)類型可否為空說明concernidint(4)not null主鍵、自動增長,出版社idconnamevchar(20)not null出版社名 conaddressvchar(30)null出版社地址contelvchar(20)null出版社電話conwebsitevchar(20)null出版社網(wǎng)址conemailvchar(20)null出版社email其中concernid為主鍵.圖書出版社(出版社id,出版社名,出版社地址,
8、出版社電話,出版社網(wǎng)址,出版社email)圖書零售列名數(shù)據(jù)類型可否為空說明idint(4)not null主鍵、自動增長orderidvchar(20)not null零售單號 useridint(4)not null用戶idnumint(4)not null圖書數(shù)目returnkeyvchar(10)not null小票addtimedatetimenot null進貨日期discountfloatnot null圖書折扣operatoridint(4)not null操作員iddescriptionvchar(200)null其他描述bookidint(4)not null圖書id其中id
9、為主鍵, bookid是表book 中bookid的外碼,userid是表user中id 的外碼,當userid為-1時表示此次零售是普通用戶,否則則是會員購買!零售(主鍵,零售單號,用戶id,圖書數(shù)目,進貨日期,圖書折扣,管理員id,圖書id)會員表 列名數(shù)據(jù)類型可否為空說明idint(4)not null主鍵、自動增長usertypeint(4)not null會員組編號usernamevchar(20)null會員名pwdvchar(20)not null密碼integralint(4)not null會員積分emailvchar(20)null會員emailaddressvchar(2
10、0)null地址postalcodevchar(10)null郵編telvchar(10)null電話descriptionvchar(200)null其他描述idcardvchar(50)not null 身份證rmbfloatnot null余額periodofvaliditydatetime(8)not null會員有效期serialnumbervchar(20)not null會員編號statusint(4)not null會員狀態(tài)sexboolnull性別addtimedatetime(8)null添加日期其中id為主鍵, usertype是表usertype 中usertype_i
11、d的外碼, status是表 userstatus 中id 的外碼觸發(fā)器 : modifyjifen該觸發(fā)器的作用是當改變了某一個會員的會員組類別的時候,系統(tǒng)將自動調(diào)整其積分,使得積分回歸該會員組定義的積分限之內(nèi)-set ansi_nulls onset quoted_identifier ongoalter trigger modifyjifen on dbo.user after insert asdeclare userid int declare integral int declare usertype intselect userid=id,usertype=usertype,in
12、tegral=integral from inserteddeclare integral_low int,integral_up intselect integral_low=integral_low,integral_up=integral_up from usertype where usertype_id=usertypeif integralintegral_upbeginupdate user set integral=integral_low where id=useridend-會員組列名數(shù)據(jù)類型可否為空說明usertype_idint(4)not null主鍵、自動增長,會員
13、組idusertype_namevchar(20)not null會員組名稱 discountfloatnot null會員組折扣integral_lowint(4)not null積分下限integral_upint(4)not null積分上限descriptionvchar(200)null描述信息其中usertype_id為主鍵. 會員組(主鍵、自動增長,會員組id,會員組名稱,會員組折扣,積分下限,積分上限,描述信息)觸發(fā)器 : modify_low_up該觸發(fā)器的作用是當改變了某一個會員組的積分上限或者下限的時候,系統(tǒng)將自動調(diào)整其相鄰的會員組的下限或者上限-set ansi_nul
14、ls onset quoted_identifier ongoalter trigger modify_low_up on dbo.usertype after updateas declare integrallow int,integrallow0 int declare integralup int,integralup0 int declare usertypeid intselect usertypeid=usertype_id,integrallow=integral_low,integralup=integral_up from inserted select integrall
15、ow0=integral_low,integralup0=integral_up from deleted -select 記錄號 from inserted修改后的 -select 記錄號 from deleted修改前的 declare integrallow2 int,integralup2 int,usertypeid2 intset integrallow2=-1set integralup2=-1if integrallow0integrallowbeginselect usertypeid2=usertype_id,integrallow2=integral_low,integr
16、alup2=integral_up from usertype where integral_up=integrallow0-1if integrallow2-1beginupdate usertype set integral_up=integrallow-1 where usertype_id=usertypeid2endendif integralup0integralupbeginselect usertypeid2=usertype_id,integrallow2=integral_low,integralup2=integral_up from usertype where int
17、egral_low=integralup0+1if integrallow2-1beginupdate usertype set integral_low=integralup+1 where usertype_id=usertypeid2endend-會員狀態(tài)列名數(shù)據(jù)類型可否為空說明idint(4)not null主鍵、自動增長,狀態(tài)iduserstatusvchar(20)not null狀態(tài)名稱 descriptionvchar(200)null描述信息其中id為主鍵.ii. 視圖設(shè)計bookinfo: 表book和 表bookconcern通過concernid內(nèi)連接生成.bookse
18、ll_userinfo_bookinfo: 視圖bookinfo和 表userinfo通過bookid和userid外連接生成.userinfo: 表user和 表usertype 和 userstatus 通過usertype_id 和userstatus_id內(nèi)連接生成.tuihuo/xiaoshou: 表booksell和 視圖bookinfo 和 userinfo 通過userid 和bookid外連接生成.以下是部分連接語句:1. 視圖 bookinfoselect dbo.book.bookid, dbo.book.isbn, dbo.book.bookname, dbo.book
19、.author, dbo.book.edition, dbo.book.bookconcernid, dbo.bookconcern.conname, dbo.book.format, dbo.book.publishtime, dbo.book.totalpages, dbo.book.price, dbo.book.summary, dbo.book.stocks, dbo.book.class1, dbo.book.class2, dbo.book.class3, bookclass_1.classname as classname1, bookclass_2.classname as
20、classname2, bookclass_3.classname as classname3, dbo.book.coverpic, dbo.book.cost, dbo.book.level, dbo.book.userrate, dbo.book.addtime, dbo.booksmetcount, dbo.bookstat.clickcountfrom dbo.book inner join dbo.bookconcern on dbo.book.bookconcernid = dbo.bookconcern.concernid inner join dbo.bookstat on
21、dbo.book.bookid = dbo.bookstat.bookid left outer join dbo.bookclass as bookclass_3 on bookclass_3.classid = dbo.book.class3 left outer join dbo.bookclass as bookclass_2 on dbo.book.class2 = bookclass_2.classid left outer join dbo.bookclass as bookclass_1 on dbo.book.class1 = bookclass_1.classidselec
22、t dbo.bookinfo.isbn, dbo.bookinfo.bookname, dbo.bookinfo.author, dbo.bookinfo.edition, dbo.bookinfo.bookconcernid, dbo.bookinfo.conname, dbo.bookinfo.format, dbo.bookinfo.publishtime, dbo.bookinfo.totalpages, dbo.bookinfo.price, dbo.bookinfo.summary, dbo.bookinfo.stocks, dbo.bookinfo.classname1, dbo
23、.bookinfo.classname2, dbo.bookinfo.classname3, dbo.userinfo.username, dbo.booksell.bookid, dbo.booksell.userid, dbo.booksell.description, dbo.booksell.addtime, dbo.booksell.returnkey, dbo.booksell.num, dbo.userinfo.pwd, dbo.userinfo.email, dbo.userinfo.address, dbo.userinfo.postalcode, dbo.userinfo.
24、tel, dbo.userinfo.idcard, dbo.userinfo.rmb, dbo.userinfo.periodofvalidity, dbo.userinfo.serialnumber, dbo.useriegral, dbo.userinfo.usertype_name, dbo.userinfo.userstatusid, dbo.userinfo.usertype_id, dbo.userinfo.userstatus, dbo.userinfo.authentication, dbo.userinfo.discount, dbo.userinfo.sex,
25、 dbo.booksell.orderid, dbo.booksell.discount as dis, dbo.booksell.operatorid, dbo.booksell.statu, dbo.bookinfo.costfrom dbo.booksell inner join dbo.bookinfo on dbo.booksell.bookid = dbo.bookinfo.bookid left outer join dbo.userinfo on dbo.booksell.userid = dbo.userinfo.id2. 視圖booksell_userinfo_bookin
26、foiii. 存儲過程1. 會員搜索的實現(xiàn)由于會員有很多的屬性,包括性別,編號,添加日期,會員組,會員狀態(tài)等等,同時又要實現(xiàn)分頁顯示, 所以該存儲過程必須能根據(jù)條件來進行不同的查詢,同時要返回符合條件的記錄總數(shù)和某一頁(用戶需求)的記錄,以供前臺調(diào)用顯示.首先聲明了需要進行判斷的參數(shù),然后對用戶傳參進行判斷,如果保持默認值表示不需要對該條件進行添加,否則必須加上該條件.以此類推,直到對所有條件進行判斷. 然后因為要實現(xiàn)分頁顯示,必須計算從哪一條記錄開始,選取多少頁,這里就應(yīng)該是選擇pagesize條記錄,應(yīng)該從pagesize*(pageindex-1)這里開始選取,這里在返回符合條件的總記錄
27、數(shù)的時候碰到了問題,因為在存儲過程中每次exec執(zhí)行后,都會將結(jié)果返回到客戶端,所以獲取總條數(shù)不能調(diào)用這個方法,這里我采用了一個投機取巧的辦法勉強實現(xiàn)了,因為對某些函數(shù)不熟悉,所以下次還是需要好好摸索下.實現(xiàn)代碼:-set ansi_nulls onset quoted_identifier ongoalter procedure dbo.searchuser (idcard nvarchar(50)=-1,username nvarchar(50)=-1,serialnumber nvarchar(50)=-1,usertype int=-1,userstatus int=-1,addtim
28、e1 nvarchar(50)=1900-01-01,addtime2 nvarchar(50)=2900-01-01,pageindex int=1,pagesize int=15,mycount int=0 out)asdeclare sql nvarchar(2000)declare sql_count nvarchar(2000)set sql=select top +cast(pagesize as varchar(32)+ * from userinfo where 10set sql_count=update user set wanttoread=1 where 10if id
29、card-1beginset sql=sql+ and idcard like %+cast( idcard as nvarchar)+%set sql_count=sql_count+ and idcard like %+cast( idcard as nvarchar)+%end if username-1beginset sql=sql+ and username like %+cast( username as nvarchar)+%set sql_count=sql_count+ and username like %+cast( username as nvarchar)+%end
30、 if serialnumber-1beginset sql=sql+ and serialnumber like %+cast( serialnumber as nvarchar)+%set sql_count=sql_count+ and serialnumber like %+cast( serialnumber as nvarchar)+%end if usertype-1beginset sql=sql+ and usertype_id=+cast(usertype as nvarchar)set sql_count=sql_count+ and usertype=+cast(use
31、rtype as nvarchar)endif userstatus-1beginset sql=sql+ and userstatusid=+cast(userstatus as nvarchar)set sql_count=sql_count+ and status=+cast(userstatus as nvarchar)endif addtime1-1 and addtime2-1beginset sql=sql+ and addtime+convert(varchar(50),addtime1,120)+ and addtime+convert(varchar(50),addtime
32、1,120)+ and addtime0if idcard-1beginset sql=sql+ and idcard like %+cast( idcard as nvarchar)+%end if username-1beginset sql=sql+ and username like %+cast( username as nvarchar)+%end if serialnumber-1beginset sql=sql+ and serialnumber like %+cast( serialnumber as nvarchar)+%end if usertype-1beginset
33、sql=sql+ and usertype_id=+cast(usertype as nvarchar)endif userstatus-1beginset sql=sql+ and userstatusid=+cast(userstatus as nvarchar)endif addtime1-1 and addtime2-1beginset sql=sql+ and addtime+convert(varchar(50),addtime1,120)+ and addtime+convert(varchar(50),addtime2,120)+endset sql=sql+ order by addtime desc) order by addtime desc exec ( sql) print(sql)print(sql_count)return-接收返回值 -declare rows int - exec rows = sptest-2. 圖書搜索的實現(xiàn)(同會員搜索)3. 圖書插入- set ansi_nulls onset quoted_identifier ongoalter procedure dbo.insertbook( isbn varchar(50), boo
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 【正版授權(quán)】 IEC 60730-2-8:2025 EN-FR Automatic electrical controls - Part 2-8: Particular requirements for electrically operated water valves,including mechanical requirements
- 【正版授權(quán)】 ISO/IEC GUIDE 98-3:2008 EN Uncertainty of measurement - Part 3: Guide to the expression of uncertainty in measurement (GUM:1995)
- 【正版授權(quán)】 IEC 60335-2-51:2023 EXV-CMV EN Household and similar electrical appliances - Safety - Part 2-51: Particular requirements for stationary circulation pumps for heating and ser
- 寫給勇敢的自己抒情作文(4篇)
- 屈原離騷思想解讀教案
- 戰(zhàn)略合作協(xié)議及雙方責(zé)任和義務(wù)明細
- 體育產(chǎn)業(yè)運動裝備銷售統(tǒng)計表
- 金融服務(wù)與資金管理服務(wù)協(xié)議
- 音樂b考試試題及答案
- 醫(yī)院物流考試試題題庫及答案
- 高效智慧的廠站網(wǎng)一體化解決方案
- 2025年福建泉州南安市國有企業(yè)招聘筆試參考題庫含答案解析
- 2024年中考模擬試卷道法(山西卷)
- 醫(yī)院健康咨詢合同范本
- 初一英語閱讀理解100篇七年級上冊英語閱讀理解及答案
- 2024年湖南省初中學(xué)業(yè)水平考試地理試卷含答案
- 急性肺栓塞的急救護理
- 奶茶供貨合作協(xié)議書范文范本
- 明清家具完整版本
- GB/T 15822.2-2024無損檢測磁粉檢測第2部分:檢測介質(zhì)
- 2024年河南省現(xiàn)場流行病學(xué)調(diào)查職業(yè)技能競賽理論考試題庫-中(多選題部分)
評論
0/150
提交評論