An Introduction to Database System College of Computer Science and Technology Chongqing University...

33
An Introduction An Introduction to to Database System Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006

Transcript of An Introduction to Database System College of Computer Science and Technology Chongqing University...

Page 1: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

An Introduction to An Introduction to Database SystemDatabase System

College of Computer Science and TechnologyChongqing University of Posts & Telecom.

Spring, 2006

Page 2: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

2

Principles of Database SystemsPrinciples of Database Systems• Professor: Yu Wu

– Email: [email protected] (best way to reach me)– Office: S1901, 62460709

• Teaching Assistant:_____– Email:– Office:

• Class web page: – http://www.cqupt.edu.cn/database– http://cs.cqupt.edu.cn/database

• My web page: http://cs.cqupt.edu.cn/wuyu

Page 3: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

3

TextbooksTextbooks• Required:

– A First Course in Database Systems, by Jeffrey D.Ullman Jennifer Widom.

• Recommended: – 萨师煊 , 王珊 . 数据库系统概论 ( 第三

版 ). 高等教育出版社 , 2000 年– Books on SQL Server 2000

• You may also want:– Books on design and programming : P

owerbuilder, PowerDesigner, UML, VB, Delphi, VC, JAVA, C#, ASP, PHP, JSP etc.

Page 4: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

4

SyllabusSyllabus• Background and history of database

management systems• Fundamentals of using a database management

systems: SQL 2000.(*extracurricular)• Database modeling• Relational model: theoretical background and

operations • Database Language SQL• Fundamentals of database management

systems: transactions and security etc. • Database system design and practice

Page 5: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

Chapter 1Chapter 1The Worlds of Database SystemsThe Worlds of Database Systems

•Evolution of Database Systems

•Architecture of DBMS and DBS

•Future of Database Systems

Page 6: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

6

1.1 Evolution of Database Systems1.1 Evolution of Database Systems

1.1.1 Some Basic notions– Data– Database (DB)– Database Management System (DBMS) – Database System (DBS).– Database Administrator (DBA)

Page 7: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

7

Basic NotionsBasic Notions• Data

– Distinct pieces of information represented in a form suitable for processing by computer.

– Data can exist in a variety of forms -- as digital numbers, text, image, sound, video and etc.

• Database (DB) – In essence, it’s nothing more than a collection of

information that exists over a long period of time.– In common parlance, it refers to a collection of data

managed by a database management system (DBMS) or just database system (DBS).

Page 8: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

8

Example of Data and DatabaseExample of Data and Database• Data

– Record of student archive(李明,男, 1972 ,江苏,计算机系, 1990 )

• Database (DB)

学生登记表

学 号 姓 名 年 龄 性 别 系 名 年 级

95004 王小明 19 女 社会学 95

95006 黄大鹏 20 男 商品学 95

95008 张文斌 18 女 法律学 95

… … … … … …

Page 9: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

9

DBMSDBMS

• Database Management System (DBMS) – A collection of programs that enables you to s

tore, modify, and extract information from a database.

– There are many different types of DBMSs, ranging from small systems that run on personal computers to huge systems that run on mainframes.

Page 10: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

10

Basic functions of DBMSBasic functions of DBMS• Data definition

– Allow creating new databases and specify their schema (logical structure of the data), via data definition language (DDL).

• Data manipulation– Allow efficient access to the data, such as querying and

modifying the data, via query language or data manipulation language (DML).

• Operation management of DB– Support the storage of very large amounts of data over a long

period of time, assuring data integrity, keeping data secure from accident or unauthorized use. Support concurrent, atomic access to data. (Example: bank and its ATM machines.)

• Creation and maintenance of DB– Such as inputting and transferring of Data, DB backup and

recovery, performance monitoring, audit and analysis etc.

P1Reading book

Page 11: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

11

Database System Database System (DBS)(DBS)• Database System (DBS).

– DB, DBMS, Development Tools, DB applications, DB Administrator (DBA) and users

DB

OS

DBMS

Developing Tools

DB applications

User User

DBA Hardware

