1 / 61

第2讲 数据库系统概念和体系结构 Textbook:Chapter 2 Database System Concepts and Architecture

第2讲 数据库系统概念和体系结构 Textbook:Chapter 2 Database System Concepts and Architecture. 本讲主要内容. 2.1 数据模型、模式和实例 2.2 三层模式体系结构和数据独立性 2.3 数据库语言和接口(简单了解) 2.4 数据库系统环境(自学,简单了解) 2.5 集中式和客户 / 服务器体系结构. 2.1 数据模型、模式和实例. 2.1.1 数据模型 2.1.2 模式、实例和数据库状态. 数据模型的基本概念.

gili
Download Presentation

第2讲 数据库系统概念和体系结构 Textbook:Chapter 2 Database System Concepts and Architecture

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 第2讲 数据库系统概念和体系结构Textbook:Chapter 2 Database System Concepts and Architecture

  2. 本讲主要内容 • 2.1 数据模型、模式和实例 • 2.2 三层模式体系结构和数据独立性 • 2.3 数据库语言和接口(简单了解) • 2.4 数据库系统环境(自学,简单了解) • 2.5 集中式和客户/服务器体系结构

  3. 2.1 数据模型、模式和实例 • 2.1.1 数据模型 • 2.1.2 模式、实例和数据库状态

  4. 数据模型的基本概念 • 数据模型(Data Model):现实世界数据特征的抽象,用来定义数据如何组织,数据之间的关系怎样。 • 数据模型的层次: • Conceptual(概念模型) :按用户的观点来对数据和信息建模 • Logical(Implementation)(逻辑/实现模型) • 层次模型 • 网状模型 • 关系模型 • … • Physical(物理模型):数据在具体DBMS产品(IBM、Microsoft、Oracle)中的物理存储方式

  5. 数据建模概述 • 建立概念模型(E-R建模方法)—》将概念模型转换为逻辑模型(Logical, 中间级数据模型)—》物理级模型

  6. 数据模型的组成要素 • 数据结构:对系统静态特征的描述 • 数据操作:对系统动态特征的描述 • 检索(查询) • 更新(插入、删除、修改:增删改) • 数据的约束条件:完整性约束规则

  7. 概念数据模型(Conceptual Data Model)

  8. 逻辑数据模型(Logical Data Model) • 层次模型 • 网状模型 • 关系模型(Relational Data Model) • 以严格的数学理论为基础:谓词逻辑(predicate logic)、集合论(set theory) • 目前主流的数据库系统都是基于“关系模型”的 • 面向对象模型(不讲) • 对象关系模型(不讲)

  9. 图(补1)学校教课模型 层次模型(Hierarchical Model) • 假设要为一个学校建立反映“学院、教研室、课程、教师”情况的数据库。且实体模型已经建立(图补1),则其对象之间的联系是这样的:每个学院设置若干教研室,开设若干门课程;每个教研室又有若干名教师。

  10. 层次模型(Hierarchical Model) • 根据图补1的实体模型,就可以构造出如补2图所示的层次数据模型及其实例。在实例中,我们只给出了计算机学院的情况,其他学院的情况用一个虚线框表示(均予以省略)。 • 从图补2可以看出,计算机学院院长是李星;该学院设有15个教研室,共开设128门课程;硬件教研室有23名教师,软件教研室有29名教师。 图(补2)

  11. 层次模型(Hierarchical Model) • 在层次模型中,必须按照从根开始的某条路径提出询问,否则就不能直接回答。故设计层次模型(以及下面将讨论的网络模型)时要细心考虑路径问题,因为路径一经规定就不能改变。

  12. 层次模型的不足 • 􀂄有时候有层次不清的情况􀂄 • 黄飞鸿和十三姨的关系􀀫 • 他们的后代该如何称呼黄飞鸿的爸爸?

  13. 图补3 教学的网络模型 网状模型(Network Model) • DBTG报告定义为:网状数据模型是以记录类型为结点的网状结构。网络与树的区别有两点非常显著: • ① 一个子结点可以有两个或多个父结点。 • ② 在两个结点之间可以有两种或多种联系。 • 在DBTG报告中,用“络”(set)表示这种联系。所谓络就是一棵二级树,它的根称为主结点,它的叶称为从结点。 • 络有型与值之分:络类型(型)表示记录类型之间的联系;络事件(值),表示记录值之间的联系。 • DBTG的网络模型系由若干络类型构成。

  14. 网状模型(Network Model) • 我们假定只有两个教师、三门课程(分别用C1,C2,C3表示其课程号)和三个学生(分别用S1,S2,S3表示其学号)。则图补4为图补3所示网状模型的一个实例。

  15. 关系数据模型(Relational Data Model)的数据结构 • 二维表(Table)=关系(Relation) • 行(Row)、列(Column) • 一般DBA术语:记录(Record)、字段(Field) • 关系模型术语:元组(Tuple)、属性(Attribute)

  16. 注意 • 关系型数据库的层次结构 • 数据库(Database)—》表(Table)—》记录(Record)(每条记录有若干字段或者属性) • 在关系模型中,E-R概念模型中的实体以及实体间的联系(Relationship)都是用关系(Relation)来表示的

  17. 物理数据模型(Physical Data Model) • 描述数据库在计算机中的存储细节

  18. Review:Data Models • Data Model: • A set of concepts to describe the structure of a database, the operations for manipulating these structures, and certain constraints that the database should obey. • Data Model Structure and Constraints: • Constructs(构造) are used to define the database structure • Constructs typically include elements (and their data types) as well as groups of elements (e.g. entity, record, table), and relationships among such groups • Constraints specify some restrictions on valid data; these constraints must be enforced(强制) at all times

  19. Review:Data Models (continued) • Data Model Operations: • These operations are used for specifying database retrievals(获取) and updates by referring to the constructs of the data model. • Operations on the data model may include basic model operations(e.g. generic insert, delete, update) anduser-defined operations(e.g. compute_student_gpa, update_inventory)

  20. Review:Categories of Data Models • Conceptual (high-level, semantic) data models: • Provide concepts that are close to the way many users perceive data. • Entity-Relationship Model • Physical (low-level, internal) data models: • Provide concepts that describe details of how data is stored in the computer. • Implementation (representational,logical) data models: • Provide concepts that fall between the above two, and may be understood by end users but that are not too far removed from the way data is organized within the computer. • Relational, network, hierarchical

  21. 2.1 数据模型、模式和实例 • 2.1.1 数据模型 • 2.1.2 模式、实例和数据库状态

  22. 数据库模式和实例的概念 • Schema(模式)与Instance(实例) • Schema:The description of a database. Includes descriptions of the database structure, data types, and the constraints on the database. • Instance(State):The actual data stored in a database at a particular moment in time. This includes the collection of all the data in the database. • Instance是Schema在某一时刻的具体化、实例化(类似于面向对象理论中Class与Object的关系)

  23. 学生信息数据库的Schema

  24. 学生信息数据库某一时刻的Instance

  25. Database Schema vs. Database State • The database schema changes very infrequently. • Schema is also called intension(内涵). • The database state changes every time the database is updated. • State is also called extension(外延).

  26. 本讲主要内容 • 2.1 数据模型、模式和实例 • 2.2 三层模式体系结构和数据独立性 • 2.3 数据库语言和接口 • 2.4 数据库系统环境 • 2.5 集中式和客户/服务器体系结构 • 2.6 数据库管理系统分类

  27. 数据库系统的三级模式结构(Three-Schema Architecture) 外模式 概念模式 内模式

  28. Three-Schema Architecture • Internal schema(内模式,也称存储模式):数据物理结构和存储方式的描述,是数据在数据库内部的表示方式 • 通常使用物理数据模型描述 • Conceptual schema(概念模式,也称全局模式,有时简称“模式”):数据库中全体数据的逻辑结构和特征的描述 • 通常使用概念或逻辑数据模型描述 • External schemas(外模式,也称子模式或用户模式):数据库用户能够看见和使用的局部数据的逻辑结构和特征的描述 • 通常使用与概念模式相同的数据模型描述

  29. 注意 • 模型(Model)与模式(Schema)的区别 • 数据模型是描述数据的一种通用形式,模式则是用给定的数据模型描述具体数据。注意:真正的数据内容保存在数据库状态(State)中。

  30. 用E-R概念模型表示的概念模式

  31. 用关系逻辑模型表示的概念模式

  32. 用关系逻辑模型表示的外模式及其实例 “教师教授课程”外模式及其实例 中文属性名 英文属性名 “学生选修课程”外模式及其实例

  33. 数据库系统的两级映射功能 • 两级映射(Mapping) • 概念模式/内模式映射 • 外模式/概念模式映射 • 数据独立性 • 物理独立性(Physical Data Independence) • 逻辑独立性(Logical Data Independence)

  34. 数据库系统的工作流程 • DBMS首先对数据查询语句进行语法检查,而后从数据字典中找到该用户对应的外模式,同时进行权限检查 • DBMS根据找到的外模式,利用概念模式/外模式映射,将其映射到概念模式,确定概念模式应该读入哪些数据

  35. 数据库系统的工作流程(续) • DBMS利用内模式/概念模式映射,将概念模式映射到内模式,确定数据库应读入哪些物理记录及其具体的地址 • DBMS根据地址信息向操作系统发出读取记录的命令 • 操作系统执行读取数据的命令,并将数据从硬盘读入系统缓冲区,将执行结果通知DBMS

  36. 数据库系统的工作流程(续) • DBMS根据查询语句及数据字典定义的信息,将系统缓冲区中的数据转换成用户所需的记录格式 • DBMS将数据记录从系统缓冲区传送到用户工作区

  37. 数据的物理独立性 • 内模式与概念模式之间的映射提供了数据的物理独立性。当数据的物理结构发生变化时,如对数据增加索引、改变数据的存储位置、改变存储设备等,不影响数据的逻辑结构。当DBA根据应用程序对数据的存取要求,对数据的物理组织进行优化后,并不需要对概念模式和外模式进行重新定义,也不需要修改应用程序,只需要修改内模式与概念模式之间的映射。

  38. 数据的逻辑独立性 • 概念模式与外模式之间的映射提供了数据的逻辑独立性。当数据的整体逻辑结构发生变化时,如增加新的关系、新的属性、改变属性的数据类型等,可以通过修改各个外模式与概念模式之间的映射,从而使外模式和依据外模式编写的应用程序不受影响。

  39. 本讲主要内容 • 2.1 数据模型、模式和实例 • 2.2 三层模式体系结构和数据独立性 • 2.3 数据库语言和接口(简单了解) • 2.4 数据库系统环境(自学,简单了解) • 2.5 集中式和客户/服务器体系结构

  40. 2.3 数据库语言和接口 • 数据库语言 • Data Definition Language (DDL): Used by the DBA and database designers to specify the conceptual schema of a database. • Data Manipulation Language (DML): Used to specify database retrievals and updates.

  41. 本讲主要内容 • 2.1 数据模型、模式和实例 • 2.2 三层模式体系结构和数据独立性 • 2.3 数据库语言和接口(简单了解) • 2.4 数据库系统环境(自学,简单了解) • 2.5 集中式和客户/服务器体系结构

  42. 数据库系统外部的体系结构 • Centralized Architecture • Combines everything into single system including:DBMS software, hardware, application programs, and user interface processing software. • User can still connect through a remote terminal(终端) –however, all processing is done at centralized site.

  43. Client-Server Architecture • 网络数据库系统:数据库系统软件安装在服务器上,通过网络向外界提供数据服务 • Client/Server:需要安装专门的客户端软件 • Browser/Server:不需要安装专门的客户端软件

  44. Client/Server架构

  45. Client/Server架构组件 Client Application SQL Server Server Net-Libraries Database API (OLE DB, ODBC, DB-Library) Open Data Services Relational Engine Client Net-Library Client Server Storage Engine Processor Memory Local Database

More Related