数据库(database)

上传人:飞*** 文档编号:54859127 上传时间:2018-09-20 格式:PPT 页数:65 大小:846KB
返回 下载 相关 举报
数据库(database)_第1页
第1页 / 共65页
数据库(database)_第2页
第2页 / 共65页
数据库(database)_第3页
第3页 / 共65页
数据库(database)_第4页
第4页 / 共65页
数据库(database)_第5页
第5页 / 共65页
点击查看更多>>
资源描述

《数据库(database)》由会员分享,可在线阅读,更多相关《数据库(database)(65页珍藏版)》请在金锄头文库上搜索。

1、Lecturer: 周晓慧,Fundamentals of Software Technology Part 3 Database,assignment p112: 12, 15,16,17,19 p267: 一. From DB to 索引 二. From 1 to 14, and 16, 24, 26, 38, 40, 42 四. 8.,Chapter 1 数据库管理系统的结构 (Database management system architecture) 一 . 为什么要数据库 Database system versus file system 数据冗余和数据不一致文件系统存在数据

2、冗余,从而导致数据的不一致 Student ID student name course score 年龄 200161120 李平 C 语言 90 19 200161120 李平 C+ 80 19 200161121 张三 C 语言 65 18 200161121 张三 C+ 78 18 200161122 王五 C+ 88 230,数据完整性问题文件系统不能保证数据的完整性,而存在数据库中的数据可以满足一定的约束。有三类数据完整性约束 a. 用户定义的数据完整性用户要求存在数据库中的数据要满足一定的要求。 For example, age must be never beyond 220。

3、定义完age220后,在插入age数据到数据库时,数据库系统(是一软件)会自动判断age是否小于220,若否,数据库系统报警,不让插入。 b. 实体完整性 主码不能为空,并且唯一,因为一实体表示一客观存在,该客观存在是唯一的,所以主码不能为空,并且唯一。见操作,数据完整性问题 存在数据库中的数据要求满足一定的约束。 c. 参照完整性主码不能为空,并且唯一,因为一实体表示一客观存在,该客观存在是唯一的,所以主码不能为空,并且唯一。见操作,一 . 为什么要数据库 迸发操作的异常(Concurrent-access anomalies)文件系统中,当多个用户对同一数据进行迸发修改时,产生数据异常。

4、Bus from city to city amount (票的数量) 杭州 到 上海 1 杭州 到 北京 30 Two customers read the number of tickets from Hangzhou to Shanghai is one almost in the same time. Then, each of them gets a ticket from Hangzhou to Shanghai with the same seat number. Finally, they will fight on the bus for that seat.,程序对数据的依

5、赖(Program independent on data)文件系统中,程序与数据是不独立的。 For example, fopen( c:zhouletter.doc, “rw” );文件名或文件路径发生变化, fopen的第一个参数就要重写。,迸发控制文件系统中,多个用户对同一数据操作,数据可能产生数据不一致。 如,前页PPT的例子中,系统实现卖出一张票的程序如下: amount = amount 1; /设amount的初值为8。 假设有2个迸发操作,即有2位客户各买了一张票。P1 P2 amount = amount 1; amount = amount 1; 由于P1、P2执行顺序的

6、问题,amount的值可能为7,6,数据恢复文件系统中,机器突然掉电,数据可能丢失或产生数据不一致。 如,超市销售: Supermarket_amount为超市的销售总金额, person_amount为个人信用卡总金额 个人采购金额为:500元则,销售程序为:. Supermarket_amount = Supermarket_amount + 500; /语句 1 person_amount = person_amount 500; /语句 2执行完语句1,机器突然掉电,谁吃亏了?,数据库基本概念1. 数据库(DataBase,简称DB)数据库是长期存放在计算机内、有组织、可共享的数据集合

7、,可供多用户共享,数据库中的数据按一定的数据模型组织、描述和储存,具有尽可能小的冗余度和较高的数据独立性和易扩展性,并可为各种用户共享。,2. 数据库管理系统(DBMS)是软件,如ORACLE、SQL-SERVER、ACESS等 数据库系统的核心组成部分,对数据进行管理的软件。 主要功能: 数据定义 :对数据库中的数据对象(包括表、视图、索引等)进行定义 。 数据操纵 :对数据库操作 查询 插入 删除 修改等 数据库的运行管理:对数据库的建立、运用和维护进行统一管理和控制 安全性控制、完整性控制、并发控制、备份与恢复 数据库的建立和维护功能 数据库初始数据的输入和转换功能、数据库的转储和恢复功

8、能以及数据库重组织功能和性能监视、分析功能等。,3. 数据库应用系统 在计算机系统中引入数据库后的系统构成 组成:数据库(及相关硬件)、数据库管理系统及开发工具、应用系统、数据库管理员和用户等。 数据库管理员(DataBase Administrator,简称DBA),数据库应用系统 示意图,数据库在计算机系统中的地位示意图,table students Student ID student name age sex 200161120 李平 19 male 200161121 张三 18 female 200161122 王五 230 male table courses Course ID

9、 course prerequisite 0001 C 语言 0002 C+ table student_course Student ID Course ID score 200161120 0001 90 200161120 0002 80 200161121 0001 65 200161121 0001 78,4. 数据库应用系统的结构(Architecture),5. 数据库系统结构,数据库的三级模式结构,数据库系统体系结构 集中式数据库系统:数据是集中的,数据的管理也是集中的 客户/服务器数据库系统:数据是集中的,应用分布 分布式数据库系统 :数据分布、应用分布,分布式数据库系统,客

10、户/服务器数据库系统,数据模型(Data model): 描述数据和数据间的联系(数据结构), 描述的方法有:层次模型、网状模型、关系模型和面向对象的数据模型,既存在数据库中的数据是结构化的。,层次模型(树) 要通过链表自己确定查询路径,网状模型(图) 要通过链表自己确定查询路径,table students Student ID student name age sex 200161120 李平 19 male 200161121 张三 18 female 200161122 王五 230 male table courses Course ID course prerequisite 00

11、01 C 语言 0002 C+ table student_course Student ID Course ID score 200161120 0001 90 200161120 0002 80 200161121 0001 65 200161121 0001 78,表(用表来描述数据和数据间的联系) DBMS会确定查询路径,模式(Schema): 描述整个数据库的结构 (对关系数据库而言,所有表的表定义, e.g. table students, course, and students_courses). 子模式(Subschema): portion of the database

12、pertinent to a particular users needs. What Program developers see the schema, e.g. maybe portion of the a table. 物理模式(Physical schema): 存储模式(Stored schema), designed by DBA (database administrator). Application developer and user dont know where and how schema stored in the disk.,数据的独立性(Data indepe

13、ndency)当数据库中的模式或物理模式发生变化时,程序不变或变化很少。(When the schema or physical schema changed, but the programs are not changed or changed a little). 逻辑独立性(Logical independency)当数据库中的模式变化时,子模式不变或变化很少,从而基于子模式的程序不变或变化很少。通过物理模式与模式之间的映射实现。 (While the schema in a database is changed, but the subschema is not changed o

14、r changed a little. This leads to the programs based on the subschema not changed or changed a little. ),物理独立性(Physical independency)当数据库中的物理模式发生变化,但,模式不变或变化很少,从而子模式不变或变化很少,导致程序不变或变化很少。通过物理模式与模式之间的映射实现。 (While the physical schema in a database is changed, but the schema is not changed. This leads to the programs based on the subschema not changed.) 分布式数据库(Distributed database): a database spread over several machines in a network,

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号