Sie sind auf Seite 1von 35

Unit 1

Introduction to DBMS
(Database Management Systems)

Application
program End-user
DBMS 1-1
Outline of Unit 1

1.1 Information Systems


1.2 An Overview of a Database System
1.3 An Architecture for a Database System
1.4 Database Technology Trends

Wei-Pang Yang, Information Management, NDHU 1-2


1.1 Information Systems

1-3
Stages of Information System
 Stage 0: Manual Information System
• Records
• Files
• Index Cards
 Stage 1: Sequential Information Systems
• Tapes
• Files
• slow, non-interactive, redundancy,... .
 Stage 2: File Based Information Systems
• Disk (direct access)
• application program has its own file data dependence
• data redundancy
 Stage 3: DBMS based Information Systems
• Generalized data management software
• Transaction processing

Wei-Pang Yang, Information Management, NDHU 1-4


File Based Information Systems
 Conventional Data Processing techniques:
Enterprise:

Application Application
Program A
File System A Customer
System A

Application
Application File System B Invoice
Program B
System B

Application Application
System N Program N File System N Inventory

Wei-Pang Yang, Information Management, NDHU 1-5


File Based Information Systems (cont.)

Customer Invoice
Customer No. Customer No.
Customer Name Customer Name
Part No.
Customer Addr.
Quantities
Social Security ID Unit Price

Inventory
Parts
Part No.
Part Description Part No.
Unit Price Part Description
Supplier Supplier
Quantities Remain Quantities Ordered
Quantities Ordered Customer Name
Unit Price

Wei-Pang Yang, Information Management, NDHU 1-6


User A1 User A2 User B1 User B2 User B3
Host Host Host Host Host C, Pascal
Language Language Language Language Language
+ DSL + DSL + DSL + DSL + DSL
DSL (Data Sub Language)
e.g. SQL
1 2 3
External View External
schema
External
schema
External View
@ # & A B B

External/conceptual External/conceptual
mapping A mapping B

Database
Conceptual Conceptual management
< schema
View system dictionary
(DBMS) e.g. system
catalog

DBA Conceptual/internal
(Build and mapping
maintain
schemas
and
mappings) Storage
structure 1 2 3 ... 100
definition
(Internal Stored database (Internal View) # & @
schema)

Wei-Pang Yang, Information Management, NDHU 1-7


DBMS based Information Systems:
Basic Approach - Integration
 (1) Integration of Information
• Description of the integrated view of data is the "Conceptual
Schema" of the database
DBMS

Application
program
End-user
Wei-Pang Yang, Information Management, NDHU 1-8
DBMS based Information Systems:
Basic Approach – Simple views and High level language
 (2) Provide simple views (External Schema) and high level language (e.g.
SQL) for users to manipulate (handle) data
• High level language: e.g. SQL (Structured Query Language)
<e.g.>: SELECT SNAME
FROM S
WHERE S#= 'S4';

• Description of user's view of data is the "external schema" or


"subschema" or "view".
• High-level languages (Query Language): SQL
(1) Data Definition Language:
define format
(2) Data Manipulation Language:
retrieve, insert, delete, update S

• Emphasize: EASE OF USE !! S# name

Wei-Pang Yang, Information Management, NDHU 1-9


DBMS based Information Systems:
Basic Approach - Storage/Access Method
 (3) Efficient Storage/Access Techniques:
• implemented once rather than duplicated in all application
programs.

User: query in SQL

Language Processor
DBMS Access Methods Calls
Access Method
(B+ tree, Dynamic Hashing)

I/O calls

Wei-Pang Yang, Information Management, NDHU 1-10


DBMS based Information Systems:
Basic Approach - Transaction Management

 (4) Provide Transaction Management:


• Concurrency Control
• Recovery
• Security
• .
:

Wei-Pang Yang, Information Management, NDHU 1-11


Example: A Simple Query Processing
Query in SQL:
SELECT CUSTOMER. NAME
DBMS
FROM CUSTOMER, INVOICE
WHERE REGION = 'N.Y.' AND
AMOUNT > 10000 AND
Language Processor
CUTOMER.C#=INVOICE.C
Internal Form :

