數(shù)據(jù)庫大作業(yè)——一卡通課程設(shè)計_第1頁
數(shù)據(jù)庫大作業(yè)——一卡通課程設(shè)計_第2頁
數(shù)據(jù)庫大作業(yè)——一卡通課程設(shè)計_第3頁
數(shù)據(jù)庫大作業(yè)——一卡通課程設(shè)計_第4頁
數(shù)據(jù)庫大作業(yè)——一卡通課程設(shè)計_第5頁
已閱讀5頁,還剩10頁未讀 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、 數(shù)據(jù)庫應(yīng)用大作業(yè)實 驗 報 告課程名稱:Oracle數(shù)據(jù)庫試驗實驗項目:校園一卡通的設(shè)計與實現(xiàn)姓 名:任秀虎學(xué) 號:班 級:軟件開發(fā)技術(shù)校園一卡通的設(shè)計與實現(xiàn)一 、引言:1.1背景 一卡通網(wǎng) 校園一卡通系統(tǒng)是數(shù)字化校園的基礎(chǔ)工程,是數(shù)字化校園中有機的、重要的組成部分。為數(shù)字化校園提供了全面的數(shù)據(jù)采集平臺,結(jié)合學(xué)校的管理信息系統(tǒng)和網(wǎng)絡(luò),形成全校范圍的數(shù)字空間和共享環(huán)境。為學(xué)校管理人員提供具有開放性、靈活性、面向?qū)W校的應(yīng)用服務(wù)管理平臺、是管理科學(xué)化的必要前提和基本途徑。以校園一卡通系統(tǒng)為平臺,實現(xiàn)以人為本,并可充分利用銀行的金融服務(wù),實現(xiàn)“一卡在手,走遍校園”,必將滿足學(xué)校數(shù)字化建設(shè)的需求及目的

2、。1.2簡要需求說明 有多個校區(qū),每個校區(qū)都有自己獨立的服務(wù)器,校區(qū)間通過寬帶連接,校園卡在校區(qū)間可通用,前提是服務(wù)器之間數(shù)據(jù)要同步。 針對學(xué)校的實際情況,校園一卡通可以實現(xiàn)以下幾個方面的功能:1 電子錢包功能:校區(qū)內(nèi)的所有的食堂,都可以使用一卡通進行交易。2 管理(身份識別)功能:校內(nèi)使用的各種證卡均可由校園一卡通代替,實現(xiàn)圖書館、電子閱覽室、學(xué)生公寓、考勤的身份識別一卡通。實現(xiàn)校內(nèi)所有重要場所的出入門禁管理。3 .金融功能:學(xué)生可以使用與校園卡關(guān)聯(lián)的銀行卡進行存取款、轉(zhuǎn)賬結(jié)算等金融業(yè)務(wù)1.3 系統(tǒng)需求: 中心數(shù)據(jù)庫:oracle11g 操作系統(tǒng):Windows xp,Linux 內(nèi)存要求:

3、不小于2G 交換空間:不小于8G 工作站操作系統(tǒng):Windows 2000/XP等 系統(tǒng)容量:系統(tǒng)帳戶容量10萬,可以擴充 子系統(tǒng)接入數(shù)量:128個,可以擴充 網(wǎng)絡(luò)設(shè)置:根據(jù)學(xué)校建筑布局結(jié)合現(xiàn)有走線管道,并為安全性考慮,提供兩種一卡通網(wǎng)絡(luò)的組建方案: (1)在現(xiàn)有校園主干網(wǎng)中分一個VLAN(虛擬局域網(wǎng)),將所有一卡通系統(tǒng)的計算機全部接入這個VLAN,以達到一卡通網(wǎng)絡(luò)與校園網(wǎng)邏輯上分開互相不能訪問。 (2)利用現(xiàn)有管道重新鋪設(shè)線路并添置新的網(wǎng)絡(luò)設(shè)置(交換機、集線器等),將一卡通系統(tǒng)組成一個單獨的網(wǎng)絡(luò),這樣在物理上與校園網(wǎng)分開。 校區(qū)互聯(lián): 應(yīng)用代理服務(wù)器機制,代理服務(wù)器只接受用戶的查詢并轉(zhuǎn)發(fā)服務(wù)

