在線考試系統(tǒng)數(shù)據(jù)庫設(shè)計_第1頁
在線考試系統(tǒng)數(shù)據(jù)庫設(shè)計_第2頁
在線考試系統(tǒng)數(shù)據(jù)庫設(shè)計_第3頁
在線考試系統(tǒng)數(shù)據(jù)庫設(shè)計_第4頁
在線考試系統(tǒng)數(shù)據(jù)庫設(shè)計_第5頁
已閱讀5頁,還剩28頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

1、數(shù)據(jù)庫設(shè)計文檔成員:曹麗瓊 馮繼偉 劉維毅 班級08軟工三班 指導(dǎo)老師:郭東恩 日 期:2011-5-22 目錄數(shù)據(jù)庫設(shè)計文檔1目錄2數(shù)據(jù)庫設(shè)計文檔31引言31.1編寫目的31.2項目來源31.3文檔約定31.4預(yù)期讀者和閱讀建議31.5參考資料32數(shù)據(jù)庫命名規(guī)則43數(shù)據(jù)庫設(shè)計說明53.1數(shù)據(jù)庫邏輯設(shè)計5數(shù)據(jù)詞典5實體關(guān)系6E_R圖10SR關(guān)系:103.2數(shù)據(jù)庫物理設(shè)計113.3數(shù)據(jù)庫分布113.4基表設(shè)計113.4.1.tb_user: 考生信息表123.4.2.tb_invigilate: 監(jiān)考人員信息表133.4.3.tb_admin: 管理員信息表133.4.4.tb_page:考試試

2、卷信息表143.4.5.tb_select:選擇題信息表153.4.6.tb_boolean:判斷題信息表163.4.7.tb_answer:簡答題信息表173.4.8.tb_subject:考試科目信息表183.5視圖設(shè)計193.6索引設(shè)計193.7序列設(shè)計193.8完整性設(shè)計203.9授權(quán)設(shè)計203.10觸發(fā)器設(shè)計203.11存儲過程設(shè)計243.11.1CRUD中的CUD三個操作243.12數(shù)據(jù)復(fù)制設(shè)計264查詢記錄語句265詞匯表276歷史數(shù)據(jù)處理27數(shù)據(jù)庫設(shè)計文檔1 引言1.1 編寫目的本文檔是本項目開發(fā)中至關(guān)重要的一部分,通過本檔編寫,對本項目中相關(guān)數(shù)據(jù)存儲信息進(jìn)行明確定位,對數(shù)據(jù)結(jié)

3、構(gòu)等相關(guān)信息進(jìn)行明確說明。本文檔盡可能的詳細(xì)說明各個實體的屬性及相互聯(lián)系,使開發(fā)人員的開發(fā)效率盡可能增加。1.2 項目來源 實訓(xùn)要求 開發(fā)人員:全體成員 文檔使用者:oracle 開發(fā)人員、 程序設(shè)計人員1.3 文檔約定1.4 預(yù)期讀者和閱讀建議 開發(fā)人員: 對oracle和java熟悉 測試人員: 對java及oracle有一定的了解1.5 參考資料1 在線考試系統(tǒng)可行性分析2 在線考試系統(tǒng)需求分析3 項目(bbs)數(shù)據(jù)庫設(shè)計文檔劉維毅4 2 數(shù)據(jù)庫命名規(guī)則 db_examonline: 在線考試系統(tǒng)數(shù)據(jù)庫 tb_invigilate: 監(jiān)考人員 tb_user: 學(xué)生或用戶信息表 tb_s

4、elect:選擇題相關(guān)信息表 tb_answer:簡答題相關(guān)信息 tb_boolean:判斷題相關(guān)信息 tb_admin: 管理員信息表 tb_page:數(shù)據(jù)庫測試試題3 數(shù)據(jù)庫設(shè)計說明3.1 數(shù)據(jù)庫邏輯設(shè)計數(shù)據(jù)字典l 考生屬性:編號tid,姓名uname,登錄密碼upassword,學(xué)號uno,班級uclass,考試狀態(tài)ustatel 監(jiān)考人員屬性:編號tid,姓名name,登錄密碼passwordl 管理員屬性:編號aid,姓名name,登錄密碼passwordl 試卷屬性:編號pid,科目subject, 選擇題數(shù)量snum, 判斷題數(shù)量bnum, 問答題數(shù)量anum,考試時間pageD