( (S SP) Optimizer Language


Operator :
Processor
SCAN C using region index, create C
SCAN I using amount index, create I
SORT C?and I?on C#
JOIN C?and I?on C#
EXTRACT name field

Operator Processor
Calls to Access Method:
OPEN SCAN on C with region index
GET next tuple
.
.
.
Access Method
Calls to file system: e.g.B-tree; Index; Access
GET10th to 25th bytes from Hashing Method
block #6 of file #5

File System

Wei-Pang Yang, Information Management, NDHU 1-12


database
1.2 An Overview of a
Database System

1-13
An Example
 The Wine Cellar Database:
Cellar:
Bin Wine Producer Year Bottle Ready Comments
2 Chardonnay Buena Vista 83 1 85
3 Chardonnay Louis Martini 81 5 84
6 Chardonnay Chappellet 82 4 85 Thanksgiving
12 Jo. Riesling Buena Vista 82 1 83 Late Harvest
16 Jo. Riesling Sattui 82 1 83 Very dry
43 Cab. Sauvignon Robt. Mondavi 77 12 87
50 Pinot Noir Mirassou 77 3 85 Harvest
51 Pinot Noir Ch. St. Jean 78 2 86

 Retrieval:
• DML (Data Manipulation Language):
SELECT Wine, Bin, Producer
FROM Cellar
WHERE Ready = 85;
• Result: Wine Bin Producer
Chardonnay 2 Buena Vista
Chardonnay 6 Chappellet
Pinot Noir 50 Mirassou

Wei-Pang Yang, Information Management, NDHU 1-14


An Example (cont.)
 Deletion:
• DML: DELETE FROM Cellar
WHERE Ready < 86;
• Result:
Bin Wine Producer Year Bottle Ready Comments

43 Cab. Sauvignon Robt. Mondavi 77 12 87


51 Pinot Noir Ch. St. Jean 78 2 86

 Insertion:
• DML: INSERT INTO Cellar
VALUES (53, 'Pinot Noir', 'Franciscan', 79, 1, 86, 'for Joan');
• Result: Bin Wine Producer Year Bottle Ready Comments

43 Cab. Sauvignon Robt. Mondavi 77 12 87


51 Pinot Noir Ch. St. Jean 78 2 86
53 Pinot Noir Franciscan 79 1 86 for Joan

Wei-Pang Yang, Information Management, NDHU 1-15


An Example (cont.)
 Update
• DML: UPDATE Cellar
SET Bottles = 4
WHERE Bin = 51;
• Result:

Bin Wine Producer Year Bottle Ready Comments

43 Cab. Sauvignon Robt. Mondavi 77 12 87


51 Pinot Noir Ch. St. Jean 78 4 86
53 Pinot Noir Franciscan 79 1 86 for Joan

Wei-Pang Yang, Information Management, NDHU 1-16


What is a Database System?
DBMS

Application
program
End-user
Wei-Pang Yang, Information Management, NDHU 1-17
What is a Database System? (cont.)
 Major components of a database system:
• Data: integrated and shared.
• Hardware: disk, CPU, Main Memory, ...
• Software: DBMS
• Users:
1. Application programmers
2. End users
3. Database administrator (DBA)
• Defining external schema
• Defining conceptual schema
• Defining internal schema
• Liaison with users
• Defining security and integrity checks
• Defining backup and recovery procedures
• Monitoring performance and changing requirements

Wei-Pang Yang, Information Management, NDHU 1-18


Why Database ?
 Redundancy can be reduced
 Inconsistency can be avoided
 The data can be shared
 Standards can be enforced
 Security restrictions can be applied
 Integrity can be maintained
 Provision of data independence

objective !

Wei-Pang Yang, Information Management, NDHU 1-19


Data Independence
 Application Program
 Data Structure
 Immunity of application to change in
storage structure and access strategy.

Wei-Pang Yang, Information Management, NDHU 1-20


Data Dependence vs. Data Independence
S
 Data Dependent
S#
e.g. SELECT CITY S1
FROM S
WHERE ITEM = 'X'; S2

• Linked list: TOP Sn

S s1 s2 sn
Top if item = TOP . item then .........
• Tree:
.

if item < root.data then root := root .left ..........

• Array:
if A[I] = item then ............

• Storage structure changed  program changed


Wei-Pang Yang, Information Management, NDHU 1-21
1.3 An Architecture for a
Database System

1-22
User A1 User A2 User B1 User B2 User B3
Host Host Host Host Host
Language Language Language Language Language
+ DSL + DSL + DSL + DSL + DSL
(Data Sub Language)
e.g. SQL, QUEL

External View External External External View


schema schema
@ #A & A B B

External/conceptual External/conceptual
mapping A mapping B

Database
Conceptual Conceptual management
< schema @ View#A & system
(DBMS)

DBA Conceptual/internal
(Build and mapping
maintain
schemas
and
mappings) Storage
structure
definition
(Internal Stored database (Internal View) # & @
schema)

Wei-Pang Yang, Information Management, NDHU 1-23


An Example of the Three Levels
 Internal level:
STORED_EMP length = 18
PREFIX TYPE = BYTE(6), OFFSET = 0, INDEX = EMPX
EMP# TYPE = BYTE(6), OFFSET=0,
DEPT# TYPE = BYTE(4), OFFSET = 12
PAY TYPE = FULLWORD, OFFSET = 16

 Conceptual level:
EMPLOYEE
EMPLOYEE_NUMBER CHARACTER(6)
DEPARTMENT_NUMBER CHARACTER(4)
SALARY NUMERIC(5)

 External level:
• ( PL /I )
DCL 1 EMP
2 EMP# CHAR(6)
2 SAL FIXED BIN(31)
• (COBOL)
01 EMPC
02 EMPNO PIC X(4)
02 DEPTNO PIC X(4)

Wei-Pang Yang, Information Management, NDHU 1-24


Functions of the DBMS
 Data Definition Language (DDL)
 Data Manipulation Language (DML)
 Data Security and Integrity
 Data Recovery and Concurrency
 Data Dictionary
 Performance

Wei-Pang Yang, Information Management, NDHU 1-25


1.4 Database Technology Trends
1960s to 1970s to Late Future
Mid-1970s Mid-1980s 1980s
Merging data models,
Semantic knowledge representation,
Network Relational
Data Model Object-oriented and programming
Hierarchical
Logic languages
Mainframes Faster PCs
Database Mainframes Minis Workstations Parallel processing
Hardware PCs Database machines Optical memories

Query Graphics
User None languages Natural language
Forms Menus
Interface - SQL, QUEL Speech input
Query-by-forms

Program Embedded Integrated database


Procedural 4GL
query and programming
Interface language
Logic programming
language
Report Business graphics Generalized display
Presentation Reports generators Image output managers
and display Processing Information Knowledge Distributed knowledge
data and transaction processing processing
processing
processing

Wei-Pang Yang, Information Management, NDHU 1-26


Distributed Databases
Database Distributed System

 Distributed database is a database that is not stored


in its entirety at a single physical location, but
rather is spread across a network of computer.
< e.g.>
Hsinchu
computers

Taipei

communication Kaoshiung
links
Taichung

Wei-Pang Yang, Information Management, NDHU 1-27


Distributed Databases (cont.)
 Advantages:
 efficiency of local processing
 data sharing
 Disadvantages:
 communication overhead
 implementation difficulties
 Reference:
S. Ceri and G. Pelagatti
"Distributed Databases: principles and systems"

Wei-Pang Yang, Information Management, NDHU 1-28


Multi-Database/Heterogeneous Database

Multidatabase

IMS INGRES .. . ORION

Relational Object-
Hierarchical
Model Oriented
Model
Model
• semantic inconsistency
• data incompleteness
• global schema

Wei-Pang Yang, Information Management, NDHU 1-29


DB + AI Database AI

Query DBMS

Language Processor
Query Optimizer Knowledge
Base

Operator Processor
Access Method
File Manager

Distributed Logical
DB design DB design

Knowledge Knowledge
Base Base

Wei-Pang Yang, Information Management, NDHU 1-30


KBMS Database Logic

 A Combined Model :
Logic Programming + Relational DB
 Three layers : User Program Query :
? :- ancestor (taro, Y)
? :- grandfather (?, c)
Knowledge
management IDB:
program ancestor(X,Y):- parent(X,Y)
IDB
ancestor(X,Y) :- parent(X,Z), ancestor(Z,Y)
parent(X,Y):-edb(father(X,Y))
relational parent(X,Y):-edb(mother(X,Y))
interface grandfather(X,Z):- father(X,Y) ^ father(Y,Z)
fathe mother
EDB: r
Relational DB father son
A B
management X Y
program EDB . . . .
B C

Wei-Pang Yang, Information Management, NDHU 1-31


Database Object-Oriented
OODB
 A typical Document : MEMO [Woelk86, SIGMOD] speaker
MCC voice message
associated
To: W. Kim
From: D. Woolk
Date: September 18, 1992 can be heard
Subject: Workstations

In the computer center of National Chiao-Tung University, there are


a lot of workstations. There are HP RS serials, SUNs, Apollo, and so
on. The students in NCTU learn to use workstation since they are fresh-
men. The configuration of the workstations follows:
} text