4、器中的數(shù)據(jù),在代理服務(wù)器上運行專用的軟件,定時負責(zé)與各個校區(qū)的服務(wù)器交換數(shù)據(jù)。 例圖如下:校區(qū)B校區(qū)A 代理服務(wù) 器 校區(qū)C 1.4系統(tǒng)設(shè)計原則: 安全、可靠、高效、易擴展1.5 設(shè)計背景: 項目名稱:校園一卡通系統(tǒng) 用戶:大學(xué)或高級中學(xué)1.6 參考資料: 1.oracle10g:Program with PL/SQL 2.數(shù)據(jù)庫系統(tǒng)概論 3.CSDN有關(guān)Oracle數(shù)據(jù)庫資料 二 、數(shù)據(jù)庫的物理結(jié)構(gòu)設(shè)計 2.1 數(shù)據(jù)庫設(shè)計:l 全局數(shù)據(jù)庫名稱:orcl l 數(shù)據(jù)庫字符集選擇 :采用UTF8字符集l 數(shù)據(jù)庫的DB_FILES 設(shè)置 使用默認的值200l OLTP類型:db_block_size

5、 用比較小的取值范圍: 2048 或 4096 2.2 數(shù)據(jù)庫控制文件配置: D:ORACLEORADATAORCLCONTROL01.CTL D:ORACLEORADATAORCLCONTROL02.CTL D:ORACLEORADATAORCLCONTROL03.CTL 2.3 數(shù)據(jù)庫重做日志文件配置: D:ORACLEORADATAORCLREDO01.LOG D:ORACLEORADATAORCLREDO02.LOG D:ORACLEORADATAORCLREDO03.LOG三 、數(shù)據(jù)庫的邏輯結(jié)構(gòu)設(shè)計 3.1 有關(guān)表空間的設(shè)計與實現(xiàn): 1、管理員信息表: admin_info 記錄系統(tǒng)

