【正文】
use grxxgocreate view view_rjb01as select title as 姓名, addtime as 性別, place as 年齡, thing as 生日f(shuō)rom rjbwhere place=39。寢室39。goselect * from view_rjb01use grxxgocreate unique nonclustered index index_bwlon bwl(addtime)use grxxgocreate unique nonclustered index index_bwl01on bwl(place,btime)use grxxgocreate unique nonclustered index index_ineon ine(addtime)use grxxgocreate unique nonclustered index index_ine01on ine(addtime,project)use grxxgocreate unique nonclustered index index_ineon out(addtime)use grxxgocreate unique nonclustered index index_rjbon rjb(thing)use grxxgocreate unique nonclustered index index_txlon txl(tel)use grxxgocreate unique nonclustered index index_txl01on txl(tname,tel)use grxxgocreate unique nonclustered index index_yhbon yhb(utel)use grxxgocreate unique nonclustered index index_yhb01on yhb(utel,usex)create procedure grxx_bwlasselect btime as 時(shí)間, place as 地點(diǎn), thing as 內(nèi)容from bwlwhere place=39。武昌分校39。gouse grxxexec grxx_bwlcreate procedure grxx_ineasselect project as 項(xiàng)目, imoney as 數(shù)額, addtime as 添加時(shí)間from inewhere project=39。生活費(fèi)39。gouse grxxexec grxx_inecreate procedure grxx_outasselect project as 項(xiàng)目, imoney as 數(shù)額, addtime as 添加時(shí)間from outwhere project like 39。買%39。gouse grxxexec grxx_outUSE grxxGOCREATE PROCEDURE grxx_out01(@yx int )AS SELECT DISTINCT project as 項(xiàng)目, imoney as 數(shù)額, addtime as 時(shí)間FROM outWHERE imoney=@yx GOExec grxx_out0139。20039。create procedure grxx_rjbasselect title as 主題, place as 地點(diǎn), addtime as 添加時(shí)間, thing as 內(nèi)容from rjbwhere place=39。寢室39。gouse grxxexec grxx_rjbcreate procedure grxx_txlasselect tname as 姓名, tel as 電話, job as 職業(yè), qq as from txlwhere tname like 39。李%39。gouse grxxexec grxx_txlUSE grxxGOCREATE PROCEDURE grxx_bwl01(@yx varchar(30) )AS SELECT DISTINCT btime as 時(shí)間, place as 地點(diǎn), thing as 內(nèi)容FROM bwlWHERE place=@yx GOExec grxx_bwl0139。武昌分校39。create procedure grxx_yhbasselect uname as 姓名, utel as 電話, usex as 性別from yhbwhere usex=39。男39。gouse grxxexec grxx_yhbUSE grxxGOCREATE PROCEDURE grxx_yhb01(@yx varchar(10) )AS SELECT DISTINCT uname as 姓名, usex as 性別, uage as 年齡, utel as 電話 FROM yhbWHERE uname=@yx GOExec grxx_yhb0139。戟長(zhǎng)峰39。use grxxgoalter table yhbadd constraint yhb_ckcheck(usex=39。男39。 or usex=39。女39。)use grxxgoalter table yhbadd constraint yhb01_uk unique (uqq)use grxxgoalter table txladd constraint txl_uk unique (tel)use grxxgo alter table txldrop constraint txl_pkgoalter table txladd constraint txl01_pk primary key (tel,qq)use grxxgoalter table rjbadd constraint title_ckcheck(len(title)=1 and len(title)=20)use grxxgoalter table txladd constraint txl_uk unique (tel)use grxxgo alter table outadd constraint out_pk primary key (addtime,project)use grxxgoalter table outadd constraint out_ckcheck(imoney0)use grxxgoalter table bwladd constraint bwl_uk unique (thing)use grxxgoCreate trigger update_student ON bwlFOR INSERT, UPDATEAS PRINT 39。插入或更新了數(shù)據(jù)表student!39。use grxxgo CREATE TRIGGER utel_grade ON yhbFOR insert,updateAS if update(utel) print 39。一行受影響39。CREATE TRIGGER txl_grade ON txlFOR insertAS begin update tel set tel=39。null39。 where len(tel)11end 5. 運(yùn)行與測(cè)試表和視圖use grxxgoselect * from yhbwhere uname=39。戟長(zhǎng)峰39。use grxxgoselect * from txlwhere tname=39。王建39。use grxxgoselect title as 主題, addtime as 時(shí)間, place as 地點(diǎn), thing as 內(nèi)容 from rjbwhere addtime=39。12月號(hào)39。use grxxgoselect as收入, as支出, as 時(shí)間 from ine,outwhere = and =39。12月號(hào)39??偨Y(jié)這一次課程設(shè)計(jì),從開(kāi)始做到現(xiàn)在完工,感受很多。本次課程設(shè)計(jì),我實(shí)現(xiàn)的功能很簡(jiǎn)單,但是十分考驗(yàn)對(duì)數(shù)據(jù)庫(kù)的基礎(chǔ)知識(shí),建庫(kù),建表,插入數(shù)據(jù),寫(xiě)視圖,索引,約束,觸發(fā)器,或許我做的都是最簡(jiǎn)單的,但我這一次,是把過(guò)程完整都做出來(lái)了,不同于我們以前做實(shí)驗(yàn)時(shí),老師提供我們數(shù)據(jù)庫(kù),我們?cè)侔l(fā)揮。自己獨(dú)立做,感受深刻些! 剛開(kāi)始設(shè)計(jì)數(shù)據(jù)庫(kù)時(shí),心中一些概念還不是很明確,準(zhǔn)備一口氣就寫(xiě)下來(lái),但發(fā)現(xiàn)做的很慢,這時(shí)才明白,自己的關(guān)系模式?jīng)]設(shè)計(jì)好,邊想邊做,是很難做出來(lái)的,就像老師平時(shí)說(shuō)的一樣,你知道,就知道,不知道就不知道,自己想是很難做出來(lái)的,還得回去看書(shū),我于是把老師的PPT重新看了一遍,基礎(chǔ)知識(shí)溫習(xí)了一下,在去做的時(shí)候,輕松多了,我認(rèn)為基礎(chǔ)很重要! 確定實(shí)體,選定關(guān)系式之后,在word畫(huà)ER圖,以前覺(jué)得做這些東西,很困難,因?yàn)閺膩?lái)沒(méi)做過(guò),但我耐心的畫(huà),時(shí)間長(zhǎng)一點(diǎn),都完成了,老師也說(shuō)可以,我覺(jué)得有時(shí)候一些事情并沒(méi)有我們想的那樣困難,只要我們耐心的做,都是可以做好的. 我認(rèn)為在這次課程設(shè)計(jì)中,我有一點(diǎn)做的不好,就是時(shí)間沒(méi)安排好,剛開(kāi)始時(shí)間很充足,不著急,最后導(dǎo)致時(shí)間有點(diǎn)趕,以后做事一定要安排好,快點(diǎn)完成! 在這次課程設(shè)計(jì)中,感謝我們的指導(dǎo)老師吳老師,他給予我們的指導(dǎo)時(shí)十分詳細(xì),從ER圖到版面,都一一指導(dǎo),在次,感謝您!