Presentation is loading. Please wait.

Presentation is loading. Please wait.

计算机科学引论 数据库系统.

Similar presentations


Presentation on theme: "计算机科学引论 数据库系统."— Presentation transcript:

1 计算机科学引论 数据库系统

2 An Introduction to Database System
数据库 数据库就是一大堆数据 数据的创建、插入、删除 数据的快速访问 数据的存储、访问控制 …… An Introduction to Database System

3 An Introduction to Database System
数据库的重要性 数据库非常重要 1.数据非常重要 经营管理、产品开发、工资福利、科学研究…… 数据中隐藏了大量的知识 2.对数据的管理和使用有很大的共同点 可以设计一个比较通用的软件来帮助这些应用管理其相关的数据 An Introduction to Database System

4 An Introduction to Database System
四个基本概念 数据(Data) 数据库(Database) 数据库管理系统(DBMS) 数据库系统(DBS) An Introduction to Database System

5 An Introduction to Database System
数据 数据(Data)是数据库中存储的基本对象 数据的定义 描述事物的符号记录 数据的种类 文字、图形、图象、声音 数据的特点 数据与其语义是不可分的 没有语义的数据是没有用处的 An Introduction to Database System

6 An Introduction to Database System
数据举例 学生档案中的学生记录 (李明,男,1972,江苏,计算机系,1990) 数据的形式不能完全表达其内容 数据的解释 语义:学生姓名、性别、出生年月、籍贯、所在系别、入学时间 解释:李明是个大学生,1972年出生,江苏人,1990年考入计算机系 An Introduction to Database System

7 An Introduction to Database System
数据库 人们收集并抽取出一个应用所需要的大量数据之后,应将其保存起来以供进一步加工处理,进一步抽取有用信息 数据库的定义 数据库(Database,简称DB)是长期储存在计算机内、有组织的、可共享的大量数据集合 An Introduction to Database System

8 An Introduction to Database System
数据库管理系统 什么是DBMS 专门管理数据的软件 DBMS的用途 科学地组织和存储数据、高效地获取和维护数据 上层程序可以不再关心数据的管理问题 大量程序有类似的数据管理要求 An Introduction to Database System

9 An Introduction to Database System
数据库系统 数据库系统(DBS: Database System) 物理上:DBS=DB+DBMS+计算机 逻辑上:用户看到的是其中存储的数据库 在不引起混淆的情况下常常把数据库系统简称为数据库。 因为我们只关心这个 An Introduction to Database System

10 An Introduction to Database System
数据管理中的问题 1.数据的语义和结构 数据库中必须同时存储数据和其语义 没有语义的数据是没有用处的 DDL:Data Definition Language 定义数据的结构的语言 计算机尚不能真正理解数据的语义尚没有真正的语义定义语言 适合计算机使用,但人难以理解 概念模型 An Introduction to Database System

11 An Introduction to Database System
概念模型 概念模型的用途 概念模型用于信息世界的建模 是现实世界到机器世界的一个中间层次 是数据库设计的有力工具 数据库设计人员和用户之间进行交流的语言 对概念模型的基本要求 较强的语义表达能力,能够方便、直接地表达应用中的各种语义知识 简单、清晰、易于用户理解。 An Introduction to Database System

12 An Introduction to Database System
信息世界中的基本概念 实体(Entity): 客观存在并可相互区别的事物 可以是具体的人、事、物或抽象的概念 实体型(Entity Type):实体的类型 实体集(Entity Set):同型实体的集合 属性(Attribute): 实体所具有的某一特性 例:人的生日、性别、身高。 地址是人的属性吗? 地址是一个属性,但是否是人的属性依赖于所使用的信息模型(如一个人只能有一个地址,则地址可以是人的属性) 域(Domain):属性的取值范围 An Introduction to Database System

13 An Introduction to Database System
信息世界中的基本概念 键(Key) : 唯一标识实体的属性集称为键。 例:身份证号码 人名? 联系(Relation):实体和实体之间的关系 联系也可以有属性 联系类型 1:1,1:n,m:n An Introduction to Database System

14 An Introduction to Database System
E-R图 实体型 用矩形表示,矩形框内写明实体名。 学生 教师 An Introduction to Database System

15 An Introduction to Database System
E-R图(续) 属性 用椭圆形表示,并用无向边将其与相应的实体连接起来 学生 学号 年龄 性别 姓名 An Introduction to Database System