6、管理者的有關(guān)信息,權(quán)限分三級,用數(shù)字1,2,3來表示,權(quán)限大小遞減用戶編號姓名密碼權(quán)限 Create table admin_info ( admin_id varchar2(20) constraint admin_info_pk primary key , admin_name varchar2(20) not null, admin_password varchar2(15) not null, admin_privilege number(1); 2、用戶信息表: user_info記錄學(xué)生用戶的有關(guān)信息用戶編號姓名信息卡號性別院系/部門 用戶編號為學(xué)號或教職工編號Create tab

7、le user_info( user_num varchar2(20) constraint student_info_pk primary key , user_name varchar2(20) not null, user_card_id varchar2(20) not null , user_sex varchar2(4) not null, user_department varchar2(30) not null, Constraint user_info_fk foreign key( user_card_id) references user_info(user_num) )

8、; 3、一卡通信息表: info_card 記錄一卡通用戶的有關(guān)信息信息卡號用戶編號 剩余金額密 碼掛 失 0表示為非掛失狀態(tài),1表示為掛失狀態(tài) Create table info_card( card_num varchar2(20) primary key, card_user_id varchar2(20), card_leftmoney number(10,2) , card_password varchar2(20) not null, card_losted number(1) not null default(0), Constraint info_card_fk foreign

9、 key( card_user_id) references info_card(card_num) );4、 流水帳消費記錄表: consume_info 記錄用戶消費情況信息卡號消費金額消費日期終端號 Create table consume_info( consume_num varchar2(20) not null, consume_money number(10,2) not null, consume_date varchar2(20) not null, concume_machine_id number(3) not null);5、 存款/轉(zhuǎn)賬記錄表:save_money

10、記錄學(xué)生存款的情況信息卡號存款金額存款日期存款類型操作員編號 此表記錄學(xué)生存現(xiàn)、轉(zhuǎn)賬情況。 如果是轉(zhuǎn)賬:存款類型為 0 如果是存現(xiàn):存款類型為 1 操作員編號為POS機的編號(自動編號為0000)Create table save_money( save_user_id varchar2(20) primary key, save_money number(10,2) not null, save_date varchar2(20) not null, save_type number(1) not null default(0), save_operator_id varchar2(6) n

11、ot null);6、 連接銀行卡和一卡通的中間記錄表(銀校表):bank_campus 信息卡號儲蓄卡號儲蓄密碼儲蓄折號轉(zhuǎn)賬金額身份證號 僅用來作為一卡通用戶進行轉(zhuǎn)賬時的用戶安全驗證Create table save_money( bank_campus_userid varchar2(20) primary key, bank_campus_banknum varchar2(30) not null, bank_campus_bankpassword varchar2(6) not null, bank_campus_bankbook varchar2(30) not null , Ban

12、k_campus_transfer number(10,2) not null default(50.00), bank_campus_idcard varchar2(20) not null); 7、假設(shè)用戶在銀行開的賬戶表如下:bank_account儲蓄折號儲蓄卡號儲蓄密碼用戶姓名剩余金額身份證號 Create table bank_account( bank_account_bankbookid varchar2(30) primary key, bank_account_banknum varchar2(30) not null, bank_account_bankpassword

13、varchar2(6) not null, bank_account_name varchar2(20) not null , Bank_account_leftmoney number(10,2) not null , bank_account_idcard varchar2(20) not null); 8、退款銷戶記錄表: remove_user_info 用于記錄退款銷戶情況用戶編號退款金額 退款日期操作類型操作員 Create table remove_user_info( remove_userid varchar2(20) primary key, remove_money nu

14、mber(10,2) not null, remove_date varchar2(20) not null, remove_type number(1) not null, remove_operator varchar2(10) not null); 3.2 有關(guān)表索引的設(shè)計與實現(xiàn): 1.對學(xué)生用戶表按院系/部門建立索引:index_student Create index index_student on user_info(user_department); 2.對一卡通信息表的掛失字段建立索引:index_card_lost Create index index_card_lost

15、on info_card(card_losted); 3.3 有關(guān)視圖的設(shè)計與實現(xiàn): 1、終端交易記錄視圖:view_terminal_record終端號交易金額消費日期 Create or replace view view_terminal_record (terminal_id,terminal_trademoney,terminal_date) As select concume_machine_id,sum(consume_money),consume_date From consume_info Where concume_machine_id = &p_terminal_id O

16、rder by concume_machine_id,to_date(consume_date,DD-Mon-YY); 3.4 PL/SQL程序?qū)崿F(xiàn)(存儲過程和函數(shù)) 在用戶存在且一卡通沒有掛失的條件下實現(xiàn) 1、存現(xiàn)函數(shù) :Fun_save_money用來完成對一卡通現(xiàn)金的存儲, 存款不成功返回值為False,存現(xiàn)成功則返回為True Create or replace function Fun_save_money ( P_userid IN info_card.Card_num%TYPE, p_save_money IN info_card.Card_leftmoney%TYPE, P_o

17、peratorid IN varchar2, P_show_message OUT varchar2 ) return boolean Is Begin If p_save_money 0 then Update info_card Set card_leftmoney=card_leftmoney+p_save_money Where card_num=p_userid; Insert into save_money Values(p_userid,p_save_money,to_char(sysdate,yyyy-mm-dd hh:mi:ss),1,p_operatorid); P_sho

18、w_message=用戶 p_userid存現(xiàn)成功!; Return true; Else P_show_message = 存款金額非法??; Retrun false; End if End Fun_save_money; 2、轉(zhuǎn)賬函數(shù):Fun_hand_transfer和Proc_auto_transfer 用來從銀行儲蓄卡里面向一卡通里充值,可以自動充值也可手動充值。當(dāng)一卡通余額不足10元時系統(tǒng)可以自動向一卡通充值(默認值50元,可以修改),用戶也可手動用儲蓄卡向一卡通充值。 手動充值函數(shù):Fun_hand_transfer Create or replace function Fun_

19、hand_transfer ( P_posid IN number, p_tansfer_money IN bank_campus.bank_campus_transfer%TYPE, P_userid IN bank_campus.bank_campus_userid %TYPE, P_bank_account_num IN bank_campus.bank_campus_banknum%TYPE, P_bank_account_psw IN bank_campus.bank_campus_bankpassword%TYPE, P_show_message OUT varchar2 )ret

20、urn boolean Is V_bank_money number(10,2); Begin If p_tansfer_money 0 then V_bank_money = Fun_bank_interface(p_tansfer_money,P_bank_account_num,P_bank_account_psw); If v_bank_money !=0 then Update table_info_card -更新一卡通信息表 Set card_leftmoney=card_leftmoney + v_bank_money Where card_num=p_userid; Inse

21、rt into save_money -記錄轉(zhuǎn)賬信息 Values(p_userid,p_tansfer_money,to_char(sysdate,yyyy-mm-dd hh:mi:ss),0,p_posid); P_show_message=用戶 p_userid轉(zhuǎn)賬成功!; Return true; Else P_show_message=用戶 p_userid轉(zhuǎn)賬失敗!; Retrun false; End if Else P_show_message=輸入金額非法??; Return false; End if End Fun_hand_tansfer 自動充值存儲過程: Proc_a

