资料库系统概论.ppt

上传人:小飞机 文档编号:6347186 上传时间:2023-10-19 格式:PPT 页数:80 大小:1.48MB
返回 下载 相关 举报
资料库系统概论.ppt_第1页
第1页 / 共80页
资料库系统概论.ppt_第2页
第2页 / 共80页
资料库系统概论.ppt_第3页
第3页 / 共80页
资料库系统概论.ppt_第4页
第4页 / 共80页
资料库系统概论.ppt_第5页
第5页 / 共80页
点击查看更多>>
资源描述

《资料库系统概论.ppt》由会员分享,可在线阅读,更多相关《资料库系统概论.ppt(80页珍藏版)》请在三一办公上搜索。

1、資料庫系統概論,2,Outlines,Basic DefinitionsAdvantages of Using the DBMS ApproachExample of a DatabaseDatabase Users何謂 View(觀點)?資料庫相較於檔案系統的優點When not to use a DBMSSchemaThree-Schema ArchitectureDatabase LanguagesCentralized and Client/Server Architectures for DBMSsCharacteristics of the Database Approach(se

2、e Chapters 1,2),3,資料庫(Database),Database ManagementSystem(DBMS),End User,Application Programs,Database System,Basic Definitions,SQL(結構化查詢語言):User與AP皆透過SQL與DBMS溝通、存取DB data!,4,Database(資料庫;DB)A collection of related data.(一群相關資料的集合)將相關的資料以系統化的方式有效率地儲存在一起,並減少資料的重覆性一個資料庫往往是因為特定的需求或目的而被建構。因此,可以被特定的應用程式或

3、人員所使用透過資料庫管理系統(Database Management System;DBMS)來管理,5,Database Management System(資料庫管理系統;DBMS)是一群程式的集合,可以讓使用者有能力去建立與維護資料庫。幫助處理資料庫的定義(Defining)、建構(Constructing)、操作(Manipulating)與共享(Sharing)。Defining(定義):specifying the data type,structure,and constraints of the data to be stored in the database.Constru

4、cting(建構):the process of storing the data on some storage medium that is controlled by the DBMS.Manipulating(操作):querying the database,updating the database,generating reports from the data.Sharing(共享):allows multiple user/programs to access the database simultaneously.,6,Other important functions p

5、rovided by the DBMS include protecting(保護)the database and maintaining(維護)it over a long period of time.Protection includes:System protection:against hardware or software malfunctionSecurity protection:against unauthorized or malicious access.Database System(資料庫系統)The DBMS software together with the

6、 database.Database System=DBMS+DB例:Oracle,SQL Server,DB2,MySQL,7,Advantages of Using the DBMS Approach,Controlling RedundancyRestricting Unauthorized AccessProviding persistent Storage for Program ObjectsProviding Storage Structures for efficient Query ProcessingProviding Backup and RecoveryProvidin

7、g Multiple User InterfacesRepresenting Complex Relationships among DataEnforcing Integrity ConstraintsPermitting Inferencing and Actions Using Rules,8,Controlling Redundancy控制重複性整合相同的資料並集中存放,可節省儲存空間,且減少不一致的現像Restricting Unauthorized AccessProviding persistent Storage for Program ObjectsProviding Sto

8、rage Structures for efficient Query ProcessingProviding Backup and RecoveryProviding Multiple User InterfacesRepresenting Complex Relationships among DataEnforcing Integrity ConstraintsPermitting Inferencing and Actions Using Rules,9,Controlling RedundancyRestricting Unauthorized Access限制未授權的存取提供適當的

9、安全性與認証機制,通常是使用帳號與密碼獲得相對的資料庫存取權限Providing persistent Storage for Program ObjectsProviding Storage Structures for efficient Query ProcessingProviding Backup and RecoveryProviding Multiple User InterfacesRepresenting Complex Relationships among DataEnforcing Integrity ConstraintsPermitting Inferencing

10、and Actions Using Rules,10,Controlling RedundancyRestricting Unauthorized AccessProviding persistent Storage for Program Objects提供程式物件永久的儲存空間將複雜的程式物件或資料結構永久性地儲存在DBMS中,解決一般程式終止後,變數即被丟棄的問題。For O-O DBMSProviding Storage Structures for efficient Query ProcessingProviding Backup and RecoveryProviding Mul

