Chapter 1 - Introduction
Chapter 1 - Introduction
Introduction
COMP3278
Introduction to Database Management Systems
2
Section 1.1
Getting started
Banking
DBMS
5
Database applications
Many daily applications involve databases.
Banking
Account … DBMS
Transactions
balance …etc.
6
Database applications
Many daily applications involve databases.
Banking
Airline
Customer
DBMS
Booking …etc.
record
7
Database applications
Many daily applications involve databases.
Banking
Airlines
Universities
Student
Emails
records
Banking
Airlines
Universities
Social network Application
program
Online maps
An information system can consists of the
data layer and the application layer.
DBMS
Locations Roads Images
9
Database applications
Many daily applications involve databases.
Banking
Airlines
Universities
Social network Application
program
Online maps Customer
information
Smart card systems
Balance
One database may support
many different applications DBMS
simultaneously. Transactions
10
File system v.s. DBMS
In the early days, application programs were built
on top of file systems. (e.g., DOS, Windows file
explorer)
So that I don’t need to spend
Why don’t we simply use a file resources (e.g., $$$) on
system to manage our data? maintaining a database/
hiring a database
administrator…
Boss, let us use a
database to organize
our data ☺!
11
File system v.s. DBMS
6 drawbacks of storing DB in file systems:
1. Difficulty in accessing data - May be inefficient to
locate a piece of information.
Chui Chun Kit; 60123456; CB320, HKU, records in a text file, I need to
Pokfulam Rd; account balance : $100
scan the file once to retrieve any
Jolly; 91234567; CYC 311; HKU,
Pokfulam Rd; account balance: $2,000 particular record.
Yvonne; 31234567; CB 415, HKU,
Pokfulam Rd; account balance: $1,000
Savings-account records 12
File system v.s. DBMS
6 drawbacks of storing DB in file systems:
2. Data redundancy and inconsistency - Data got
updated in one place but forget to update the other
one.
…
…
Contact
Chui Chun Kit; 60123456; CB320, HKU, Ben/ account balance: $100,000/ CYC
Pokfulam Rd; account balance : $100 314, HKU, Pokfulam Rd/ 21234567/ information
Chui Chun Kit/ account balance: $4,000/
duplicated among
Jolly; 91234567; CYC 311; HKU,
Pokfulam Rd; account balance: $2,000 CB320, The University of Hong Kong, different files!
Pokfulam Rd, Hong Kong/ 60123456/
Yvonne; 31234567; CB 415, HKU,
Pokfulam Rd; account balance: $1,000 Kevin/ account balance $20,000/ 2nd
Floor … Central/ 62234567/
…
separate fields while
Chui Chun Kit; 60123456; CB320, HKU, Ben/ account balance: $100,000/ CYC the other uses “/”,
Pokfulam Rd; account balance : $100 314, HKU, Pokfulam Rd/ 21234567/
also, the fields are in
Jolly; 91234567; CYC 311; HKU, Chui Chun Kit/ account balance: $4,000/ different orders!
Pokfulam Rd; account balance: $2,000 CB320, The University of Hong Kong,
Pokfulam Rd, Hong Kong/ 60123456/
Yvonne; 31234567; CB 415, HKU,
Pokfulam Rd; account balance: $1,000 Kevin/ account balance $20,000/ 2nd
Floor … Central/ 62234567/
…
if the system crashes
Chui Chun Kit; 60123456; CB320, HKU, Ben/ account balance: $100,000/ CYC right after money is
Pokfulam Rd; account balance : $100 314, HKU, Pokfulam Rd/ 21234567/
deducted but not
Jolly; 91234567; CYC 311; HKU, Chui Chun Kit/ account balance: $4,000/ deposited?
Pokfulam Rd; account balance: $2,000 CB320, The University of Hong Kong,
Pokfulam Rd, Hong Kong/ 60123456/
Yvonne; 31234567; CB 415, HKU,
Pokfulam Rd; account balance: $1,000 Kevin/ account balance $20,000/ 2nd
Floor … Central/ 62234567/
18
Database Management System
A good DBMS aims at handling all problems related
to large DB management.
DBMS provides an environment that is both
convenient and efficient to use.
Three powerful concepts supported by a DBMS:
1. Data abstraction.
2. Data modeling.
3. Database languages.
19
1. Data abstraction
Three levels of data abstraction.
1. Physical level
Describes HOW the data are
actually stored.
Describes complex low-level data
structures in detail.
E.g., Whether the actual data are
compressed or not? With what data
compression scheme?
Physical level
20
1. Data abstraction
Three levels of data abstraction.
2. Logical level
Describes WHAT data are stored.
Describes the relationship among data.
Physical data independence
Logical level
Adding an index to speed up the access won’t
affect the data stored in the database.
Compressing the data in the physical level also won’t
affect application programs or user interfaces.
22
1. Data abstraction
Important concept of Schema and Instance
A Schema describes the structure of the database.
An Instance is the actual content of the database at a
particular time.
customer {
Schema and string customer_name;
instance are analog string customer_address;
to type and value in Logical level
}
programming.
A schema of customer
address
customer Name Address Account balance
account_ Kit HKU… $100
balance Ben … $2,000
The data model The data instance 24
2. Data modeling
Data modeling is used to describe data in a
systematic way. A customer can have more
than one account!!!
name
address
customer Name Address Account balance
account_ Kit HKU… $100
balance Kit … $2,000
The data model The data instance 25
2. Data modeling
Data modeling is used to describe data in a
systematic way. A customer can have more
than one account!!!
address
customer Account ID Name Address Account balance
account_ 1 Kit HKU… $100
balance 2 Kit HKU… $2,000
account_id name
Data redundancy
address
customer Account ID Name Address Account balance
account_ 1 Kit HKU… $100
balance 2 Kit HKU… $2,000
29
2. Data modeling
Data modeling is used to describe data in a
systematic way. An extra information is needed to
represent the relationship of the
customers with the accounts, then one
Customer ID Account ID customer can have more than one
1 1 account, and the customer info will not be
1 2 duplicated ☺!
owner
Customer ID Name Address Account ID Balance
1 Kit HKU… 1 $100
2 … … 2 $2,000
customer account account_
customer_id balance
The database
creates the
Customer table
accordingly
I want to CREATE a database table called
“Customers” with attributes “Customer
ID”, “Name” and “Address”.
33
3. Database languages
DBMS provide different tools for managing data.
Data definition language (DDL)
Data manipulation language (DML)
CID Name Address
1 Ben HKU…
DML DBMS 10 Kit HKU…
12 Jolly …
10 Kit HKU…
Database
Overview
Query processer
Storage manager
Disk storage
36
Storage manager
A program module in DBMS that provides interface
between the low-level data and the application
programs/queries.
Query processer
Consists of
File manager
Transaction manager Storage manager
Authorization
Authorization and File
manager
Transaction
manager
and integrity
Buffer
manager
manager
integrity manager
Buffer manager Disk storage
37
File manager
Manages the allocation of space on disk storage and
the data structures used to represent information
stored on disk.
Query processer
Storage manager
Authorization
File Transaction Buffer
and integrity
manager manager manager
manager
Disk storage
38
Transaction manager
Ensures that the database remains in a consistent
(correct) state despite system failures.
Query processer
Ensures interaction
among all concurrent
transactions does not
make the DB Storage manager
Disk storage
39
Authorization and integrity manager
Storage manager
Authorization
File Transaction Buffer
and integrity
manager manager manager
manager
Disk storage
40
Buffer manager
Responsible for fetching data from disk storage into
main memory.
cache in main
memory.
Storage manager
Authorization
File Transaction Buffer
and integrity
manager manager manager
manager
Disk storage
41
Disk storage
Disk storage consists of
Data files – stores the
database itself. Query processer
Data dictionary –
stores metadata about
the structure of the
Storage manager
database, in particular
the schema of the File Transaction
Authorization
and integrity
Buffer
manager manager manager
database. manager
42
Query processer
A program module in DBMS that converts high-level
user requests to efficient low-level commands to
DB.
Query processer
Consists of DDL DML
Query
evaluation
interpreter compiler
engine
DDL interpreter
DML compiler Storage manager
Authorization
Query evaluation engine File
manager
Transaction
manager
and integrity
Buffer
manager
manager
Disk storage
Data
Data files Indices
dictionary
43
DDL interpreter
Interprets DDL statements and records the
definition in the data dictionary
Query processer
Query
DDL DML
evaluation
interpreter compiler
engine
Storage manager
Authorization
File Transaction Buffer
and integrity
manager manager manager
manager
Disk storage
Data
Data files Indices
dictionary
44
DML compiler
Translates DML statements in a query language into
an evaluation plan.
Query processer
Evaluation plan - low-
level instructions that the DDL DML
Query
evaluation
interpreter compiler
query evaluation engine engine
understand.
Storage manager
Query optimization – Authorization
File Transaction Buffer
Picks the lowest cost manager manager
and integrity
manager
manager
45
Query evaluation engine
Executes low-level instructions generated by the
DML compiler.
Query processer
Query
DDL DML
evaluation
interpreter compiler
engine
Storage manager
Authorization
File Transaction Buffer
and integrity
manager manager manager
manager
Disk storage
Data
Data files Indices
dictionary
46
Database Administrator
Duties of DBA
Schema definition.
Storage structure and access method
definition (e.g., hash table or B+ tree?)
Granting user authority to access the database.
Monitoring performance and responding to changes
in requirements.
An important and well-paid job.
[Link]
47
Summary
Simple file systems are inadequate for enterprise
needs – the 6 drawbacks.
48
Chapter 1.
END
COMP3278 Introduction to
Database Management Systems