16 An Introduction to Database System
E-R图(续) 联系 联系本身:用菱形表示,菱形框内写明联系名,并用无向边分别与有关实体连接起来,同时在无向边旁标上联系的类型(1:1、1:n或m:n) 联系的属性:联系本身也是一种实体型,也可以有属性。如果一个联系具有属性,则这些属性也要用无向边与该联系连接起来 An Introduction to Database System

17 An Introduction to Database System
联系的表示方法示例 班级 班级-班长 班长 1 1:1联系 课程 选修 学生 m n m:n联系 组成 1:n联系 An Introduction to Database System

18 An Introduction to Database System
联系的表示方法示例(续) 职工 领导 1 n 同一实体型内部的1:n联系 课程 讲授 教师 m 多个实体型间的1:n联系 参考书 An Introduction to Database System

19 An Introduction to Database System
联系属性的表示方法 课程 选修 学生 m n 成绩 An Introduction to Database System

20 An Introduction to Database System
数据模型 概念模型是给人使用的 计算机难以直接使用 数据模型 计算机用于抽象、表示和处理现实世界中的数据和信息的模型 An Introduction to Database System

21 An Introduction to Database System
常用数据模型 非关系模型 层次模型(Hierarchical Model) 网状模型(Network Model ) 数据结构:以基本层次联系为基本单位 基本层次联系:两个记录以及它们之间的一对多(包括一对一)的联系 An Introduction to Database System

22 An Introduction to Database System
常用数据模型(续) 关系模型(Relational Model) 数据结构:表 面向对象模型(Object Oriented Model) 数据结构:对象 An Introduction to Database System

23 An Introduction to Database System
层次数据模型的数据结构 1 根结点 2 兄弟结点 3 叶结点 4 5 An Introduction to Database System

24 An Introduction to Database System
层次模型的优缺点 优点 层次数据模型简单,对具有一对多的层次关系的部门描述自然、直观,容易理解 性能优于关系模型,不低于网状模型 层次数据模型提供了良好的完整性支持 缺点 多对多联系表示不自然 对插入和删除操作的限制多 查询子女结点必须通过双亲结点 层次命令趋于程序化 An Introduction to Database System

25 An Introduction to Database System
典型的层次数据库系统 IMS数据库管理系统 第一个大型商用DBMS 1968年推出 IBM公司研制 An Introduction to Database System

26 An Introduction to Database System
网状数据模型的数据结构 1 2 R3 L L2 R1 R2 L3 L1 L2 R3 L4 R4 R5 An Introduction to Database System

27 An Introduction to Database System
网状模型的优缺点 优点 能够更为直接地描述现实世界,如一个结点可以有多个双亲 具有良好的性能,存取效率较高 缺点 结构比较复杂,而且随着应用环境的扩大,数据库的结构就变得越来越复杂,不利于最终用户掌握 DDL、DML语言复杂,用户不容易使用 An Introduction to Database System

28 An Introduction to Database System
典型的网状数据库系统 DBTG系统,亦称CODASYL系统 由DBTG提出的一个系统方案 奠定了数据库系统的基本概念、方法和技术 70年代推出 实际系统 Cullinet Software Inc.公司的 IDMS Univac公司的 DMS1100 Honeywell公司的IDS/2 HP公司的IMAGE An Introduction to Database System

29 An Introduction to Database System
关系模型 最重要的一种数据模型。也是目前主要采用的数据模型 1970年由美国IBM公司San Jose研究室的研究员E.F.Codd提出 本科数据库课程的重点 An Introduction to Database System

30 An Introduction to Database System
关系数据模型的数据结构 在用户观点下,关系模型中数据的逻辑结构是一张二维表,它由行和列组成。 An Introduction to Database System

31 An Introduction to Database System
关系模型的基本概念 关系(Relation) 一个关系对应通常说的一张表。 元组(Tuple) 表中的一行即为一个元组。 属性(Attribute) 表中的一列即为一个属性,给每一个属性起一个名称即属性名。 An Introduction to Database System

32 An Introduction to Database System
关系模型的基本概念 主码(Key) 表中的某个属性组,它可以唯一确定一个元组。 域(Domain) 属性的取值范围。 分量 元组中的一个属性值。 关系模式 对关系的描述 关系名(属性1,属性2,…,属性n) 学生(学号,姓名,年龄,性别,系,年级) An Introduction to Database System