11、tiple User InterfacesRepresenting Complex Relationships among DataEnforcing Integrity ConstraintsPermitting Inferencing and Actions Using Rules,11,Controlling RedundancyRestricting Unauthorized AccessProviding persistent Storage for Program ObjectsProviding Storage Structures for efficient Query Pro

12、cessing提供有效處理查詢的儲存結構資料庫系統必須提供有效執行查詢與更新的能力,而DBMS可以提供查詢處理與最佳化模組,可針對不同的查詢動作選擇一個有效率的查詢執行計劃。Providing Backup and RecoveryProviding Multiple User InterfacesRepresenting Complex Relationships among DataEnforcing Integrity ConstraintsPermitting Inferencing and Actions Using Rules,12,Controlling RedundancyRe

13、stricting Unauthorized AccessProviding persistent Storage for Program ObjectsProviding Storage Structures for efficient Query ProcessingProviding Backup and Recovery提供備份與回復功能確保資料庫可以回復到程式開始執行前的狀態,或確保程式能從之前中斷處繼續執行。Providing Multiple User InterfacesRepresenting Complex Relationships among DataEnforcing

14、 Integrity ConstraintsPermitting Inferencing and Actions Using Rules,13,Controlling RedundancyRestricting Unauthorized AccessProviding persistent Storage for Program ObjectsProviding Storage Structures for efficient Query ProcessingProviding Backup and RecoveryProviding Multiple User Interfaces提供多重使

15、用者介面針對不同程度的使用者,提供不同的使用者介面,包括:圖形化使用者介面、自然語言介面、查詢語言、程式語言介面等。Representing Complex Relationships among DataEnforcing Integrity ConstraintsPermitting Inferencing and Actions Using Rules,14,Controlling RedundancyRestricting Unauthorized AccessProviding persistent Storage for Program ObjectsProviding Stora

16、ge Structures for efficient Query ProcessingProviding Backup and RecoveryProviding Multiple User InterfacesRepresenting Complex Relationships among Data表示資料間的複雜關係可以利用各資料表格之間的相同欄位(即:外來鍵)來表示其間的關係。Enforcing Integrity ConstraintsPermitting Inferencing and Actions Using Rules,15,Controlling RedundancyRes

17、tricting Unauthorized AccessProviding persistent Storage for Program ObjectsProviding Storage Structures for efficient Query ProcessingProviding Backup and RecoveryProviding Multiple User InterfacesRepresenting Complex Relationships among DataEnforcing Integrity Constraints實施完整性限制大部份的資料庫都有完整性限制,資料必須

18、遵守這些限制。個體完整性限制、參考完整性限制、與特定資料的完整性限制。Permitting Inferencing and Actions Using Rules,16,Controlling RedundancyRestricting Unauthorized AccessProviding persistent Storage for Program ObjectsProviding Storage Structures for efficient Query ProcessingProviding Backup and RecoveryProviding Multiple User In

19、terfacesRepresenting Complex Relationships among DataEnforcing Integrity ConstraintsPermitting Inferencing and Actions Using Rules允許使用規則來進行推論與活動從已儲存的資料庫中推論出新的資訊。,17,Example of a Database,18,Database Users,For a small personal database,one person typically defines,constructs,and manipulates the datab

20、ase,and there is no sharing.However,in large organizations,many people are involved in the design,use,and maintenance of a large database with hundreds of users.Actors on the scene:Database Administrators(DBA)資料庫管理師Database Designers(DBD)資料庫設計師End Users 終端使用者Software Engineers(SE)軟體工程師,19,Database a

21、dministrators(DBA):DBA負責定義、建立、維護實際的資料庫,從技術性觀點提供系統整體的控制。DBA的任務:決定資料庫的資訊內容決定儲存結構、存取策略與使用者連絡定義安全性與完整性限制定義備份、回復的策略監測執行效率及應付需求的改變Database Designers(DBD):與所有可能會去使用資料庫的使用者們溝通,了解他們的需求,以便設計出符合他們的資料與處理需求的資料庫觀點(View;或稱視觀)。最後再將其他使用者的觀點一起分析與整合,以滿足所有使用者的需求。,20,何謂 View(觀點、視觀)?,男/女朋友,老闆,父母,21,A database typically h

22、as many users,each of whom may require a different view of the database.A view may be a subset of the database that is derived from the database files but is not explicitly stored.A multiuser DBMS whose users have a variety of distinct applications must provide facilities for defining multiple views

