




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、數(shù)據(jù)庫應(yīng)用技術(shù)第一章 緒論目錄第一章 緒論第二章 數(shù)據(jù)庫基本概念第三章 深入SQL第四章 數(shù)據(jù)庫對象與數(shù)據(jù)庫設(shè)計(jì)第五章 面向過程的SQL擴(kuò)展第六章 事務(wù)處理與并發(fā)第七章 數(shù)據(jù)庫應(yīng)用開發(fā)第八章 數(shù)據(jù)庫安全第九章 數(shù)據(jù)庫管理內(nèi)容概要1.1 信息和數(shù)據(jù)1.2 數(shù)據(jù)庫系統(tǒng)發(fā)展歷史1.3 典型的DBMS軟件產(chǎn)品 1.4 數(shù)據(jù)庫應(yīng)用系統(tǒng)構(gòu)成1.5 數(shù)據(jù)庫的現(xiàn)狀與發(fā)展1.1 信息和數(shù)據(jù)世界由物質(zhì)、能量、信息三大要素組成信息是世界上事物的存在、運(yùn)動方式的描述信息有助于減少不確定性信息與物質(zhì)和運(yùn)動的關(guān)系信息的可復(fù)制性,可傳播性、可存儲性符號和數(shù)據(jù)不同載體上的信息雖然表現(xiàn)形式不同,其內(nèi)在的含義是一致的,但必須通過
2、一致的方式來記錄內(nèi)容,和一致的解讀方式來還原內(nèi)容。這種一致的記錄和解讀信息的方式,被稱為符號系統(tǒng)。這種方式必須是可操作的和精確的信息在一種可編碼符號系統(tǒng)下的編碼就是數(shù)據(jù)。將數(shù)據(jù)理解為信息,必須在一定的符號系統(tǒng)下進(jìn)行,否則它就只是一個(gè)數(shù)而已。一般將“信息”作為一個(gè)集合名詞,而將“數(shù)據(jù)”指代為具體的操作對象。數(shù)據(jù)管理技術(shù)發(fā)展經(jīng)歷三個(gè)階段: 人工管理階段(20世紀(jì)50年代中期以前) 文件系統(tǒng)管理階段(20世紀(jì)50年代后期至60年代中期)數(shù)據(jù)庫管理階段(20世紀(jì)60年代末開始)一 人工管理階段存儲介質(zhì): 磁帶、卡片、紙帶(無磁盤)主要用于科學(xué)計(jì)算 特點(diǎn):數(shù)據(jù)量小、計(jì)算復(fù)雜。數(shù)據(jù)管理的特點(diǎn): (1)數(shù)據(jù)
3、不保存在計(jì)算機(jī)中。 (2)只有程序的概念,無文件的概念。 (3)沒有專用的軟件對數(shù)據(jù)進(jìn)行管理。 (4)數(shù)據(jù)面向應(yīng)用,程序與數(shù)據(jù)不具有獨(dú)立性。二 文件系統(tǒng)管理階段存儲介質(zhì):出現(xiàn)了磁盤和磁鼓。應(yīng)用:由科學(xué)計(jì)算轉(zhuǎn)向于信息管理。特點(diǎn):計(jì)算簡單,數(shù)據(jù)量大。數(shù)據(jù)管理的特點(diǎn): (1)數(shù)據(jù)要求長期保存在磁盤上。 (2)數(shù)據(jù)不再屬于某個(gè)特定的程序,可重復(fù)使用。 (3)數(shù)據(jù)邏輯結(jié)構(gòu)和物理結(jié)構(gòu)有區(qū)別;程序與數(shù)據(jù)之間具 有“設(shè)備獨(dú)立”。 (4)文件組織呈現(xiàn)多樣化:索引文件,鏈接文件和散列文 件等。 文件系統(tǒng)管理數(shù)據(jù)的缺點(diǎn): (1)數(shù)據(jù)冗余大。 (2)數(shù)據(jù)操作具有不一致性。 (3)數(shù)據(jù)缺乏獨(dú)立性。 (4)數(shù)據(jù)之間聯(lián)系弱
4、。 (5)數(shù)據(jù)管理無法實(shí)施統(tǒng)一的標(biāo)準(zhǔn)。三 數(shù)據(jù)庫管理階段1、特點(diǎn): (1) 采用了復(fù)雜的數(shù)據(jù)模型表示數(shù)據(jù)結(jié)構(gòu)。 (2) 有較高的數(shù)據(jù)獨(dú)立性。 數(shù)據(jù)的邏輯獨(dú)立:當(dāng)數(shù)據(jù)整體邏輯結(jié)構(gòu)改變時(shí),盡量不影響用戶的 邏輯結(jié)構(gòu)和應(yīng)用程序 。 數(shù)據(jù)的物理獨(dú)立:當(dāng)數(shù)據(jù)的物理結(jié)構(gòu)改變時(shí),不影響整體的邏輯結(jié)構(gòu)以及應(yīng)用程序 。 (3) 減少了數(shù)據(jù)的無控冗余。 (4) 數(shù)據(jù)庫系統(tǒng)為用戶提供了方便的用戶接口來使用數(shù)據(jù)庫。 (5) 數(shù)據(jù)操作的基本單位是數(shù)據(jù)項(xiàng)而不是記錄,增強(qiáng)了系統(tǒng)的靈活性。 (6) 系統(tǒng)提供了4個(gè)方面的數(shù)據(jù)控制功能:數(shù)據(jù)庫的恢復(fù)、并發(fā)控制、數(shù)據(jù)完整性和數(shù)據(jù)的安全性。1.2 數(shù)據(jù)庫系統(tǒng)發(fā)展歷史數(shù)據(jù)庫發(fā)展史大規(guī)模
5、存儲介質(zhì)的出現(xiàn)Hard Data基于File System的數(shù)據(jù)管理原始的數(shù)據(jù)庫模型網(wǎng)狀 DBMS,1961 層次型DBMS,1968關(guān)系數(shù)據(jù)庫模型的建立1970年,IBM研究員E.F.Codd奠定了RDBMS的理論基礎(chǔ)1979年,Oracle面世存儲的歷史打孔卡片18841970s穿孔紙帶18461970s4096bit計(jì)數(shù)電子管1946盤式磁帶Univac,1951IBM,1952盒式錄音磁帶飛利浦,1963 約1M字節(jié)磁鼓IBM,1953約10K軟盤,從早期的8英寸軟盤、5.25英寸軟盤到3.5英寸軟盤。其中,3.5英寸1.44MB軟盤占據(jù)計(jì)算機(jī)的標(biāo)準(zhǔn)配置地位近20年之久 第一臺硬盤機(jī)I
6、BM,19564.4MB 目前主流磁盤200GB 光盤SONY,飛利浦,1979650MB DVD8.5GB藍(lán)光DVD和HD-DVD 存儲設(shè)備層次三級存儲脫機(jī)存儲基本存儲輔助存儲聯(lián)機(jī)存儲易失性存儲非易失性存儲磁盤的機(jī)制NOTE: Diagram is schematic, and simplifies the structure of actual disk drives磁道主軸磁盤壁組件讀寫頭磁盤壁旋轉(zhuǎn)盤片扇區(qū)柱面磁盤的性能指標(biāo)訪問時(shí)間 the time it takes from when a read or write request is issued to when data tra
7、nsfer begins. Consists of: 尋道時(shí)間 time it takes to reposition the arm over the correct track. Average seek time is 1/2 the worst case seek time.Would be 1/3 if all tracks had the same number of sectors, and we ignore the time to start and stop arm movement4 to 10 milliseconds on typical disks旋轉(zhuǎn)等待時(shí)間 ti
8、me it takes for the sector to be accessed to appear under the head. Average latency is 1/2 of the worst case latency.4 to 11 milliseconds on typical disks (5400 to 15000 r.p.m.)數(shù)據(jù)傳輸率 the rate at which data can be retrieved from or stored to the disk.25 to 100 MB per second max rate, lower for inner
9、tracksMultiple disks may share a controller, so rate that controller can handle is also importantE.g. SATA: 150 MB/sec, SATA-II 3Gb (300 MB/sec)Ultra 320 SCSI: 320 MB/s, SAS (3 to 6 Gb/sec)Fiber Channel (FC2Gb or 4Gb): 256 to 512 MB/s平均故障時(shí)間(Mean time to failure MTTF) the average time the disk is exp
10、ected to run continuously without any failure.Typically 3 to 5 yearsProbability of failure of new disks is quite low, corresponding to a“theoretical MTTF” of 500,000 to 1,200,000 hours for a new diskE.g., an MTTF of 1,200,000 hours for a new disk means that given 1000 relatively new disks, on an ave
11、rage one will fail every 1200 hoursMTTF decreases as disk ages數(shù)據(jù)庫管理系統(tǒng)數(shù)據(jù)庫管理系統(tǒng)(Database Management System,DBMS)是一套軟件產(chǎn)品,可以把一系列相關(guān)數(shù)據(jù)保存在計(jì)算機(jī)中,并提供對這些數(shù)據(jù)進(jìn)行檢索、修改和維護(hù)等操作的工具和編程接口。 數(shù)據(jù)庫(DB,Database)指保存在計(jì)算機(jī)中的數(shù)據(jù)部分。DBMS的功能模式翻譯:將概念上的數(shù)據(jù)庫模式翻譯為內(nèi)部表示。數(shù)據(jù)庫的邏輯結(jié)構(gòu)、完整性約束和物理儲存結(jié)構(gòu)保存在內(nèi)部的數(shù)據(jù)字典中。數(shù)據(jù)庫的各種數(shù)據(jù)操作(如查找、修改、插入和刪除等)和數(shù)據(jù)庫的維護(hù)管理都是以數(shù)據(jù)庫模
12、式為依據(jù)的。 應(yīng)用程序的編譯:把包含著訪問數(shù)據(jù)庫語句的應(yīng)用程序,編譯成在dbms支持下可運(yùn)行的目標(biāo)程序。 交互式查詢:提供易使用的交互式查詢語言,如sql。dbms負(fù)責(zé)執(zhí)行查詢命令,并將查詢結(jié)果顯示在屏幕上。 DBMS的功能-續(xù)數(shù)據(jù)的組織與存取:提供數(shù)據(jù)在外圍儲存設(shè)備上的物理組織與存取方法。 事務(wù)運(yùn)行管理:提供事務(wù)運(yùn)行管理及運(yùn)行日志,事務(wù)運(yùn)行的安全性監(jiān)控和數(shù)據(jù)完整性檢查,事務(wù)的并發(fā)控制及系統(tǒng)恢復(fù)等功能。 數(shù)據(jù)庫的維護(hù):為數(shù)據(jù)庫管理員提供軟件支持,包括數(shù)據(jù)安全控制、完整性保障、數(shù)據(jù)庫備份、數(shù)據(jù)庫重組以及性能監(jiān)控等維護(hù)工具。 RDBMS的特點(diǎn)高可靠性存儲的數(shù)據(jù)不會遭到破壞(即使軟件、硬件遭到破壞)
13、,使用備份機(jī)制,可恢復(fù)。物理可靠;數(shù)據(jù)安全。不同人員授權(quán)不同,避免非法訪問及級別不夠時(shí)的越權(quán)操作。高可用性:并發(fā)性。多用戶通過網(wǎng)絡(luò)并發(fā)訪問,使用各種緩存機(jī)制;事務(wù)處理。數(shù)據(jù)冗余性低,可重用性強(qiáng)。平臺無關(guān)性數(shù)據(jù)不加改動可移植到不同操作系統(tǒng)下。程序員無須顧及服務(wù)器,只須考慮DBMS即可。支持工具充分1.3 典型的DBMS軟件產(chǎn)品 大型DBMS產(chǎn)品ORACLEDB2 (Informix)中小型DBMS產(chǎn)品MSSQLSybase SQL Server桌面型DBMSAccess開源產(chǎn)品MySqlPostgreSQL、FirebirdOracle數(shù)據(jù)庫Oracle是以高級結(jié)構(gòu)化查詢語言(SQL)為基礎(chǔ)的大
14、型關(guān)系數(shù)據(jù)庫,是目前最流行的客戶-服務(wù)器(Client/Server)體系結(jié)構(gòu)的數(shù)據(jù)庫之一。Oracle特點(diǎn)共享SQL和多線索服務(wù)器體系結(jié)構(gòu)提供基于角色分工的安全保密管理支持多媒體數(shù)據(jù)提供第三代高級語言的接口軟件Pro*系列,能在C、C+等主語言中嵌入SQL語句及過程化(PL/SQL)語句,對數(shù)據(jù)庫中的數(shù)據(jù)進(jìn)行操縱提供分布式數(shù)據(jù)庫能力MS SQL Server數(shù)據(jù)庫SQL Server是一個(gè)全面的、集成的、端到端的數(shù)據(jù)解決方案,為企業(yè)中的用戶提供一個(gè)安全、可靠和高效的平臺用于企業(yè)數(shù)據(jù)管理和商業(yè)智能應(yīng)用。自SQL Server2005以來的新特性加強(qiáng)的T-SQL(事務(wù)處理SQL)CLR(通用語言
15、運(yùn)行時(shí)),整合了符合.NET規(guī)范的語言,可在DBMS中執(zhí)行.NET代碼以充分利用其功能服務(wù)代理數(shù)據(jù)加密合并SMTP郵件提高郵件性能創(chuàng)建HTTP終端多活動結(jié)果集允許從單個(gè)客戶端到數(shù)據(jù)庫保持一條持久連接,每個(gè)連接可以擁有超過一個(gè)的活動請求專用管理員連接以對SQL Server發(fā)起單個(gè)診斷連接數(shù)據(jù)庫鏡像SQL Server綜合服務(wù)滿足復(fù)雜數(shù)據(jù)的移動要求SQL Server主要工具關(guān)系數(shù)據(jù)庫:關(guān)系型數(shù)據(jù)庫引擎,支持結(jié)構(gòu)化和非結(jié)構(gòu)化(XML)數(shù)據(jù)復(fù)制服務(wù):可用于數(shù)據(jù)分發(fā)、處理移動數(shù)據(jù)應(yīng)用,系統(tǒng)高可用,企業(yè)報(bào)表解決方案的后備數(shù)據(jù)可伸縮存儲,與異構(gòu)系統(tǒng)的集成等通知服務(wù):用于開發(fā)、部署可伸縮應(yīng)用程序集成服務(wù):
16、支持?jǐn)?shù)據(jù)倉庫和企業(yè)范圍內(nèi)數(shù)據(jù)集成的抽取、轉(zhuǎn)換和裝載能力分析服務(wù):OLAP聯(lián)機(jī)分析處理,用于多維存儲的大量復(fù)雜數(shù)據(jù)集的快速高級分析報(bào)表服務(wù):全面的報(bào)表解決方案,新增基于web的報(bào)表管理工具:集成管理工具實(shí)現(xiàn)高級數(shù)據(jù)庫的管理和調(diào)諧開發(fā)工具:實(shí)現(xiàn)端到端的應(yīng)用程序開發(fā)能力IBM DB2數(shù)據(jù)庫20世紀(jì)70年代初,IBM的San Jose研究中心的E.F.Codd首次提出關(guān)系數(shù)據(jù)庫模型1983年,IBM為MVS(多重虛擬系統(tǒng))開創(chuàng)了第一代DB2數(shù)據(jù)庫DB2 通用數(shù)據(jù)庫UDB是當(dāng)今世界上先進(jìn)的數(shù)據(jù)庫支持最多的系統(tǒng)平臺支持商務(wù)智能和基于知識的應(yīng)用支持多種數(shù)據(jù)類型(文件、圖形、文本、視頻、空間數(shù)據(jù))DB2核心數(shù)
17、據(jù)庫(公共服務(wù)器)特色支持面向?qū)ο蟮木幊讨С侄嗝襟w應(yīng)用程序備份和恢復(fù)能力支持存儲過程和觸發(fā)器支持遞歸SQL查詢支持異構(gòu)分布式數(shù)據(jù)庫訪問支持?jǐn)?shù)據(jù)復(fù)制MySQL數(shù)據(jù)庫開放源碼數(shù)據(jù)庫,在一定規(guī)則下任何人都可以使用、修改源碼以符合特殊需要免費(fèi)!簡單易用!C/S架構(gòu)多線程服務(wù)器適于中小型應(yīng)用無后期保障,自行解決問題、承擔(dān)風(fēng)險(xiǎn)MySQL數(shù)據(jù)庫特性支持多種編譯器,開發(fā)語言為C/C+良好的內(nèi)存管理機(jī)制支持多種平臺提供多種形式的API使用多線程技術(shù)提供多種數(shù)據(jù)類型提供Windows端的ODBC連接客戶端可通過TCP/IP、UNIX套接字、命名管道(NT)連接到MySQL數(shù)據(jù)庫服務(wù)器Sybase數(shù)據(jù)庫Sybase
18、公司1987年推出的數(shù)據(jù)庫產(chǎn)品Sybase數(shù)據(jù)庫三種版本UNIX操作系統(tǒng)下版本Novell Netware環(huán)境下版本W(wǎng)indows NT下版本UNIX操作系統(tǒng)下目前廣泛應(yīng)用Sybase數(shù)據(jù)庫,目前版本Sybase 11 for SCO UNIXSybase數(shù)據(jù)庫特點(diǎn)基于C/S架構(gòu)的數(shù)據(jù)庫開放式數(shù)據(jù)庫,不僅提供預(yù)編譯,而且公開應(yīng)用程序接口DB-LIB便于應(yīng)用程序在不同平臺間移植高性能數(shù)據(jù)庫 可編程數(shù)據(jù)庫事件驅(qū)動的觸發(fā)器多線索化1.4 數(shù)據(jù)庫應(yīng)用系統(tǒng)構(gòu)成1、硬件。包括服務(wù)器、工作站、和網(wǎng)絡(luò)2、軟件核心是DBMS操作系統(tǒng)、DBMS支撐工具,接口庫,開發(fā)工具等。由程序員根據(jù)用戶需求設(shè)計(jì)開發(fā)的應(yīng)用系統(tǒng)。
19、3、數(shù)據(jù)庫。具有持久性,結(jié)構(gòu)化和可共享的數(shù)據(jù)集合。數(shù)據(jù)庫是現(xiàn)代化企業(yè)的核心資源之一。數(shù)據(jù)庫應(yīng)用系統(tǒng) 數(shù)據(jù)庫應(yīng)用領(lǐng)域聯(lián)機(jī)事務(wù)處理(Online Transaction Processing,OLTP):對各種現(xiàn)實(shí)事務(wù)過程中的數(shù)據(jù)進(jìn)行存儲、查詢和處理。如超市結(jié)賬,銀行轉(zhuǎn)賬等,一般由業(yè)務(wù)操作員進(jìn)行操作,是其他數(shù)據(jù)庫應(yīng)用的基礎(chǔ)。聯(lián)機(jī)分析處理(Online Anlysis Processing,OLAP):對OLTP的數(shù)據(jù)進(jìn)行分析、匯總、統(tǒng)計(jì)等,力求進(jìn)行深入的分析。一般由專業(yè)管理人員和技術(shù)人員進(jìn)行操作。數(shù)據(jù)庫應(yīng)用系統(tǒng)的發(fā)展70年代之前,原始的,基于主機(jī)的應(yīng)用系統(tǒng),供政府、軍隊(duì)和大企業(yè)使用80年代后,隨著
20、局域網(wǎng)和PC機(jī)的發(fā)展,局域網(wǎng)模式的數(shù)據(jù)庫應(yīng)用系統(tǒng)逐漸普及到中小企業(yè)。形成C/S的開發(fā)模式。本世紀(jì),隨著互聯(lián)網(wǎng)的迅速發(fā)展,以網(wǎng)站為表現(xiàn)形式的數(shù)據(jù)庫應(yīng)用系統(tǒng)越來越多。形成B/S的開發(fā)模式。數(shù)據(jù)庫應(yīng)用系統(tǒng)的領(lǐng)域作業(yè)控制:數(shù)據(jù)處理系統(tǒng) (Data Processing System, DPS)或交易處理系統(tǒng) (Transaction Processing System, TPS) 知識管理:知識工作系統(tǒng)(Knowledge Work System, KWS)與辦公室系統(tǒng)(Office System, OS),負(fù)責(zé)累積知識與協(xié)助運(yùn)用知識以提高組織的競爭力。 管理控制:管理信息系統(tǒng)(Management
21、Information System,MIS)策略規(guī)劃:決策支持系統(tǒng) (Decision Support Systems,DSS)、數(shù)據(jù)挖掘(Data Mining)數(shù)據(jù)庫應(yīng)用系統(tǒng)-用戶最終用戶是系統(tǒng)的使用者初級用戶高級用戶程序員是系統(tǒng)程序的建立者,包括系統(tǒng)分析員,和(高級)用戶溝通,設(shè)計(jì)數(shù)據(jù)庫應(yīng)用方案和軟件結(jié)構(gòu)。前臺程序員,使用前臺開發(fā)工具,設(shè)計(jì)界面軟件,對數(shù)據(jù)庫進(jìn)行存取。后臺程序員,較復(fù)雜的系統(tǒng)中,使用特定數(shù)據(jù)庫開發(fā)工具做一些通用子程序在數(shù)據(jù)庫服務(wù)器端或者中間服務(wù)器運(yùn)行。管理員:DBA,數(shù)據(jù)庫管理員,負(fù)責(zé)配置和維護(hù)數(shù)據(jù)庫。Database1.5 數(shù)據(jù)庫的現(xiàn)狀與發(fā)展數(shù)據(jù)庫應(yīng)用現(xiàn)狀與缺陷分布式
22、DBMS面向?qū)ο蟮腄BMS數(shù)據(jù)倉庫與數(shù)據(jù)挖掘面向文檔的數(shù)據(jù)庫NoSQL = Not Only SQLNOSQL優(yōu)點(diǎn)對數(shù)據(jù)庫的高并發(fā)讀寫。Key-Value型數(shù)據(jù)庫:Redis 等對海量數(shù)據(jù)的高效率存儲和訪問。文檔型數(shù)據(jù)庫:MongoDB等數(shù)據(jù)庫的可擴(kuò)展性。分布式數(shù)據(jù)庫:Cassandra等NOSQL缺點(diǎn)很難實(shí)現(xiàn)數(shù)據(jù)的完整性。缺乏強(qiáng)有力的技術(shù)支持。開源數(shù)據(jù)庫從出現(xiàn)到用戶接受需要一個(gè)漫長的過程。關(guān)系型數(shù)據(jù)庫在設(shè)計(jì)時(shí)更能夠體現(xiàn)實(shí)際。An Introduction to Database Systems1.2.5 層次模型層次模型是數(shù)據(jù)庫系統(tǒng)中最早出現(xiàn)的數(shù)據(jù)模型 層次數(shù)據(jù)庫系統(tǒng)的典型代表是IBM公司的
23、IMS(Information Management System)數(shù)據(jù)庫管理系統(tǒng)層次模型用樹形結(jié)構(gòu)來表示各類實(shí)體以及實(shí)體間的聯(lián)系 An Introduction to Database Systems四、層次數(shù)據(jù)模型的存儲結(jié)構(gòu)鄰接法按照層次樹前序遍歷的順序把所有記錄值依次鄰接存放,即通過物理空間的位置相鄰來實(shí)現(xiàn)層次順序An Introduction to Database Systems層次數(shù)據(jù)模型的存儲結(jié)構(gòu)(續(xù))圖1.20 層次數(shù)據(jù)庫及其實(shí)例 A1A2C8C6C4B6C9C2B4C14C7C5C3B1A1圖1.21 鄰接法 按鄰接法存放圖1.20(b)中以根記錄A1為首的層次記錄實(shí)例集按鄰
24、接法存放圖1.20(b)中以根記錄A1為首的層次記錄實(shí)例集 An Introduction to Database Systems層次數(shù)據(jù)模型的存儲結(jié)構(gòu)(續(xù))鏈接法用指引來反映數(shù)據(jù)之間的層次聯(lián)系子女兄弟鏈接法層次序列鏈接法An Introduction to Database Systems層次數(shù)據(jù)模型的存儲結(jié)構(gòu)(續(xù))子女-兄弟鏈接法每個(gè)記錄設(shè)兩類指針,分別指向最左邊的子女(每個(gè)記錄型對應(yīng)一個(gè))和最近的兄弟An Introduction to Database Systems層次數(shù)據(jù)模型的存儲結(jié)構(gòu)(續(xù))層次序列鏈接法按樹的前序穿越順序鏈接各記錄值A(chǔ)n Introduction to Datab
25、ase Systems五、層次模型的優(yōu)缺點(diǎn)優(yōu)點(diǎn)層次模型的數(shù)據(jù)結(jié)構(gòu)比較簡單清晰 查詢效率高,性能優(yōu)于關(guān)系模型,不低于網(wǎng)狀模型層次數(shù)據(jù)模型提供了良好的完整性支持缺點(diǎn)多對多聯(lián)系表示不自然對插入和刪除操作的限制多,應(yīng)用程序的編寫比較復(fù)雜 查詢子女結(jié)點(diǎn)必須通過雙親結(jié)點(diǎn)由于結(jié)構(gòu)嚴(yán)密,層次命令趨于程序化 An Introduction to Database Systems1.2.6 網(wǎng)狀模型網(wǎng)狀數(shù)據(jù)庫系統(tǒng)采用網(wǎng)狀模型作為數(shù)據(jù)的組織方式 典型代表是DBTG系統(tǒng):亦稱CODASYL系統(tǒng)70年代由DBTG提出的一個(gè)系統(tǒng)方案奠定了數(shù)據(jù)庫系統(tǒng)的基本概念、方法和技術(shù)實(shí)際系統(tǒng)Cullinet Software Inc.
26、公司的 IDMSUnivac公司的 DMS1100Honeywell公司的IDS/2HP公司的IMAGEAn Introduction to Database Systems1.網(wǎng)狀數(shù)據(jù)模型的數(shù)據(jù)結(jié)構(gòu)網(wǎng)狀模型滿足下面兩個(gè)條件的基本層次聯(lián)系的集合:1. 允許一個(gè)以上的結(jié)點(diǎn)無雙親;2. 一個(gè)結(jié)點(diǎn)可以有多于一個(gè)的雙親。An Introduction to Database Systems網(wǎng)狀數(shù)據(jù)模型的數(shù)據(jù)結(jié)構(gòu)(續(xù))表示方法(與層次數(shù)據(jù)模型相同)實(shí)體型:用記錄類型描述 每個(gè)結(jié)點(diǎn)表示一個(gè)記錄類型(實(shí)體)屬性:用字段描述 每個(gè)記錄類型可包含若干個(gè)字段聯(lián)系:用結(jié)點(diǎn)之間的連線表示記錄類型(實(shí)體)之 間的一對多
27、的父子聯(lián)系A(chǔ)n Introduction to Database Systems網(wǎng)狀數(shù)據(jù)模型的數(shù)據(jù)結(jié)構(gòu)(續(xù))網(wǎng)狀模型與層次模型的區(qū)別網(wǎng)狀模型允許多個(gè)結(jié)點(diǎn)沒有雙親結(jié)點(diǎn)網(wǎng)狀模型允許結(jié)點(diǎn)有多個(gè)雙親結(jié)點(diǎn)網(wǎng)狀模型允許兩個(gè)結(jié)點(diǎn)之間有多種聯(lián)系(復(fù)合聯(lián)系)網(wǎng)狀模型可以更直接地去描述現(xiàn)實(shí)世界層次模型實(shí)際上是網(wǎng)狀模型的一個(gè)特例An Introduction to Database Systems網(wǎng)狀數(shù)據(jù)模型的數(shù)據(jù)結(jié)構(gòu)(續(xù))網(wǎng)狀模型中子女結(jié)點(diǎn)與雙親結(jié)點(diǎn)的聯(lián)系可以不唯一要為每個(gè)聯(lián)系命名,并指出與該聯(lián)系有關(guān)的雙親記錄和子女記錄 R1與R3之間的聯(lián)系L1R2與R3之間的聯(lián)系L2 An Introduction to Da
28、tabase Systems網(wǎng)狀數(shù)據(jù)模型的數(shù)據(jù)結(jié)構(gòu)(續(xù))網(wǎng)狀模型的例子 An Introduction to Database Systems網(wǎng)狀數(shù)據(jù)模型的數(shù)據(jù)結(jié)構(gòu)(續(xù))多對多聯(lián)系在網(wǎng)狀模型中的表示用網(wǎng)狀模型間接表示多對多聯(lián)系方法: 將多對多聯(lián)系直接分解成一對多聯(lián)系A(chǔ)n Introduction to Database Systems網(wǎng)狀數(shù)據(jù)模型的數(shù)據(jù)結(jié)構(gòu)(續(xù))例如:一個(gè)學(xué)生可以選修若干門課程,某一課程可以被多個(gè)學(xué)生選修,學(xué)生與課程之間是多對多聯(lián)系 引進(jìn)一個(gè)學(xué)生選課的聯(lián)結(jié)記錄,由3個(gè)數(shù)據(jù)項(xiàng)組成學(xué)號課程號成績表示某個(gè)學(xué)生選修某一門課程及其成績 An Introduction to Databas
29、e Systems網(wǎng)狀數(shù)據(jù)模型的數(shù)據(jù)結(jié)構(gòu)(續(xù))圖1.24 學(xué)生/選課/課程的網(wǎng)狀數(shù)據(jù)模型 An Introduction to Database Systems網(wǎng)狀數(shù)據(jù)模型的操縱與完整性約束(續(xù))網(wǎng)狀數(shù)據(jù)庫系統(tǒng)(如DBTG)對數(shù)據(jù)操縱加 了一些限制,提供了一定的完整性約束碼:唯一標(biāo)識記錄的數(shù)據(jù)項(xiàng)的集合 一個(gè)聯(lián)系中雙親記錄與子女記錄之間是一對多聯(lián)系支持雙親記錄和子女記錄之間某些約束條件 An Introduction to Database Systems三、網(wǎng)狀數(shù)據(jù)模型的存儲結(jié)構(gòu)關(guān)鍵實(shí)現(xiàn)記錄之間的聯(lián)系常用方法單向鏈接雙向鏈接環(huán)狀鏈接向首鏈接An Introduction to Database
30、 Systems網(wǎng)狀數(shù)據(jù)模型的存儲結(jié)構(gòu)(續(xù))圖1.25 學(xué)生/選課/課程的網(wǎng)狀數(shù)據(jù)庫實(shí)例 學(xué)生記錄課程記錄選課記錄An Introduction to Database Systems四、網(wǎng)狀數(shù)據(jù)模型的優(yōu)缺點(diǎn)優(yōu)點(diǎn)能夠更為直接地描述現(xiàn)實(shí)世界,如一個(gè)結(jié)點(diǎn)可以有多個(gè)雙親具有良好的性能,存取效率較高缺點(diǎn)結(jié)構(gòu)比較復(fù)雜,而且隨著應(yīng)用環(huán)境的擴(kuò)大,數(shù)據(jù)庫的結(jié)構(gòu)就變得越來越復(fù)雜,不利于最終用戶掌握DDL、DML語言復(fù)雜,用戶不容易使用RAIDRAID: Redundant Arrays of Independent Disks disk organization techniques that manage a
31、 large numbers of disks, providing a view of a single disk of high capacity and high speed by using multiple disks in parallel, high reliability by storing data redundantly, so that data can be recovered even if a disk fails The chance that some disk out of a set of N disks will fail is much higher
32、than the chance that a specific single disk will fail.E.g., a system with 100 disks, each with MTTF of 100,000 hours (approx. 11 years), will have a system MTTF of 1000 hours (approx. 41 days)Techniques for using redundancy to avoid data loss are critical with large numbers of disksOriginally a cost
33、-effective alternative to large, expensive disksI in RAID originally stood for inexpensiveToday RAIDs are used for their higher reliability and bandwidth. The “I” is interpreted as independentImprovement of Reliability via RedundancyRedundancy store extra information that can be used to rebuild info
34、rmation lost in a disk failureE.g., Mirroring (or shadowing)Duplicate every disk. Logical disk consists of two physical disks.Every write is carried out on both disksReads can take place from either diskIf one disk in a pair fails, data still available in the otherData loss would occur only if a dis
35、k fails, and its mirror disk also fails before the system is repairedProbability of combined event is very small Except for dependent failure modes such as fire or building collapse or electrical power surgesMean time to data loss depends on mean time to failure, and mean time to repairE.g. MTTF of
36、100,000 hours, mean time to repair of 10 hours gives mean time to data loss of 500*106 hours (or 57,000 years) for a mirrored pair of disks (ignoring dependent failure modes)Improvement in Performance via ParallelismTwo main goals of parallelism in a disk system: 1.Load balance multiple small access
37、es to increase throughput2.Parallelize large accesses to reduce response time.Improve transfer rate by striping data across multiple disks.Bit-level striping split the bits of each byte across multiple disksIn an array of eight disks, write bit i of each byte to disk i.Each access can read data at e
38、ight times the rate of a single disk.But seek/access time worse than for a single diskBit level striping is not used much any moreBlock-level striping with n disks, block i of a file goes to disk (i mod n) + 1Requests for different blocks can run in parallel if the blocks reside on different disksA
39、request for a long sequence of blocks can utilize all disks in parallelFile Organization, Record Organization and Storage Access磁盤的機(jī)制NOTE: Diagram is schematic, and simplifies the structure of actual disk drives磁道主軸磁盤壁組件讀寫頭磁盤壁旋轉(zhuǎn)盤片扇區(qū)柱面File OrganizationThe database is stored as a collection of files.
40、Each file is a sequence of records. A record is a sequence of fields.One approach:assume record size is fixedeach file has records of one particular type only different files are used for different relationsThis case is easiest to implement; will consider variable length records later.Fixed-Length R
41、ecordsSimple approach:Store record i starting from byte n (i 1), where n is the size of each record.Record access is simple but records may cross blocksModification: do not allow records to cross block boundariesDeletion of record i: alternatives:move records i + 1, . . ., n to i, . . . , n 1move re
42、cord n to ido not move records, but link all free records on afree listDeleting record 3 and compactingDeleting record 3 and moving last recordFree ListsStore the address of the first deleted record in the file header.Use this first record to store the address of the second deleted record, and so on
43、Can think of these stored addresses as pointers since they “point” to the location of a record.More space efficient representation: reuse space for normal attributes of free records to store pointers. (No pointers stored in in-use records.)Variable-Length RecordsVariable-length records arise in data
44、base systems in several ways:Storage of multiple record types in a file.Record types that allow variable lengths for one or more fields such as strings (varchar)Record types that allow repeating fields (used in some older data models).Attributes are stored in orderVariable length attributes represen
45、ted by fixed size (offset, length), with actual data stored after all fixed length attributesNull values represented by null-value bitmapVariable-Length Records: Slotted Page StructureSlotted page header contains:number of record entriesend of free space in the blocklocation and size of each recordR
46、ecords can be moved around within a page to keep them contiguous with no empty space between them; entry in the header must be updated.Pointers should not point directly to record instead they should point to the entry for the record in header.Organization of Records in FilesHeap a record can be pla
47、ced anywhere in the file where there is spaceSequential store records in sequential order, based on the value of the search key of each recordHashing a hash function computed on some attribute of each record; the result specifies in which block of the file the record should be placedRecords of each relation may be stored in a separate file. In a multitable clustering file organization records of several different relations can be stored in the same fileMotivati
溫馨提示
- 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)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 勞務(wù)安全協(xié)議合同范本
- 共同經(jīng)營承包土地合同范本
- 2025年南陽道路運(yùn)輸貨運(yùn)考試題庫
- 2025年棗莊年貨運(yùn)從業(yè)資格證考試題大全
- 包鋼供貨合同范本
- 別墅灌溉維修合同范本
- 倉庫道具租賃合同范本
- 加工車間機(jī)床承包合同范本
- 共同做模具合同范本
- 個(gè)人售房合同范本
- 臺州事業(yè)單位筆試真題2024
- 父母房產(chǎn)繼承協(xié)議書范本
- 51個(gè)行業(yè)領(lǐng)域重大事故隱患判定標(biāo)準(zhǔn)和重點(diǎn)檢查事項(xiàng)匯編
- 2024年高二化學(xué)教案 選擇性必修2(配人教版)第1課時(shí)原子結(jié)構(gòu)與性質(zhì)
- 2024-2030年中國空氣閥行業(yè)市場發(fā)展趨勢與前景展望戰(zhàn)略分析報(bào)告
- 人工智能(人工智能大數(shù)據(jù)技術(shù)相關(guān)專業(yè))全套教學(xué)課件
- 2024年輔警招聘考試試題庫附參考答案(綜合題)
- 小學(xué)數(shù)學(xué)主題活動設(shè)計(jì)一年級《歡樂購物街》
- 一年級口算天天練1(打印版)
- 垃圾發(fā)電廠汽機(jī)培訓(xùn)
- 村情要素模板
評論
0/150
提交評論