33 An Introduction to Database System
关系模型的优缺点 优点 建立在严格的数学概念的基础上 概念单一。数据结构简单、清晰,用户易懂易用 实体和各类联系都用关系来表示。 对数据的检索结果也是关系。 关系模型的存取路径对用户透明 具有更高的数据独立性,更好的安全保密性 简化了程序员的工作和数据库开发建立的工作 An Introduction to Database System

34 An Introduction to Database System
关系模型的优缺点(续) 缺点 存取路径对用户透明导致查询效率往往不如非 关系数据模型 为提高性能,必须对用户的查询请求进行优化 增加了开发数据库管理系统的难度 An Introduction to Database System

35 An Introduction to Database System
典型的关系数据库系统 ORACLE SYBASE INFORMIX DB/2 COBASE PBASE EasyBase DM/2 OpenBase An Introduction to Database System

36 An Introduction to Database System
数据库系统结构 数据库的存储和应用的矛盾 存储:数据的独立性、修改的方便性 尽可能减少冗余:任何一份数据只存储一次 使用:数据的易用性、信息的完整性 可能包含冗余:为方便使用把同一份数据复制到各处 An Introduction to Database System

37 An Introduction to Database System
数据库系统结构 数据库的存储和应用的矛盾 例:学生数据库 学生有属性:姓名、系、年级 学生可选多门课程 大学语文 生活导论 An Introduction to Database System 大量冗余信息

38 An Introduction to Database System
数据库系统结构 数据库的存储和应用的矛盾 用不同的模式来满足存储和应用的各自需求 数据库系统内部的模式结构 从数据库管理系统角度看 数据库系统外部的体系结构 从数据库最终用户角度看 An Introduction to Database System

39 An Introduction to Database System
数据库系统模式的概念 “型” 和“值” 的概念 型(Type) 对某一类数据的结构和属性的说明 值(Value) 是型的一个具体赋值 例如:学生记录 记录型: (学号,姓名,性别,系别,年龄,籍贯) 该记录型的一个记录值: (900201,李明,男,计算机,22,江苏) An Introduction to Database System

40 An Introduction to Database System
数据库系统模式的概念(续) 模式(Schema) 数据库逻辑结构和特征的描述 是型的描述 反映的是数据的结构及其联系 模式是相对稳定的 模式的一个实例(Instance) 模式的一个具体值 反映数据库某一时刻的状态 同一个模式可以有很多实例 实例随数据库中的数据的更新而变动 An Introduction to Database System

41 An Introduction to Database System
1.模式(Schema) 模式(也称逻辑模式) 数据库中全体数据的逻辑结构和特征的描述 所有用户的公共数据视图,综合了所有用户的需求 一个数据库只有一个模式 模式的地位:是数据库系统模式结构的中间层 与数据的物理存储细节和硬件环境无关 与具体的应用程序、开发工具及高级程序设计语言无关 模式的定义 数据的逻辑结构(数据项的名字、类型、取值范围等) 数据之间的联系 数据有关的安全性、完整性要求 An Introduction to Database System

42 An Introduction to Database System
2. 外模式(External Schema) 外模式(也称子模式或用户模式) 数据库用户(包括应用程序员和最终用户)使用的局部数据的逻辑结构和特征的描述 数据库用户的数据视图,是与某一应用有关的数据的逻辑表示 An Introduction to Database System

43 An Introduction to Database System
外模式(续) 外模式的地位:介于模式与应用之间 模式与外模式的关系:一对多 外模式通常是模式的子集 一个数据库可以有多个外模式。反映了不同的用户的应用需求、看待数据的方式、对数据保密的要求 对模式中同一数据,在外模式中的结构、类型、长度、保密级别等都可以不同 外模式与应用的关系:一对多 同一外模式也可以为某一用户的多个应用系统所使用, 但一个应用程序只能使用一个外模式。 An Introduction to Database System

44 An Introduction to Database System
外模式(续) 外模式的用途 保证数据库安全性的一个有力措施。 每个用户只能看见和访问所对应的外模式中的数据 An Introduction to Database System