23、.,22,資料庫系統相較於檔案系統的優點,避免資料重覆存放(Data Redundancy)避免資料不一致(Inconsistency)資料的分享(Multi-User)標準的確立妥善的安全性與完整性控制(Security Constraints and Integrity Constraints)資料獨立性(Data Independence),23,避免資料重覆存放(Data Redundancy)透過資料集中化(Data Centralized)及存取界面標準化來減少資料的重覆存放,讓多個User讀取同一份資料庫內容。避免資料不一致(Inconsistency)資料的分享(Multi-U

24、ser)標準的確立妥善的安全性與完整性控制(Security Constraints and Integrity Constraints)資料獨立性(Data Independence),24,避免資料重覆存放(Data Redundancy)避免資料不一致(Inconsistency)若資料庫無法完全無重覆,則需透過DBMS做良好的控制,以減少產生資料不一致的現象。資料庫具有傳播更新(Propagating update)的特性,確保任何更新的動作會自動地更新到其它重複的資料,以減少不一致現象。資料的分享(Multi-User)標準的確立妥善的安全性與完整性控制(Security Const

25、raints and Integrity Constraints)資料獨立性(Data Independence),25,為何資料需要重覆存放?,增加效率備份,26,何謂傳播更新,從附近的點往外傳播,Jan(註冊資料),27,避免資料重覆存放(Data Redundancy)避免資料不一致(Inconsistency)資料的分享(Multi-User)不同的應用程式可以共享資料庫的同一份資料,不必像檔案系統,要為每一個應用建立自已的檔案。標準的確立妥善的安全性與完整性控制(Security Constraints and Integrity Constraints)資料獨立性(Data Ind

26、ependence),28,避免資料重覆存放(Data Redundancy)避免資料不一致(Inconsistency)資料的分享(Multi-User)標準的確立藉由資料集中化及存取界面標準化達成。妥善的安全性與完整性控制(Security Constraints and Integrity Constraints)資料獨立性(Data Independence),29,避免資料重覆存放(Data Redundancy)避免資料不一致(Inconsistency)資料的分享(Multi-User)標準的確立妥善的安全性與完整性控制(Security Constraints and Inte

27、grity Constraints)資料庫的集中控制讓DBA更容易從事安全性與完整性的限制。資料獨立性(Data Independence),30,避免資料重覆存放(Data Redundancy)避免資料不一致(Inconsistency)資料的分享(Multi-User)標準的確立妥善的安全性與完整性控制(Security Constraints and Integrity Constraints)資料獨立性(Data Independence)應用程式和資料是分開的。實體儲存方式的改變或資料庫結構的改變不會影響到上一層次的應用。,31,When not to use a DBMS,Dis

28、advantages of Database(by overhead costs):初期成本高(軟體、硬體、教育訓練費用等)DBMS為了定義與處理資料提供了一般性,因此可能為了某些特殊需求而浪費額外資源。過多的限制:完整性限制(Integrity)、安全性控制(Security)、並行控制(Concurrency)、回復(Recovery)等。且需要額外資源來確保這些限制的正常工作。資料庫設計師不常遵守完整性限制,32,何時不必採用資料庫:資料庫及其相關應用是非常簡單、好定義且不常改變的。某些應用程式有非常嚴格的即時性需求(Stringent,real-time requirements)Be

29、cause of DBMS overhead.不會有多使用者同時存取(No multiple-user access to data)未來擴充可能性非常小,33,綱要(Schema)是對整個資料庫的邏輯結構和特徴之描述。只涉及到類型(Type)的描述,不涉及到具體的記錄值。在DB中需描述的相關資料類型有:資料型態資料項目名稱相關的資料限制各個關聯表格之間的關係 綱要中的一個實際資料,稱為該綱要的一個實例(Instance)。,Schema,34,若學生資料庫中只有一個表格,則該表格的Schema為:表頭的部份即為Schema。主體的部份包含了三筆Instance.,35,比喻:Schema就好

30、像一支程式中的所有變數,有著不同的TypeInstance就好像該程式執行時,對所有變數指定不同的實際資料,36,Schema Diagram,A diagrammatic display of(some aspects of)a database schema.,37,Metadata(中繼資料),資料庫系統對於存放資料的之處:資料庫,有著完整的定義與描述。如:資料庫儲存結構、資料型態、資料表格間的關係及相關限制等資訊。此概念如同前述的關聯表格之Schema。這些並非資料本身,而是用來描述資料的資料,即為Metadata。Metadata儲存於資料庫系統的系統目錄中。因此,資料庫系統具有自我