Workstation . . .

Database
Server
Workstation

In the course introduction to Computer Science? students do their


} graphics

homework's on workstations.

} image

Wei-Pang Yang, Information Management, NDHU 1-32


Use of a Database Management System in
Design and Application
Design
Detailed
Release
Design
Database Manufacturing Control
Fabrication
Analysis Assembly
Models Info

DBMS
Preliminary- Database Management Test /
design Inspection
System

INTERFACE Graphic Interface Language Interface

APPLICATION
Design Design
Evaluation Synthesis Release
Analysis Verification

Manufacturing Production Project


Planning Control Management

Wei-Pang Yang, Information Management, NDHU 1-33


Database Fuzzy Set Theory
Fuzzy Database
 Fuzzy Query
<e.g.> SELECT STUDENT.NAME
FROM STUDENT
WHERE SEX = M
AND HEIGH = TALLER
AND WEIGH = SLIMMER
STUDENT:
NAME SEX HEIGHT WEIGHT IQ

Mary F 158 55 High


Linda F 165 55 Medium
. . . . .
. . . . .
. . . . .

<e.g.> SELECT STUDENT.NAME


FROM STUDENT
WHERE IQ >= 130

Wei-Pang Yang, Information Management, NDHU 1-34


More?
DB AI DB 911/ Anthrax
1993 ? ?
2001

DB VR
DB DNA/BioInfo
1995 ? 2003 .
?

DB WWW DB ??? SARS


1997 ? 2004 ?

DB Mobile/video DB ???
1999
2006 ?
?

Wei-Pang Yang, Information Management, NDHU 1-35