22、uto_transfer Create or replace procedure Proc_auto_transfer Is V_money number(10,2); V_addmoney number(10,2); V_user_id varchr2(20); V_bank_cardid varchar2(30); V_bank_psw varchar2(6); Cursor auto_transfer_cursor is Select card_num,card_leftmoney From info_card Where card_leftmoney 0 and v_money-pta

23、nsfer_num0) then Update bank_account Set Bank_account_leftmoney=bank_account_leftmoney-p_tansfer_num Where P_tansfer_accountid=bank_account_banknum And P_tansfer_accountpassword=bank_account_bankpassword ; Update P_show_message=轉(zhuǎn)賬成功!; Return p_tansfer_num; Else P_show_message=轉(zhuǎn)賬失敗?。?Return 0; End if

24、 End Fun_bank_interface; 3、就餐消費函數(shù):Fun_consume Create or replace function Fun_consume ( p_user_id IN info_card.card_num%TYPE, P_consume_money IN consume_info.consume_money%TYPE, P_terminal_id IN consume_info.concume_machine_id%TYPE, P_show_message OUT varchar2 ) return boolean Is V_leftmoney number(1

25、0,2); Begin Select card_leftmoney Into v_leftmoney From info_card Where card_num=p_user_id ; If v_leftmoney p_consume_money then Update info_card Set card_leftmoney=card_leftmoney - p_consume_money Where card_num=p_user_id ; Insert into consume_info Values(p_user_id,p_consume_money,to_char(sysdate,y

26、yyy-mm-dd hh:mi:ss),p_terminal_id); P_show_message=用戶|p_user_id|消費成功!; Return true; Else P_show_message=用戶|p_user_id|消費失敗!; Return false; End if End Fun_consume 4、退款函數(shù):Fun_back_remove 記錄用戶退款及刪除用戶并寫入日志表 Create or replace function Fun_back_remove ( p_user_id IN info_card.card_num%TYPE, P_operator IN r

27、emove_user_info.remove_operator%TYPE, )return varchar2 Is V_back_money number(10,2); Begin Select card_leftmoney Into v_back_money From info_card Where p_user_id = card_num; If v_back_money0 then Delete from bank_campus where bank_campus_userid=p_user_id; Delete from info_card where card_num=p_user_

28、id; Insert into remove_user_info Values(p_user_id,v_back_money,to_char(sysdate,yyyy-mm-dd hh:mi :ss),0,p_operator); Return (請退給用戶|p_user_id|v_back_money|元|并刪除用戶!); Else Delete from bank_campus where bank_campus_userid=p_user_id; Delete from info_card where card_num=p_user_id; Insert into remove_user

29、_info Values(p_user_id,v_back_money,to_char(sysdate,yyyy-mm-dd hh:mi :ss),0,p_operator); Return(用戶|p_user_id|一卡通里已無余額!|并刪除用戶!); End if End Fun_back_remove 四 、數(shù)據(jù)庫運行與維護方案 4.1 數(shù)據(jù)庫的備份策略 DBA要針對一卡通系統(tǒng)的特殊性制定出多種備份方案,以保證一旦發(fā)生故障能盡快將數(shù)據(jù)庫恢復(fù)到某種一致狀態(tài),并盡可能減少對數(shù)據(jù)庫的損壞。 1.可利用oracle數(shù)據(jù)庫所提供的備份技術(shù)進行數(shù)據(jù)庫級、用戶級及表級備份 2.可利用動態(tài)增量轉(zhuǎn)儲技術(shù)對數(shù)據(jù)庫進行周期性備份 3.可定時對控制文件和日志文件進行備份 4.可以采用數(shù)據(jù)庫鏡像文件的方式對其進行轉(zhuǎn)儲備份 4.2數(shù)據(jù)庫的恢復(fù)策略 由于計算機系統(tǒng)中的硬件故障、軟件的錯誤、操作員的失誤以及惡意的破壞是不可避免的,這些故障輕則造成運行事務(wù)非正常中斷,影響數(shù)據(jù)庫的數(shù)據(jù)正確性,重則破壞數(shù)據(jù)庫,使數(shù)據(jù)庫中

溫馨提示

  • 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)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論