31、描述(Self-Description)的特性。Schema亦可擴大解釋為MetadataMetadata/Schema不是只有表頭資料而已,尚有以下的Data亦屬於Metadata:資料結構-如:循序檔、索引檔、等資料格式-如:姓名char(10),薪水int資料限制-如:員工編號不可重覆等,38,內部層(Internal Level),概念層(Conceptual Level),外部層(External Level),(External/Conceptual Mapping),(Conceptual/Internal Mapping),軟體工程師(SE)的工作,資料庫設計師(DBD)的工作

32、,資料庫管理師(DBA)的工作,採全組織關觀點。如:表格(Table;或稱基礎表格Base Table).,所關心的是使用者(User)或應用程式(Application)的觀點。,所關心的是真正的硬體結構。如:Cylinder,Sector,Track.,所關心的是資料實際儲存結構。如:索引方式,樹狀結構等.,實體資料獨立性(Physical Data Independence),邏輯資料獨立性(Logical Data Independence),Three-Schema Architecture,39,又稱ANSI/SPARC 架構,1970年代提出。,40,Internal schem

33、a(內部綱要)At the internal level 描述有關資料庫的資料儲存結構與存取路徑的完整細節紀錄資料儲存格式最接近機器,但不涉及真正儲存媒體的硬體結構使用內部資料定義語言(Internal DDL),Defines the Three Levels,41,Conceptual schema(概念綱要)At the conceptual level 以組織中之全體使用者為主,描述資料庫整體的架構與限制(Describe the structure and constraints for the whole database for a community of users.)屬於群

34、體使用者觀點,表示資料庫全部資訊的內容使用概念資料定義語言(Conceptual DDL),42,External schemas(外部綱要)At the external level描述個別使用者的觀點(Describe the various user views)。使用者可以是應用程式或是終端使用者。最接近使用者的層次,資料於不同使用者有不同的呈現,即:涉及資料的個別使用方法。隱藏不需要的部份,對個別使用者只顯示其感興趣、或有權限讀取的部份。使用外部資料定義語言(External DDL),43,Mappings among schema levels are needed to tra

35、nsform requests and results.These mappings may be time-consuming.,44,Data Independence(資料獨立性)指改變資料庫系統的某一層次的綱要,不會影響到較高層次的綱要,即:不需要跟著修改較上層的綱要。(The capacity to change the schema at one level of a database system without having to change the schema at the next higher level.)某一層綱要與其上層綱要間相互獨立,相關的改變只需透過DBMS

36、從事適當的管理或修改即可,不用更改資料庫的相關程式。,45,Two types of data independence:Logical Data Independence(邏輯資料獨立性)當改變概念綱要時,不需要跟著改變外部綱要及其應用程式。(Change the conceptual schema without having to change the external schemas and their application programs.)外部層與概念層之間獨立時機:如,擴大資料庫規模時Physical Data Independence(實體資料獨立性)當改變內部綱要時,不需

37、要跟著改變概念綱要和外部綱要。(Change the internal schema without having to change the conceptual schema and external schema.)外部層與內部層之間獨立且概念層與內部層之間獨立時機:如,重組某些實體檔案結構,46,Database Languages,SQL(Structured Query Language,結構化查詢語言)是一種標準的關連式資料庫語言,由IBM於1970年代所研發。SQL為用與關式資庫系統對話而使用的語言幾乎目前所有的資庫管系統支援SQL目前版本為1999年所提出的SQL/99或稱S

38、QL/3,對物件導向DB與分散式DB有提供支援,並加入了程式設計的功能預存程式(stored procedure)(早期版本:SQL/87或稱SQL/1,SQL/92或稱SQL/2),47,優點:能由一個指令同時處理多個值組可以用指令來處理相關的值組可以直接處理記錄內的屬性,而不必重新定義變數缺點:沒有圖形化的查詢支援,需記憶一些指令,較不利初學者,48,SQL指令的種類:資料定義語言(Data Definition Language,DDL)用來宣告(或建立)資料庫物件針對Table,View或Schema,做建立(Create)、刪除(Drop)、更改(Alter)等動作。資料處理語言(D

39、ata Manipulation Language,DML)用來操作 資料庫中的資料針對Table內的Data,做插入(Insert)、更新(Update)、刪除(Delete)等動作。資料查詢語言(Data Query Language,DQL)用來查詢資料庫中的資料資料控制語言(Data Control Language,DCL)用來從事資料庫的權限控管,如Grant、Revoke、Alter Password等動作。資料管理指令(Data Administration Commands)用來從事資料庫的稽核與分析交易控制指令(Transactional Control Commands)