Operation System

DBMS, Compiling System

Developing Tools

Application Systems

DBMS in Computer System

Page 12: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

12

Database UsersDatabase Users• 用户( Database Users )可以按照使用系

统的不同方式进行区分– 复杂用户

• 可直接使用查询语言的技术人员• 专家用户:可根据需要编写特定的数据库应用程序

– 简单用户• 使用编制好的应用程序访问数据库• 如银行的职员、机票预定人员、旅馆总台服务员

– 偶然用户• 企业或组织机构的高中级管理人员

Page 13: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

13

Database AdministratorDatabase Administrator

• DBA– Person who is responsible for management a

nd maintenance of DB.

• 具体任务– 决定数据库中信息内容和结构– 存储结构和存取方式定义– 定义数据的安全性和完整性约束条件– 改进和重构数据库系统– 监控数据库的使用和运行

Page 14: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

14

其它人员 其它人员 • 系统分析员

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

• 数据库设计人员– 参加用户需求调查和系统分析– 确定数据库中的数据– 设计数据库各级模式

• 应用程序员– 设计和编写应用系统的程序模块– 进行调试和安装

Page 15: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

15

问题问题• 在一个大公司的工资单系统中,指出哪些

类型的用户执行以下功能?– a. 编写一个应用程序以生成和打印帐单– b. 改变一个已搬家的员工在数据库中的地址– c. 为一个新职工的工资单创建一个新的用户帐

应用程序员用户DBA

Page 16: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

16

DataData• 数据是 DBMS 的核心• 两类数据

– 显然数据• 所需数据集合

– 元数据( metadata )• 关于数据库的信息,通常保存在数据字典或目录中• 数据字典中的信息包括与用户、权限和数据库内部

的结构有关的信息

Page 17: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

17

1.1.2 History of Data management1.1.2 History of Data management• File systems

– Problems: limited support to definition of data schema, no directly support to DML (Data Manipulate Language), no support to efficient concurrent, secure access etc.

• Early DBMS– The first commercial DBMS appeared in the late 1960’s,

evolved from file systems.– The early DBMS’s used several data models for describ

ing structure of DB: hierarchical model and network model.

– Problems: no support to high-level query languages.

P2

Page 18: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

18

History of Data management (cont.History of Data management (cont. ))

• Relational DBMS– A famous paper by Ted Codd in 1970, “A relational m

odel for large shared data banks” in Comm. ACM.– Data organized as tables called relations.– Unlike the user of early DBS, user of a relational syste

m won’t be concerned with the storage structure, and queries are expressed in a very high-level language (SQL).

– Today used in most DBMS's.

P4

Page 19: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

19

Relational ModelRelational Model

• Based on tables, such as:

acct # name balance

12345 Sally 1000.21

34567 Sue 285.48

… … …

Attributes(column headers)

Tuples(rows)

P4

Page 20: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

20

Query LanguagesQuery Languages

Employee

Name Dept

Department

Dept Manager

SELECT ManagerFROM Employee, DepartmentWHERE Employee.name = "Clark Kent”

AND Employee.Dept = Department.Dept ;

Page 21: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

21

History of Data ModelHistory of Data Model• Data model:

– abstraction of data features in real world into computer world.

Hierarchical model

60’s

70's

80's

90’s

now

Relational modelChoice for most new

applications

Object Bases model Knowledge Bases model

Network model

P3

Page 22: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

22

Relational model or not?Relational model or not?• Relational model is good for:

– Large amounts of data —> simple operations– Navigate among small number of relations

• Difficult Applications for relational model:– VLSI Design (CAD in general)– CASE: Computer-Aided Software Engineering– Graphical Data

• Where number of "relations" is large, relationships are complex– Object Data Model– Logic Data Model

Page 23: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

23

Other Data ModelsOther Data Models• Object data model

– Usually find objects via explicit navigation, also query language in some systems

• Complex Objects – Nested Structure (pointers or references)

• Encapsulation, set of Methods/Access functions• Object Identity• Inheritance – Defining new classes like old classes

