32
Database Systems Database Systems 高高高 [email protected]

Database Systems 高海昌 [email protected]. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade Introduction*

Embed Size (px)

Citation preview

Page 1: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

Database SystemsDatabase Systems

高海昌

[email protected]

Page 2: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 2

Major Content & GradeMajor Content & Grade Introduction * The Relational Model

*** SQL **** Transaction Management *** Database Design (E-R) *** Database Design (Normalization) ***

考核方式 笔试 (70%)+ 平时 ( 课堂 / 作业 / 上机 )

(30%)

Page 3: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 3

BooksBooks Book

Abraham Silberschatz, Henry F. Korth, S.Sudarshan, Database System Concepts (5th ed.), The McGraw-Hill Companies, 2006

Reference Books Thomas M. Connolly, et al. Database Systems: A practical

approach to Design, Implementation, and Management. 4th edition, Addison-Wesley, 2008

萨师煊,王珊 《数据库系统概论 》 高等教育出版社( 第 4 版 )

Page 4: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 4

Unit 1 IntroductionUnit 1 IntroductionData & Database DBMSDatabase SystemDatabase Applications Brief History of Data Management

Page 5: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 5

Data & DatabaseData & Database How to management Information (Data)?

data: data are raw facts that describe people, objects, and events.

Page 6: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 6

Data & DatabaseData & Database How to management Information(Data)?

Database : An integrated collection of related data constitutes a Database (DB).

Page 7: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 7

DBMSDBMS Database Management System (DBMS) : Contains

information about a particular enterprise Collection of interrelated data Set of programs to access the data An environment that is both convenient and efficient to use

DBMS

Application1

Application2

Database

……

Page 8: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 8

What should A DBMS needed?

DBMSDBMS

Data can be shared Redundancy( 冗余 ) can be reduced Inconsistency( 不一致性 ) can be avoided Transaction( 事务 ) support can be provided Integrity( 完整性 ) can be maintained Security( 安全性 ) can be enforced Conflicting( 冲突 ) requirements can be balanced Standards can be enforced

DBMS is less complex than OS.

Page 9: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 9

DBMSDBMS Architecture Architecture

Sno Sname Ssex Sage Sdept Cno Cname Cpno Ccredit

Sno Cno Grade

成绩单学号:xxxxx

姓名: xxx 性别: x

离散数据 75

数据库系统 81

…… ……

模式( Logical Schema, Schema ,也称逻辑模式) ——数据库中全体数据的逻辑结构和特征(型)的描述

外 模 式 ( External Schema ,也称子模式或用户模式) ——数据库用户使用的局部数据的逻辑结构和特征的描述

内 模 式 ( Physical Schema ,也称存储模式) ——数据物理结构和存储方式的描述

Page 10: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 10

DBMSDBMS Architecture Architecture ANSI/SPARC architecture

Page 11: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 11

1) Data definition(Data Definition Language—DDL)利用 DDL 可方便地对数据库中的数据对象进行定义。

2) Data manipulation(Data Manipulation Language—DML) 用户利用 DML 实现对数据库数据的基本操作,如查

询、插入、删除和修改等。3) Database running management 在数据库的建立、运行和维护时,由 DBMS 进行统一

管理、统一控制,以确保数据的安全性、完整性、多用户的并发操作及发生故障后的系统恢复。

4) Database establish and maintain 数据库初始数据的录入、转换功能、数据库的转储、

恢复功能、数据库的重组织和性能监视、分析功能等。一般由 DBMS中的一些实用程序完成。

Functions of DBMSFunctions of DBMS

Page 12: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 12

Database SystemDatabase System Database System: A computerized record-keeping systems,

composed by Data, Hardware, Software and People

User User User

Application

Development Tools

DBMS

OS

DB

DBA

Page 13: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 13

Components of Database SystemComponents of Database SystemData

Anything that is of significance to the individual or organization concerned

Two characters

integrated - needn’t include redundant information

shared – a record file should be shared by different user Multi-views

Hardware Secondary storage volume

I/O device, Device controller, I/O channel, etc Processor and Main memory

Page 14: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 14

Components of Database SystemComponents of Database SystemSoftware

OS

Unix , Linux, OS/2, Windows NT … Database Management System

Oracle, DB2, Sybase, MySQL, PostgreSQL, … Others software

utilities, application development tools, designs aid, report writer, transaction manager

Page 15: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 15

Components of Database SystemComponents of Database System People

End users—Interactive users. Casual users (临时用户 ):facility with SQL… Naive users (初级用户 ): bank clerks…

Application programmers An application programmer, in the sense used with

DBMS, writes the menu applications used by naive users.

DBA (database administrator) A DBA is a computer professional responsible for

the design and maintenance of the database.

Page 16: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 16

题外:数据库领域的三位图灵奖得主题外:数据库领域的三位图灵奖得主 Charles W. Bachman( 查尔斯 • 巴赫曼 )   1973

主持设计与开发了最早的网状数据库管理系统IDS ,它的设计思想和技术直接影响了后来的数据库。他还促成了数据库标准的制定,即DDL 和 DML 规范说明。

Edgar F. Codd( 埃德加 • 科德 )   1981 于 1970 年 6 月发表了题为“ A Relational Model of Data for Large Shared Data Banks” 一文,首次 明确而清晰地为数据库系统提出了一种崭新的模 型,即关系模型。一经提出迅速商品化。