40、用來管理資料庫的交易動作,49,Centralized and Client/Server Architectures for DBMSs,資料庫系統處理架構的演進:集中式處理架構(Centralized Processing Architecture)主從式架構(Client/Server Architecture)多層式架構(Multi-Tier Architecture),50,Centralized Architectures,是早期的系統架構,使用大型電腦主機(Mainframe Computer)為所有的系統運作提供主要的處理。相關運作包含:DBMS software,hardwa

41、re,application programs and user interface processing software.大多數使用者是透過電腦終端機(Computer Terminal)來存取系統資料。此終端機沒有處理資料的能力,僅提供顯示的能力。Therefore,all processing was performed remotely on the computer system via various types of communications networks.,51,52,Basic Client-Server Architectures,近期由於硬體價格下降,大多數的使

42、用者都以個人電腦來取代原本的終端機。漸漸地,DBMS開始將部份的工作轉移到User端來執行,進而發展出 client/server DBMS架構。,53,When DBMS access is required,the program on the client side establishes a connection to the DBMS.ODBC(Open Database Connectivity)ODBC是一種由Microsoft推動、介於Server端資料庫系統與Client端應用程式之間的程式介面(Application programming interface;API)。讓

43、Client端的應用程式可以很容易地和各種不同之關連式資料庫系統的DBMS連結並取得資料庫內的資料。換句話說,ODBC是一種讓各種資料庫都具有相同的存取資料介面的程式。因為 ODBC 是一個應用程式介面,所以要使用 ODBC 時,在Client端必須安裝ODBC 驅動程式。而在Server端的資料庫系統,如Oracle、MS SQL、MySQL等,也須有相對應的ODBC驅動程式。有了ODBC後,程式設計師在設計不同資料庫系統的程式時,就不必將重新撰寫程式,只要變動與 ODBC所連結的介面即可,可以節省不少麻煩。JDBC An Java API.For the Java programming

44、language由Sun推動,54,Client/Server(Two-tier)Architecture的問題:當Server種類變多,Client也需因此而安裝多個介面當Client增多時,Server的負荷也會變重,55,Three Tier Architecture,將應用程式代理人(Application agent)置於Client與Server中間,存放企業規則(Business logic),以處理Client與Server間往來的業務。可整合後端不同的Server,以統一的方式呈現內部的資料。,(DB Server),(Web Server),(Browser),ODBC/J

45、DBC,http,56,Three-Tier Architecture的問題:Application Agent將會是瓶頸解決方法:第二層設置多一點Server中間層多設幾層(即:Multi-tier Architecture),57,比較,58,補 充,59,Characteristics of the Database Approach,Self-Describing Nature of a Database SystemInsulation between Programs and Data,and Data AbstractionSupport of Multiple Views of

46、 the DataSharing of Data and Multiuser Transaction Processing,60,Self-Description of a Database System資料庫系統的自我描述特性資料庫系統不僅包含資料庫本身,同時也包含了對於資料庫完整的定義與描述。如:資料庫儲存結構、資料型態、資料間的關係及限制等資訊。這些非資料內容本身、用來描述資料的資料,稱為中繼資料(Meta-Data),是儲存於DBMS的系統目錄中。Insulation between Programs and Data,and Data AbstractionSupport of Mu

47、ltiple Views of the DataSharing of Data and Multiuser Transaction Processing,61,Self-Describing Nature of a Database SystemInsulation between Programs and Data,and Data Abstraction隔離程式與資料及資料抽象化A DBMS provides users with a conceptual representation of data that does not include many of the details of

48、 how the data is stored or how the operations are implemented.Program-data independence(User Program不用理會資料存放於資料庫中的細節)Program-operation independence(User Program不用理會資料庫系統所提供之相關操作的細節)Data abstraction:the characteristic that allows above two independences.Support of Multiple Views of the DataSharing of

49、 Data and Multiuser Transaction Processing,62,Self-Describing Nature of a Database SystemInsulation between Programs and Data,and Data AbstractionSupport of Multiple Views of the Data支援資料的多重觀點A database typically has many users,each of whom may require a different view of the database.A view may be

50、a subset of the database that is derived from the database files but is not explicitly stored.A multiuser DBMS whose users have a variety of distinct applications must provide facilities for defining multiple views.Sharing of Data and Multiuser Transaction Processing,63,Self-Describing Nature of a D

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号