45 3.内模式(Internal Schema)
内模式(也称存储模式) 是数据物理结构和存储方式的描述 是数据在数据库内部的表示方式 记录的存储方式(顺序存储,按照B树结构存储,按hash方法存储) 索引的组织方式 数据是否压缩存储 数据是否加密 数据存储记录结构的规定 一个数据库只有一个内模式 An Introduction to Database System

46 An Introduction to Database System
三级模式与二级映象 三级模式是对数据的三个抽象级别 二级映象在DBMS内部实现这三个抽象层次的联系和转换 An Introduction to Database System

47 An Introduction to Database System
数据库系统的三级模式结构 An Introduction to Database System

48 An Introduction to Database System
外模式/模式映象 定义外模式与模式之间的对应关系 每一个外模式都对应一个外模式/模式映象 映象定义通常包含在各自外模式的描述中 An Introduction to Database System

49 An Introduction to Database System
外模式/模式映象的用途 保证数据的逻辑独立性 当模式改变时,数据库管理员修改有关的外模式/模式映象,使外模式保持不变 应用程序是依据数据的外模式编写的,从而应用程序不必修改,保证了数据与程序的逻辑独立性,简称数据的逻辑独立性。 An Introduction to Database System

50 An Introduction to Database System
2.模式/内模式映象 模式/内模式映象定义了数据全局逻辑结构与存储结构之间的对应关系。例如,说明逻辑记录和字段在内部是如何表示的 数据库中模式/内模式映象是唯一的 该映象定义通常包含在模式描述中 An Introduction to Database System

51 An Introduction to Database System
模式/内模式映象的用途 保证数据的物理独立性 当数据库的存储结构改变了(例如选用了另一种存储结构),数据库管理员修改模式/内模式映象,使模式保持不变 应用程序不受影响。保证了数据与程序的物理独立性,简称数据的物理独立性。 An Introduction to Database System

52 An Introduction to Database System
数据库系统的组成 数据库 数据库管理系统(及其开发工具) 应用系统 数据库管理员 (用户) An Introduction to Database System

53 An Introduction to Database System
硬件平台及数据库 数据库系统对硬件资源的要求 (1) 足够大的内存 操作系统 DBMS的核心模块 数据缓冲区 应用程序 An Introduction to Database System

54 An Introduction to Database System
数据库系统对硬件资源的要求 (2) 足够大的外存 磁盘 操作系统 DBMS 应用程序 数据库及其备份 光盘、磁带、软盘 数据备份 (3) 较高的通道能力,提高数据传送率 An Introduction to Database System

55 An Introduction to Database System
软件 DBMS 操作系统 与数据库接口的高级语言及其编译系统 以DBMS为核心的应用开发工具 为特定应用环境开发的数据库应用系统 An Introduction to Database System

56 An Introduction to Database System
人员 数据库管理员 系统分析员 数据库设计人员 应用程序员 (最终用户) An Introduction to Database System

57 An Introduction to Database System
数据库管理员(DBA) 决定数据库中的信息内容和结构 决定数据库的存储结构和存取策略 定义数据的安全性要求和完整性约束条件 An Introduction to Database System

58 An Introduction to Database System
数据库管理员(续) 监控数据库的使用和运行 周期性转储数据库 数据文件 日志文件 系统故障恢复 介质故障恢复 监视审计文件 An Introduction to Database System

59 An Introduction to Database System
数据库管理员(续) 数据库的改进和重组 性能监控和调优 数据重组 数据库重构 An Introduction to Database System

60 An Introduction to Database System
系统分析员 负责应用系统的需求分析和规范说明 与用户及DBA协商,确定系统的硬软件配置 参与数据库系统的概要设计 An Introduction to Database System

61 An Introduction to Database System
数据库设计人员 参加用户需求调查和系统分析 确定数据库中的数据 设计数据库各级模式 An Introduction to Database System

62 An Introduction to Database System
应用程序员 设计和编写应用系统的程序模块 进行调试和安装 An Introduction to Database System

63 An Introduction to Database System
用户 偶然用户 企业或组织机构的高中级管理人员 简单用户 银行的职员、机票预定人员、旅馆总台服务员 An Introduction to Database System

64 An Introduction to Database System
用户(续) 复杂用户 工程师、科学家、经济学家、科技工作者等 直接使用数据库语言访问数据库,甚至能够基于数据库管理系统的API编制自己的应用程序 An Introduction to Database System

65 Thanks!


Download ppt "计算机科学引论 数据库系统."

Similar presentations


Ads by Google