James Gray( 詹姆斯 • 格雷 )   1998 在事务处理技术上的创造性思维和开拓性工作, 使他成为该技术领域公认的权威。在解决保障 数据的完整性、安全性、并行性,以及从故障 中恢复方面发挥了十分关键的作用。

Page 17: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 17

Unit 1 IntroductionUnit 1 IntroductionData & Database DBMSDatabase SystemDatabase Applications Brief History of Data Management

Page 18: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 18

Database ApplicationsDatabase Applications Database contains information about a particular enterprise.

Database Applications: Banking: all transactions Airlines: reservations, schedules Universities: registration, grades Sales: customers, products, purchases Manufacturing: production, inventory, orders, supply chain Human resources: employee records, salaries, tax deductions ……

Databases touch all aspects of our lives

Page 19: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 19

Database Applications ArchitectureDatabase Applications Architecture Client/Server architecture

Page 20: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 20

Browser/Server architecture

Database Applications ArchitectureDatabase Applications Architecture

Page 21: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 21

Brief History of Data ManagementBrief History of Data Management In the early days(Before 1960s), database applications were

built on top of FILE systems

File1

File2

Filen

Prog1

Prog2

Progn

File System

Page 22: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 22

Brief History of Data ManagementBrief History of Data Management Drawbacks of using FILE SYSTEMS :

Data redundancy and inconsistency( 不一致性 ) Difficulty in accessing data Data isolation Integrity problems Atomicity of updates Concurrent access by multiple users Security problems

It’s impossible to programmers for even ONE solution!

Page 23: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 23

Brief History of Data ManagementBrief History of Data Management Management using DBMS Database systems offer solutions to all the above problems in using file systems !

DBProg1

Prog2

Progn

DBMS

Page 24: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 24

History of Database SystemHistory of Database System Hierarchical system (1960s)

IBM’s IMS data represent to user is the form of tree structure IMS provided the hierarchical data model, where different

kinds of records relate to one another in a hierarchical form.

data shared by several applications

R3

R1

R2

R5R4

Page 25: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 25

Example of Hierarchical systemExample of Hierarchical system学院D01 通信工程 主楼 II 区D02 电子工程 主楼 III 区D03 计算机 主楼 I 区…… …… ……

教研室R0101 信息科学研究所R0102 信息保密研究所…… ……

R0301 应用教研室R0302 软件实践中心R0303 软件教研室…… ……教师

E0102 王大明 男E0103 李明丽 女…… …… ……

E0313 陈芝 女E0315 孟正堂 男…… …… ……

用指针实现记录间的联系!

Page 26: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 26

History of Database SystemHistory of Database System Network System (1960s)

Cullinet Software IDMS (CODASYL DBTG Report) The network data model, a generalization of the

hierarchical model where a set of record in one layer might have two different containing hierarchies at the next layer up.

data represent to user is graph structure operator similar to hierarchical system

Bachman

Page 27: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 27

Example of Network SystemExample of Network System

CS王杰S003

……………

CS张娜S002

CS李小明S001

S

4计算机原理C02

……………

3高等数学C01

C

65C01S002

84C02S002

91C01S003

85C02S003

……

…..……

78C02S001

80C01S001

SC

Page 28: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 28

History of Database SystemHistory of Database System Relational system (1970s)

data representation are table, operator generate new tables from old tables

In a relational database, all information is represented in the form of named tables (relation) with labeled column (attribute)

In the relational model, a column of a table must contain a single, unstructured value(first normal form rule)

Products : SQL server, Oracle, Sybase, DB2, Informix, Ingres, etc.

Codd

Page 29: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 29

Example of Relational SystemExample of Relational System

sid lname fname class tel

1 Jones Allan 2 882012342 Smith John 3 882012333 Brown Harry 2 882022554 White Edward 3 88201688

cno cname croom time

101 English I I-101 MW2102 English II I-102 MW3105 Math II-101 MW2108 Chinese II-202 MW4

sid cno major

1 101 No1 108 Yes2 105 No3 101 Yes3 108 No4 102 No4 105 No

students

courses

enrollment ( 注册 )

Page 30: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 30

History of Database SystemHistory of Database System Object-Relational system (1980s)

In an object-relational database, information is still represented as in the relational model in the form of named tables with labeled columns

but the column values are no longer restricted by the First Normal Form rule (can be STRUCT or SET datatype).

Page 31: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 31

Example of ORDBMSExample of ORDBMS

Sidname

class telenrollment

lname fname cno major

1 Jones Allan 2 88201234 101 No108 Yes

2 Smith John 3 88201233 105 No3 Brown Harry 2 88202255 101 Yes

108 No4 White Edward 3 88201688 102 No

105 No

cno cname croom time

101 English I I-101 MW2102 English II I-102 MW3105 Math II-101 MW2108 Chinese II-202 MW4

students

courses

Page 32: Database Systems 高海昌 hchgao@xidian.edu.cn. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*

DataBase System

Haichang Gao , Software School , Xidian University 32

History of Database SystemHistory of Database System 1990s:

Large decision support and data-mining applications Large multi-terabyte data warehouses Emergence of Web commerce

2000s: XML and XQuery standards Automated database administration