5、atel 選擇題屬性:編號id,題目name,選項A optionA,選項B optionB,選項C option C,選項D optionD,所屬科目subjectl 判斷題屬性:編號id,題目name,對選項yes,錯選項no ,所屬科目subjectl 簡答題屬性:編號id,題目name, 所屬科目subjectl 科目屬性:編號sid,科目subject實體關(guān)系 編號姓名學(xué)號考試狀態(tài)登錄密碼班級考生監(jiān)考人員編號姓名登錄密碼管理員姓名登錄密碼編號考試試卷選擇題數(shù)目判斷題數(shù)目科目名稱簡答題數(shù)目編號編號題目選項A科目名稱選項D選項B選項C選擇題判斷題題目科目名稱編號考試時間簡答題題目科目名稱

6、編號科目科目名稱編號E_R圖考生監(jiān)考人員管理員選擇題簡答題判斷題科目考試試卷組成監(jiān)考管理做組成SR關(guān)系:學(xué)生關(guān)系表:Stb_user(usid,uname,upassword,uno,uclass,ustate)監(jiān)考人員關(guān)系表:Stb_invigilate(tid,name,password)管理員信息關(guān)系:Stb_admin(aid,name,password)考試試卷信息關(guān)系:Stb_page(usid,pid,subject,snum,bnum,anum,pageDate)選擇題信息關(guān)系:Stb_select(id,pid,subject,name,optionA,optionB,opt

7、ionC,optionD)判斷題信息關(guān)系:Stb_boolean(id,pid,subject,name,yes,no)簡答題信息關(guān)系:Stb_answer(id,pid,subject,name)科目信息關(guān)系:Stb_subject(sid,subject)3.2 數(shù)據(jù)庫物理設(shè)計暫無3.3 數(shù)據(jù)庫分布暫無3.4 基表設(shè)計在線考試系統(tǒng)數(shù)據(jù)庫:3.4.1. tb_user: 考生信息表屬性:編號Tid,姓名name,登錄密碼password,學(xué)號number,班級class,考試狀態(tài)state字段名稱數(shù)據(jù)類型長度主鍵描述Tidnumber10是主鍵標(biāo)識unameVarchar250否學(xué)生姓名up

8、asswordchar16否登錄密碼unonumber10否學(xué)號uclassVarchar250否班級ustatenumber1否考試狀態(tài)Create table tb_user( Tid number(10) primary key, Uname varchar2(50), Upassword char(16), Uno number(10), Uclass varchar2(50), Ustate number(1) );3.4.2. tb_invigilate: 監(jiān)考人員信息表屬性:編號tid,姓名name,登錄密碼password字段名稱數(shù)據(jù)類型長度主鍵描述tidnumber10是主鍵

9、標(biāo)識nameVarchar250否姓名passwordchar16否登錄密碼Create table tb_invigilate( Tid number(10) primary key, Name varchar2 (50), Password char(16) );3.4.3. tb_admin: 管理員信息表屬性:編號aid,姓名name,登錄密碼password字段名稱數(shù)據(jù)類型長度主鍵描述aidnumber10是主鍵標(biāo)識nameVarchar250否姓名passwordchar16否登錄密碼Create table tb_admin( Aid number(10) primary key

10、, Name varchar2(50), Password char(16) );3.4.4. tb_page:考試試卷信息表屬性:編號pid,科目subject, 選擇題數(shù)量snum, 判斷題數(shù)量bnum, 問答題數(shù)量anum,考試時間pageDate字段名稱數(shù)據(jù)類型長度主鍵描述pidnumber10是主鍵標(biāo)識subjectVarchar250否科目(外鍵)snumnumber2否選擇題數(shù)量bnumnumber2否判斷題數(shù)量anumnumber2否問答題數(shù)量pageDatedate/否考試時間tidnumber10是學(xué)生編號(外鍵) Create table tb_page( Pid num

11、ber(10) primary key, Subject varchar2(50), Snum number(2), Bnum number(2), Anum number(2), pageDate date, tid number(10), constraint page_FK foreign key (subject) references tb_subject(subject), constraint page_FK2 foreign key(tid) references tb_user(tid) );3.4.5. tb_select:選擇題信息表屬性:編號id,題目name,選項A

