




版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
1、數(shù)據(jù)庫系統(tǒng)概論實驗報告學 號: 姓 名:提交日期:2010-12-15成 績:【實驗名稱】學生選課系統(tǒng)的數(shù)據(jù)庫設計與實現(xiàn)【實驗內(nèi)容】1、熟悉數(shù)據(jù)庫設計方法;2、熟悉E-R圖到關系模式的轉(zhuǎn)換;3、掌握SQL Server 2005數(shù)據(jù)庫的創(chuàng)建SQL語句,理解數(shù)據(jù)庫文件組、文件邏輯名和物理名稱 的具體含義;4、掌握SQL Server 2005中用SQL語句建立數(shù)據(jù)庫表,設置數(shù)據(jù)庫完整性約束;5、掌握用SQL Server 2005建立表的關系圖,清楚的表示各表之間的聯(lián)系。 【實驗步驟】一、數(shù)據(jù)庫的邏輯設計圖(一)班級、學生、課程實體類型及聯(lián)系型的 ER圖班級 學生、課程實體的E限圈圖(二)班級實
2、體的分ER圖班圾實悴的E-R圖圖(三)課程實體的分ER圖東北大學秦皇島分校電子信息系第1頁指導教師:李佳音第2頁指導教師:李佳音圖(四)學生實體的ER圖將上述的E-R圖轉(zhuǎn)換為關系模型,關系的主鍵用下橫線標出。學生 課程 班級 選課班級號) 學分)(學號,姓名,性別,年齡,(課程號,課程名,課時, 班級號,班級名,人數(shù),專業(yè))(課程號學號,成績)數(shù)據(jù)庫的物理設計1.建表語句:本數(shù)據(jù)庫共創(chuàng)建了四張表,其建表語句如下1 .班級表create tableclass(classNo intclassNamenot null primary key , char ( 20),sdept char ( 20
3、),number int )東北大學秦皇島分校電子信息系2 學生表create table stude nt(stude ntNo int not n ullprimary keystudentName char (20 ),sex char (20),age int ,classNo int )3.課程表create table course(courseNo int not nullprimary key ,courseName char ( 20),grade int )4.選課表create table choice(studentNoint ,courseNo int 。result
4、 int ,primary key ( studentNo, courseNo )2.說明外碼語句altertablechoiceaddforeig nkey (studentNo)refere ncesstudent ( studentNo)foreig nkey ( courseNo )refere ncescourse (courseNo )altertablestude ntaddforeig nkey (classNo )refere ncesclass (classNo )3 .記錄插入語句:(1) class 表:in sertclassvalues(40801,yyy,os,3
5、5)in sertclassvalues(40802,XX,ad,45)in sertclassvalues(40803,rr,cs,36)in sertclassvalues(40804,yy,os,35)in sertclassvalues(40805,ee,ry,78)in sertclassvalues(40806,yyy,os,35)in sertclassvalues(40807,xg,ad,45)in sertclassvalues(40808,ry,cs,36)in sertclassvalues(40809,yd,os,65)東北大學秦皇島分校電子信息系第5頁指導教師:李佳音
6、in sertclassvalues( 408010 , eg,ry,48)(2)stude nt表:in sertstude ntvalues(10001,aa,f,23 , 40801 )in sertstude ntvalues(10002 , df,f,23 , 40802 )in sertstude ntvalues(10003 , adf,f,22 , 40802 )in sertstude ntvalues(10004 , gh,m,23 , 40803 )in sertstude ntvalues(10005 , dc,f,24 , 40804 )in sertstude nt
7、values(10006 , sd,m,23 , 40802 )in sertstude ntvalues(10007 , dfc,f,23 , 40803 )in sertstude ntvalues(10008 , xc,m,25 , 40805 )in sertstude ntvalues(10009 , sd,f,23 , 40806 )in sertstude ntvalues(100010 , cv,f,27 , 40806 )(3)course表:in sertcoursevalues(1, operating,48,8)in sertcoursevalues(2, comput
8、er,24 , 4)in sertcoursevalues(3, music,56, 12)in sertcoursevalues(4, compile,48, 8)in sertcoursevalues(5, oracle,32, 6)in sertcoursevalues(6,sql, 48,8)(4) choice 表:in sertchoicevalues ( 10001 , 1, 80 )in sertchoicevalues ( 10001 , 2, 85 )in sertchoicevalues ( 10002 , 3, 86 )in sertchoicevalues ( 100
9、02 , 5,45 )in sertchoicevalues ( 10003 , 1, 80 )in sertchoicevalues ( 10004 , 2, 87 )in sertchoicevalues ( 10004 , 6, 89 )in sertchoicevalues ( 10005 , 1, 90 )in sertchoicevalues ( 10005 , 4, 100 )in sertchoicevalues ( 10006 , 1,60 )in sertchoicevalues ( 10006 , 3,49 )in sertchoicevalues ( 10007 , 5
10、, 70 )in sertchoicevalues ( 10008 , 1,70 )in sertchoicevalues ( 10008 , 6, 78 )in sertchoicevalues ( 10009 , 2, 80 )in sertchoicevalues ( 100010 , 3, 78)in sertchoicevalues ( 100010 , 1, 80)in sertchoicevalues ( 100010 , 2, 78)in sertchoicevalues ( 100010 , 4, 89)in sertchoicevalues ( 100010 , 5, 45
11、)4、查詢記錄:1選擇輸出學號、姓名滿足性別為女,年齡小于25selectstudentNo, studentNamefrom stude ntwhere sex =f and age 50的班級輸出其班級號和人數(shù)createview NumasselectclassNo , numberfrom classwhere number 50查詢語句select * from Nums結(jié)果class No1 4CSQ52 40309number78656. 插入數(shù)據(jù)插入數(shù)據(jù):插入student表中一個學生,學生名為newstudent性別為女,年齡34,班級號為40806insertstudent
12、values ( 100011 , newstudent,f , 24,40806 )3結(jié)果Lj消息gene 好 mN口st(tentNafnpA,das&No11DD01f234CBO113002df卡4W2310001adf224083?41QD043hm408(510005def24408C4G1MXKsdtn4080?71SD07dfGf234C8O18iM)oaxefti254080S91DD09sdf234CED&Ifl1TO010旳f77111QDQ11f2A iiaBiiiauiii 4辟三、利用SQL Server 2005的Management Studio來創(chuàng)建表的關系圖
13、,創(chuàng)建好的關系 圖如下所示:四. 實驗體會通過這次實驗,讓我對sql server2005 的使用更加熟悉了,同時也加深了我對課本上數(shù)據(jù)庫 知識的理解,這次實驗可以說是我第一次完成的一個整體的數(shù)據(jù)庫實驗。此次實驗中,我完成了從概念設計到邏輯設計,也就是完成了ER圖的設計并完成了向關系模型的轉(zhuǎn)換,完成了數(shù)據(jù)庫的建立、表的建立、視圖的創(chuàng)建,最后還完成了表之間的關系圖。一個數(shù)據(jù)庫 的創(chuàng)建首先要對客戶的需求進行充分的分析,找出創(chuàng)建數(shù)據(jù)庫所需的實體和實體間的關系畫出E-R圖,確定要創(chuàng)建的表的數(shù)量和每張表的屬性、主鍵和外鍵。在動手實驗的過程中我遇到很多困難,比如如何刪除表中的數(shù)據(jù)但不保留到日志文件中,數(shù)據(jù)
14、的 不普遍性所造成的查詢等操作的空表等等,但是正是這些問題才讓我學到了更多,同時也享受到了解 決問題后的喜悅。更重要的是,我對數(shù)據(jù)庫產(chǎn)生了濃厚的興趣,相信以后會把學到的東西應用到實踐 中去的。東北大學秦皇島分校電子信息系第10頁指導教師:李佳音五. 附錄(SQL語句)-班級表create table class(classNo int not n ull primary key, className char(20), sdept char(20),nu mber int)-學生表create table stude nt(stude ntNo int not n ull primary ke
15、y, stude ntName char(20),sex char(20),age int,classNo int) create table course(courseNo int not n ull primary key,courseName char(20), courseTime int, grade int)create table choice(stude ntNo i nt,courseNo int,result int,primary key(stude ntNo,courseNo)alter table choiceadd foreig n key (stude ntNo)
16、 refere nces stude nt(stude ntNo), foreig n key (courseNo) refere nces course(courseNo)alter tablestude ntadd foreig n key (classNo) refere nces class(classNo) in sert class values (40801,yyy,os,35) in sert class values (40802,xx,ad,45) in sert class values (40803,rr,cs,36) in sert class values (408
17、04,yy,os,35) in sert class values (40805,ee,ry,78) in sert class values (40806,yyy,os,35) in sert class values (40807,xg,ad,45) in sert class values (40808,ry,cs,36) in sert class values (40809,yd,os,65) in sert class values (408010,eg,ry,48) select * from stude nt in sert stude nt values(10001,aa,f
18、,23,40801) in sert stude nt values(10002,df,f,23,40802) in sert stude nt values(10003,adf,f,22,40802) in sert stude nt values(10004,gh,m,23,40803) in sert stude nt values(10005,dc,f,24,40804) in sert stude nt values(10006,sd,m,23,40802) in sert stude nt values(10007,dfc,f,23,40803) in sert stude nt
19、values(10008,xc,m,25,40805) in sert stude nt values(10009,sd,f,23,40806) in sert stude nt values(100010,cv,f,27,40806)in sert course values(1,operat in g,48,8) in sert course values(2,computer,24,4) in sert course values(3,music,56,12) in sert course values(4,compile,48,8) in sert course values(5,or
20、acle,32,6) in sert course values(6,sql,48,8)in sert choice values(10001,1,80) in sert choice values(10001,2,85) in sert choice values(10002,3,86) in sert choice values(10002,5,45) in sert choice values(10003,1,80) in sert choice values(10004,2,87) in sert choice values(10004,6,89) in sert choice val
21、ues(10005,1,90) in sert choice values(10005,4,100) in sert choice values(10006,1,60) in sert choice values(10006,3,49) in sert choice values(10007,5,70) in sert choice values(10008,1,70) in sert choice values(10008,6,78) in sert choice values(10009,2,80) in sert choice values(100010,3,78) in sert choice values(100010,1,80) in sert choic
溫馨提示
- 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. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 二手房產(chǎn)交易合同樣本
- 居民供暖費用支付合同
- 四川省達州市開江縣重點達標名校2024-2025學年中考預測卷(全國I卷)物理試題試卷含解析
- 江西省宜春市宜豐中學2024-2025學年高三綜合練習數(shù)學試題卷(三模)含解析
- 遼寧何氏醫(yī)學院《形式邏輯》2023-2024學年第二學期期末試卷
- 凱里學院《時間序列分析課程》2023-2024學年第二學期期末試卷
- 內(nèi)蒙古鄂爾多斯市達拉特旗第一中學2025年高三期中考試英語試題試卷含解析
- 江西省南康區(qū)2025屆3月初三第一次在線大聯(lián)考(江蘇卷)含解析
- 四川國際標榜職業(yè)學院《軟件測試技術》2023-2024學年第二學期期末試卷
- 下學班會課件圖片
- 陜09N1 供暖工程標準圖集
- 小型折彎機設計
- 大學英語泛讀教程第2冊課件Unit-6-Fath
- 復旦棒壘球?qū)m椪n教學大綱
- 房產(chǎn)中介法律知識及案例分享811課件
- 安全用電-觸電與急救課件
- 初三任務型閱讀公開課一等獎省優(yōu)質(zhì)課大賽獲獎課件
- 公司組織架構(gòu)圖(可編輯模版)
- 激光跟蹤儀使用手冊
- 貨物采購服務方案
- 初中英語 滬教牛津版 8B U6-1 Reading Head to head 課件
評論
0/150
提交評論