View
219
Download
0
Category
Preview:
Citation preview
Database System Concepts
Computer science and technology department
Liping Zhang
E-mail: Carolyn321@163.com
Textbook :
Book name: Database System Concepts,Fourth Edition
Author: Abraham Silberschatz,Henry E Korth,S.Sudarshan
Press: China Machine Press
References book :
Book name: An Introduction to Database Systems
Author: C. J.Date
Press: China Machine Press Book name: A First Course in Database Systems
Author: Jeffrey D.ullman Jennifer Widom
Press: China Machine Press
References book :
Book name : 数据库系统概念(第三版) Author : 萨师煊 王珊 Press: Higher Education Press
Book name : 数据库系统教程 Author : 王能斌 Press: Electronics industry
Book name : 数据库系统基础 Author : 冯玉才 Press: 华中科技大学
Database system concepts
Teaching outline: 1. in the classroom Chapter 1 Introduction Chapter 2 Entity-Relationship Model Chapter 3 Relational Model Chapter 4 SQL Chapter 5 Integrity and Security Chapter 6 Relational-Database Design Chapter 7 Query Optimization Chapter 8 Transactions Chapter 9 Concurrency Control Chapter 10 Recovery System
2.practice in the laboratory Requirement:
1.preparation
2.review
3.learn by yourself
Delphi7.0
SQLServer2000 Scores:
70%+30%
absence -3
Chapter 1 introduction
1.1 What is a database system? 1.2 What is a database? 1.3 Purpose of database systems. 1.4 Database languages 1.5 The three levels of the
architecture
1.5.1 The three levels
1.5.2 Mappings
1.5.3 Instances and schemas
1.6 Transaction management 1.7 The Database Management
System 1.8 Application Architectures 1.9 Distributed processing
Banking:accounts, loans,baking transactions. Airlines: reservations ,schedule information. Universities:, student information,course registration, grades. Credit card transactions: purchases on credit cards, generation
of monthly statements. Telecommunication: keeping records of calls made. Finance Sales:customer,product,purchase information. Manufacturing:management of supply chain. Human resources:employees,salaries.
1.1 What is a database system?
1.1 What is a database system?
A database system is basically a computerized record-keeping system; i.e.,it is a computerized system whose overall purpose is to store information and to allow users to retrieve and update that information on demand.
A database system involves four major components:
data hardware software users
DBS=DB+DBMS+APPLICATION+DBA+USER
employee
enrollment
1.Data
The data in the database—at least in a large system—will be
both integrated and shared.
name address department salary …
name course …
Example:
department
employee Personnel Department
Education Department
Use the employee information for different purpose
?
1.Data
By integrated: we mean that the database can be thought of as a unification of several otherwise distinct files, with any redundancy among those files at least partly eliminated.
By shared: we mean that individual pieces of data in the database can be shared among different users, in the sense that each of those users can have access to the same piece of data, possibly for different purpose.
2.Hardware
The hardware components of the system consist of:
1.The secondary storage volumes, device controllers, I/o channels, and so forth;and
2.The hardware processor(s) and associated main memory
3.Software
Between the physical database itself—i.e.,
the data as physically stored—and the users
of the system is a layer of software, know
variously as the database manger or
database server or, most commonly,
the database management system(DBMS).
DBMS
DATABASE
OS
AS
…USER USER
All requests for access to the database are handled by the DBMS. One general function provided by the DBMS is thus the shielding of database users from hardware—level details.
4.Users
① Application programmers: responsible writing database application programs in some programming language.
② End users: end users interact with the system from online workstations or terminals.
③ Database administrator(DBA): Schema definition storage Structure and access-method definition Schema and physical-organization modification Granting of authorization for data access Routine maintenance
1.2 What is a database
It is customary to refer to the data in a database as “persistent”. We say that data in the database “persists” because, once it has been accepted by the DBMS for entry into the database in the first place, it can subsequently be removed from the database only by some explicit request to the DBMS,not as a mere side effect of some program completing execution.
A database is a collection of persistent data that is used by the application systems of some given enterprise.
1.3 Purpose of database system
Keeping organizational information in a file—processing system has a number of major disadvantages.
1. Data redundancy and inconsistency
2. Difficulty in accessing data
3. Data isolation
4. Integrity problems
5. Atomicity problems
6. Concurrent—access anomalies
7. Security problems
Data are scattered in various files&files may be in different formats
Consistency constraintsExample:balance of bank>=$25
1. Data redundancy and inconsistency
name address department salaryHayes Round Hidd Account 500
Johnson Perryridge Account 780
Smith Perryridge Loan 1200
name course departmentHayes OS Account
Johnson DB Account
Smith DS Loan
LoanHayes
Loan
Hayes
Account
?
employee
enrollment
inconsistency
2. Difficulty in accessing data
Requirement:
Find out the names of all customers who live within wuhan.(the list of all customers)
resolvesExtract the needed information form the list of all customers
Write a new necessary application program
Find out the names of all customers who live within wuhan and have an account balance of $1000 or more.
5. Atomicity problems
Account A
$500
Account B
$100
$50x
$50 $50$50$50
$50$50$50
$500-$50=$450 $100$50?
(1)
(2)
$50
6. Concurrent—access anomalies
Husband $100Account A $500
Wife $50Read $500
$500-$50=$450
Write $450
Read $500
$500-$100=$400
Write $400
$400 / $450 XRead $450
$450-$100=$350
Write $350
Read $400
$400-$50=$350
Write $350
1.3 Purpose of database system
Benefits of the database approach:
2. Redundancy can be reduced
3. Inconsistency can be avoided (to some extent)
4. Transaction support can be provided.
5. Integrity can be maintained6. Security can be enforced
7. Conflicting requirements can be balanced
8. Standards can be enforced
1. The data can be shared
1.4 Database languages
A database system provides two different types of languages: one to specify the database schema, and the other to express database queries and updates.
Data-Definition Language Data-Manipulation Language
Database Language
Procedural DMLs Declarative DMLs
1.5.1 The three levels
The internal level is the one closes to physical storage.
it is consists of many occurrences of each of many types of internal record.(internal schema)
The external level is the one closest to the users. it is consists of many occurrences of each of many types of external record. ( external schema)
The conceptual level is a level of indirection between the other two. it is consists of many occurrences of each of many types of conceptual record.(conceptual schema)
The ANSI/SPARC architecture is divided into three levels— internal, conceptual, and external
1.5.1 The three levels
External level
(individual user views)
Conceptual level
(community user views)
Internal level
(storage views)
Fig 1.1 The three levels of the architecture
Internal Schema
Conceptual Schema
External schema
External schema
External schema
1.5.1 The three levels
Example:
External(PL/I)
Conceptual
Internal
External(COBOL)DCL 1 EMPP,
2 EMP# CHAR(6),
2 SAL FIXED BIN(31);
01 EMPC.
02 EMPNO PIC X(6).
02 DEPTNO PIC X(4).
EMPLOYEE
EMPLOYEE NUMBER CHARACTER (6)
DEPARTMENT_NUMBER CHARACTER (4)
SALARY
STORED EMP BYTES=20
PREFIX TYPE=BYTE(6), OFFSET=0
EMP# TYPE=BYTE(6), OFFSET=6, INDEX=EMPX
DEPT# TYPE=BYTE(4), OFFSET=12
PAY TYPE=FULLWORD, OFFSET=16
1.5.1 The three levels
Fig 1.2 Detailed system architecture
1.5.2 Mappings
conceptual/internal mapping and several external/conceptual mappings :
1.the conceptual/internal mapping defines the correspondence between the conceptual view and the stored database; it specifies how conceptual records and fields are represented and the internal level.
2.an external/conceptual mapping defines the correspondence between a particular external view and the conceptual view.
1.5.2 Mappings
Internal Schema
Conceptual Schema
External schema
External schema
External schema
conceptual/internal mapping
external/conceptual
1.5.2 Mappings
Data independence:
1.physical data independence is the ability to modify the physical schema without causing application programs to be rewritten. (conceptual/internal mapping)
2.logical data independence is the ability to modify the logical schema without causing application programs to be rewritten. (external/conceptual)
1.5.3 Instances and schemas
The overall design of the database is called the database schema.
The collection of information stored in the database at a particular moment is called an instance of the database.
database schema instance of the database int i i=2
sn name sex
01 carol female
03 bob malestudent
Student={sn,name,sex}
1.6 Transaction Management
A transaction is a collection of operations that performs a single logical function in a database application.
Each transaction is a unit of both atomicity and consistency.
Atomicity Consistency Isolation Durability (ACID)
1.7 The Database Management System
DBMS is the software that handles all access to the database.1.A user issues an access request, using some particular data sublanguage (SQL)
2.The DBMS intercepts that request and analyzes it
3.The DBMS inspects, in turn, the external schema for that user, the corresponding external/conceptual mapping, the conceptual schema,the conceptual/internal mapping,and the storage structure definition. 4.The DBMS execute the necessary operations on the stored database.
1.7 The Database Management System
The functions of the DBMS :Data definition
Data manipulation
Optimization and execution
Data security and integrity
Data recovery and concurrency
Data dictionary
Performance
Fig 1.3 major DBMS functions and components
1.8 Application Architectures
A database system can be regarded as having a very simple two-part structure consisting of a server and a set of clients. The server is just the DBMS itself. The clients are various applications that run on top of the DBMS.
1.9 Distributed processing
Distributed processing means that distinct machines can be connected together into a communication network such as internet ,such that a single data-processing task can span several machines in the network.
Exercises:
1.Explain the following terms:
DBMS Data inconsistency Data view Data instance
Database schema Physical schema Logical schema
Physical data independence Logical data independence
2. P23 : 1.1 1.3 1.5 1.8
Recommended