12、optionA,選項B optionB,選項C option C,選項D optionD,所屬科目subject字段名稱數(shù)據(jù)類型長度主鍵描述idnumber10是主鍵標(biāo)識nameVarchar250否題目optionAVarchar2100否選項AoptionBVarchar2100否選項BoptionCVarchar2100否選項CoptionDVarchar2100否選項DsubjectVarchar250否科目(外鍵)pidnumber10是試卷編號(外鍵) Create table tb_select( Id number(10) primary key, Name varchar2(

13、50), optionA varchar2(100), optionB varchar2(100), optionC varchar2(100), optionD varchar2(100), subject varchar2(50), pid number(10), constraint select_FK foreign key(subject) references tb_subject(subject), constraint select_FK2 foreign key(pid) references tb_page(pid) );3.4.6. tb_boolean:判斷題信息表 屬

14、性:編號id,題目name,對選項yes,錯選項no ,所屬科目subject字段名稱數(shù)據(jù)類型長度主鍵描述idnumber10是主鍵標(biāo)識nameVarchar250否題目subjectVarchar250否科目(外鍵)pidnumber10否試卷編號(外鍵) Create table tb_boolean( id number(10) primary key, Name varchar2(50), Subject varchar2(50), Pid number(10), constraint boolean_FK foreign key(subject) references tb_subj

15、ect(subject), constraint boolean_FK2 foreign key(pid) references tb_page(pid) );3.4.7. tb_answer:簡答題信息表屬性:編號id,題目name, 所屬科目subject字段名稱數(shù)據(jù)類型長度主鍵描述idnumber5是主鍵標(biāo)識nameVarchar250否題目subjectVarchar250否科目(外鍵)pidnumber10否試卷編號(外鍵)Create table tb_answer( Id number(5) primary key, Name varchar2(50), Subject varc

16、har2(50), Pid number(10), constraint answer_FK foreign key(subject) references tb_subject(subject), constraint answer_FK2 foreign key(pid) references tb_page(pid) );3.4.8. tb_subject:考試科目信息表 屬性:編號sid,科目subject字段名稱數(shù)據(jù)類型長度主鍵描述sidnumber10否科目自增編號subjectVarchar250 是主鍵標(biāo)識 Create table tb_subject( Sid number

17、(10) , Subject varchar2(50) primary key );/備注uid是關(guān)鍵字已被系統(tǒng)占用3.5 視圖設(shè)計3.6 索引設(shè)計3.7 序列設(shè)計 設(shè)計目的:通過序列的設(shè)計,可以使得編號可以進(jìn)行自增,從而達(dá)到設(shè)計目的。l Tb_sq 序列自動進(jìn)行遞增初值為:1遞增為:1最大值:無Create sequence tb_sqIncrement by 1Start with 1NomaxvalueNocycleCache 10;l Tb_invigilate_sq監(jiān)考人員的 tid 自動進(jìn)行遞增Create sequence tb_invigilate_sqIncrement by

18、 10Start with 10NomaxvalueNocycleCache 10;3.8 完整性設(shè)計請參閱本文檔的基表設(shè)計的外鍵設(shè)置3.9 授權(quán)設(shè)計3.10 觸發(fā)器設(shè)計l Tb_user_triggerCreate or replace trigger tb_user_triggerBefore insert on tb_userFor each rowDeclareNext_no number;BeginSelect tb_sq.nextvalInto next_noFrom dual;:new.tid:=next_no;End;/-insert into tb_user (uname,

19、upassword,uno, uclass, ustate)-values();l Tb_invigilate_triggerCreate or replace trigger tb_invigilate_triggerBefore insert on tb_invigilateFor each rowDeclareNext_no number;BeginSelect tb_sq.nextvalInto next_noFrom dual;:new.tid:=next_no;End;l Tb_admin_triggerCreate or replace trigger tb_admin_trig