• Logic data model– Prolog, Datalog– More power than relational

Page 24: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

24

The DBMS MarketplaceThe DBMS Marketplace• Relational DBMS companies – Oracle, SybaseOracle, Sybase – are among the larg

est software companies in the world.• IBM offers its relational DB2DB2 system. With IMS, a nonrelational syst

em, IBM is by some accounts the largest DBMS vendor in the world.• Microsoft offers SQL-ServerSQL-Server, plus Microsoft AccessMicrosoft Access for the cheap D

BMS on the desktop, answered by “lite” systems from other competitors.

• Relational companies also challenged by “object-oriented DB” companies.

• But countered with “object-relational” systems, which retain the relational core while allowing type extension as in OO systems.

Page 25: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

25

1.2 Architecture of DBMS1.2 Architecture of DBMS• Major components of a DBMS

DataMetadata

Storage Manager

Query Processor

TransactionManager

SchemaModifications

Queries Modifications

Schema (logical structure of the data); Metadata(data of data)

Page 26: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

26

Architecture of DBSArchitecture of DBSThree Schema Architecture of DBS• External Schema: user schema or subschema

– Defines one view of the data as seen by a specific set of application or end users.

– There may be many external schemas in a DB.

• Schema: conceptual schema, logical schema– Defines data from perspective systems designer; – Independent of end users & data storage mechanism– There is only one conceptual schema in a DB.

• Internal Schema: storage schema– Defines how data is organized, stored and manipulated inside

the system.– Totally dependent on particular implementation.– There is only one internal schema in a DB.

Page 27: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

27

Three Schema Architecture (cont.)Three Schema Architecture (cont.)

Application

A

External Schema 1

Schema

Internal Schema

DB

Application

B

Application

D

Application

E

Application

C

External Schema 2

External Schema 3

Page 28: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

28

Independence of Data and ProgramIndependence of Data and Program• Logical Independence

– Via Reflection of External Schema/Schema– One Schema corresponds to many External schemas;

every Ex-Schema has an Ex-Schema/Schema Reflection.

– When Schema changes, DBA changes the Ex-Schema/Schema reflections, so application programs needn’t been changed.

• Physical Independence– Via Reflection of Schema/Internal Schema– Schema/Internal Schema Reflection is unique.– When Internal Schema changes, DBA changes the S

chema/ Internal Schema Reflection, so application programs needn’t been changed.

Page 29: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

29

各种人员的数据视图各种人员的数据视图

数据表示 应用系统

外模式

模式

内模式

DB

DBMS

OS

用户

应用程序员

DBA,

系统分析员

数据抽象级别 软件系统层次

Page 30: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

30

Three Aspects to Studying DBMS'sThree Aspects to Studying DBMS's

• Modeling and design of databases.– Allows exploration of issues before committing

to an implementation.

• Programming– SQL: queries and DB operations like update.– Host language and Embedded SQL

• DBMS implementation

Page 31: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

31

Host Languages Host Languages • Host language is completely general (Turing complet

e) but gives you no support.• Query language—less general, "non procedural" and

optimizable.

(Storage)

C, C++, Fortran, Java, Delphi, VB etc.

Application program

Local Vars

DBMSCalls to DB

(Memory)

Page 32: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

32

Reading GuideReading Guide

• A First Course in Database Systems: – Required: 1.1– Recommended: 1.2, 1.5

• 数据库系统概论– 推荐:第一章

Page 33: An Introduction to Database System College of Computer Science and Technology Chongqing University of Posts & Telecom. Spring, 2006.

33

ExercisesExercises

• (Required, in English) Explain the following notions and give an example to show them clearly.– DB, DBMS, DBS

以下选做:• (推荐作业,中文完成 ) 逻辑独立性和物理独立性是什么含义?在数据库系统架构中是如何保证这两个独立性的?

• ( 建议作业,中文完成 ) 对数据库技术发展趋势、主流数据库产品、流行数据库开发和设计技术进行调研,撰写小论文,和同学分组讨论。

http://www.google.com