20、gerBefore insert on tb_adminFor each rowDeclareNext_no number;Begin Select tb_sq.nextvalInto next_noFrom dual;:new.aid:=next_no;End;l Tb_page_triggerCreate or replace trigger tb_page_triggerBefore insert on tb_pageFor each rowDeclareNext_no number;Begin Select tb_sq.nextvalInto next_noFrom dual;:new

21、.pid:=next_no;End;l Tb_select_triggerCreate or replace trigger tb_select_triggerBefore insert on tb_selectFor each rowDeclareNext_no number;BeginSelect tb_sq.nextvalInto next_noFrom dual;:new.id:=next_no;End;l Tb_boolean_triggerCreate or replace trigger tb_boolean_triggerBefore insert on tb_booleanF

22、or each rowDeclareNext_no number;BeginSelect tb_sq.nextvalInto next_noFrom dual;:new.id:=next_no;End;l Tb_answer_triggerCreate or replace trigger tb_answer_triggerBefore insert on tb_answerFor each rowDeclareNext_no number;Begin Select tb_sq.nextvalInto next_noFrom dual;:new.id:=next_no;End;l Tb_sub

23、ject_triggerCreate or replace trigger tb_subject_triggerBefore insert on tb_subjectFor each rowDeclare Next_no number;BeginSelect tb_sq.nextvalInto next_noFrom dual;:new.sid:=next_no;End;3.11 存儲過程設(shè)計3.11.1 CRUD中的CUD三個操作-向試卷表中插入信息(create操作)Create or replace procedure insert_tb_page(p_subject in tb_pag

24、e.subject%type,p_snum in tb_page.snum%type,p_bnum in tb_page.bnum%type,p_anum in tb_page.anum%type,p_pageDate in tb_page.pageDate%type,-插入系統(tǒng)時間sysdatep_tid in tb_page.tid%type)asBeginInsert into tb_page(subject,snum,bnum,anum,pageDate,tid) values(p_subject,p_snum,p_bnum,p_anum,p_pageDate,p_tid);Excep

25、tion When DUP_VAL_ON_INDEX thenDbms_output.put_line(subject primary key error!);When others thenDbms_output.put_line(異常);End insert_tb_page;-/執(zhí)行過程: execute insert_tb_page(,);-向判斷題表中插入信息(create操作)Create or replace procedure insert_tb_boolean(b_name in tb_%type,b_subject in tb_boolean.subj

26、ect%type,b_pid in tb_boolean.pid%type) asbeginInsert into tb_boolean(name, subject,pid) values(b_name,b_subject,b_pid);End insert_tb_boolean;-/執(zhí)行過程: execute insert_tb_boolean(,);-向簡答題表中插入信息Create or replace procedure insert_tb_answer(a_name in tb_%type,a_subject in tb_answer.subject%type,

27、a_pid in tb_answer.pid%type)as BeginInsert into tb_answer(name,subject,pid) values(a_name,a_subject,a_pid);End insert_tb_answer;-向科目表中插入信息Create or replace procedure insert_tb_subject(s_subject in tb_subject.subject%type)asBeginInsert into tb_subject(subject) values(s_subject);Exception When DUP_VAL

28、_ON_INDEX thenDbms_output.put_line(subject primary key error!);When others thenDbms_output.put_line(異常);End insert_tb_subject;-向選擇題表中插入信息Create or replace procedure insert_tb_select(s_name tb_%type,s_optionA tb_select.optionA%type,s_optionB tb_select.optionB%type,s_optionC tb_select.optionC%type,s_optionD tb_select.optionD%type,s_subject tb_select.subject%type,s_pid tb_select.pid%type)asBegin Insert into tb_select(name, optionA, optionB, optionC, optionD, subject, pid) values(s_name,s_optionA,s_optionB,s_optionC,s_optionD,s_subject,s_pid);End

溫馨提示

  • 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)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論