0% found this document useful (0 votes)
23 views45 pages

CH 2 Database Systems

The document discusses the advantages of database management systems (DBMS) over traditional file processing systems, highlighting issues such as data redundancy, program-data dependence, and lengthy development times. It outlines the functions and components of a DBMS, including data storage, concurrency control, security, and integrity services, as well as the ANSI-SPARC three-level architecture which provides data independence. Additionally, it covers various multi-user DBMS architectures, including client-server and distributed systems.

Uploaded by

ngyx-wp22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views45 pages

CH 2 Database Systems

The document discusses the advantages of database management systems (DBMS) over traditional file processing systems, highlighting issues such as data redundancy, program-data dependence, and lengthy development times. It outlines the functions and components of a DBMS, including data storage, concurrency control, security, and integrity services, as well as the ANSI-SPARC three-level architecture which provides data independence. Additionally, it covers various multi-user DBMS architectures, including client-server and distributed systems.

Uploaded by

ngyx-wp22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 45

BACS3183

Advanced Database Management


Chapter 2
Database Systems

1
Learning Outcomes

• Explain the characteristics that distinguish the


database approach from the traditional approach of
programming with data files.
• Describe the basic functions and components of a
DBMS
• Discuss the ANSC-SPARC Three-level architecture
• Describe the meaning of logical and physical data
independence
• Differentiate among the various DBMS architectures

2
1. Disadvantages of File Processing
(Traditional Approach)
• Program-Data Dependence (See slide 5)
– All programs maintain metadata for each file they use
• Data Redundancy (Duplication of data) (See slide 6)
– Different systems/programs have separate copies of the same
data
• Limited Data Sharing
– No centralized control of data
• Lengthy Development Times
– Programmers must design their own file formats
• Excessive Program Maintenance
– 80% of the information systems budget

3
Example : Three file processing systems
Duplicate
Data

Program-Data Dependence
Data Redundancy (duplication of data)
Limited Data Sharing
Lengthy Development Times
Excessive Program Maintenance 4
Problems with Data Dependency
 Each application programmer
must maintain their own data
 Each application program
needs to include code for the
metadata of each file
 Each application program
must have its own processing
routines for reading, inserting,
updating and deleting data
 Lack of coordination and
central control
 Non-standard file formats

5
Problems with Data Redundancy
• Waste of space to have duplicate data
• Causes more maintenance headaches
• The biggest Problem:
– When data changes in one file, could cause
inconsistencies
– Compromises data integrity

6
2. Database Management System (DBMS)
• A software system that enables users to define,
create, maintain, and control access to the database.

7
2.1 Functions of a DBMS
• Store, Update and Retrieve Data

• Concurrency Control Services.


 Multiple users make updates to the database
simultaneously, ensure updates are made
correctly and the end result is accurate.
 Solution:
 Locking & 2-phase locking,
 Time-stamping
 Versioning

8
Effect of no concurrency control
E.g. Two customers withdrawing funds from the same
account at the same time - account has $1000 in it, and they
withdraw $200 and $300.

9
9
Functions of a DBMS
•Backup and Recovery Services.
 Crash, fire, natural disaster
 So data not permanently lost

10
Functions of a DBMS
Security
 Prevent unauthorized users accessing the database.
 Encryption, authentication, authorization and views

11
Functions of a DBMS
• Integrity Services.
Avoid incorrect or inconsistent data by complying
a set of rules to ensure data integrity is enforced.
CREATE TABLE PropertyForRent(
propertyNo VARCHAR(5) NOT NULL,
rent NUMBER NOT NULL DEFAULT 600,
staffNo VARCHAR(5)
CONSTRAINT StaffNotHandlingTooMuch
CHECK (NOT EXISTS (SELECT staffNo
FROM PropertyForRent
GROUP BY staffNO
HAVING COUNT(*) > 100)),
PRIMARY KEY (propertyNo),
FOREIGN KEY (staffNo) REFERENCES Staff
12
Types Of Integrity Constraint In Oracle
• A NOT NULL constraint prohibits a database value from being null.
• A unique constraint prohibits multiple rows from having the same
value in the same column or combination of columns but allows
some values to be null.
• A primary key constraint combines a NOT NULL constraint and a
unique constraint in a single declaration.
• A foreign key constraint requires values in one table to match
values in another table.
• A check constraint requires a value in the database to comply with
a specified condition.
– CHECK (supplier_id BETWEEN 100 and 9999)
– CHECK (supplier_name IN ('IBM', 'Microsoft', 'NVIDIA')
– CHECK (status NOT IN ('A','B','C','D'));
13
CREATE TABLE OrderDetail (
OrderDetailKey VARCHAR(10) NOT NULL,
OrderKey VARCHAR(10),
ProductKey VARCHAR(10),
Quantity NUMBER(3) check (Quantity >=1),
PriceCharged NUMBER(6,2) check (PriceCharged > 0),
constraint OrderToOrddet unique (OrderKey, ProductKey),
Primary key (OrderDetailKey),
Foreign Key (OrderKey) references CustomerOrder(OrderKey),
Foreign Key (ProductKey) references Product (ProductKey)
);
14
14
• Transaction Support
 Ensure that all the updates are made or that none
of them is made.
Airline Transaction Example
1. BEGIN-TRANS
2. Display greeting
3. Get reservation preferences from user
4. SELECT departure and return flight records
5. If reservation is acceptable then
6. UPDATE seats remaining of departure flight record
7. UPDATE seats remaining of return flight record
8. INSERT reservation record
9. Print ticket if requested
10. End If
11. On Error: ROLLBACK 15
Functions of a DBMS
• A User-Accessible System Catalogue
(Data Dictionary Management).
• System Catalogue
• Repository of information (metadata) describing the data in
the database.
• One of the fundamental components of DBMS.
• Typically stores:
 names, types, and sizes of data items;
 constraints on the data;
 names of authorized users;
 data items accessible by a user and the type of access;
 usage statistics (eg counts on the number of accesses
made to objects in the database)
16
DBMS consults the
system catalog
before performing
almost every
action:
• Authorize users
• Process queries
• Check integrity
• etc

17
Sample Oracle Catalog Tables
Table Name Contents

USER_CATALOG Contains basic data about each table and view defined by
a user.
USER_OBJECTS Contains data about each object (functions, procedures,
indexes, triggers, assertions, etc.) defined by a user. This
table contains the time created and the last time changed
for each object.
USER_TABLES Contains extended data about each table such as space
allocation and statistical summaries.
USER_TAB_COLUMNS Contains basic and extended data for each column such as
the column name, the table reference, the data type, and a
statistical summary.
USER_VIEWS Contains the SQL statement defining each view.
18
Oracle Metadata

19
2.2 Components of a DBMS
• A DBMS is
partitioned into
several software
components (or
modules), each of
which is assigned a
specific operation.
• The DBMS
interfaces with
other software
components, such
as user queries and
access methods.
20
20
Components of a DBMS
• Query processor - transforms queries into low-level
instructions directed to the database manager.
• Database manager
• DML preprocessor converts DML statements embedded in
an application program into standard function calls in the
host language.

21
21
Components of a DBMS
• DDL compiler
converts DDL
statements into a
set of tables
containing
metadata. These Catalog
tables are then manager

stored in the
system catalog
• Catalog manager
manages access to
and maintains the
system catalog. 22
22
Components of Database Manager
• Authorization control.
• Command processor
• Integrity checker
• Query optimizer determines an
optimal strategy for the query
execution.
• Transaction manager
• Scheduler ensures concurrent
operations proceed without
conflicting with one another.
Recovery manager
• Buffer manager responsible for
the transfer of data between
main memory and secondary
storage, such as disk and tape.
23
23
3. ANSI-SPARC Architecture

The ANSI-SPARC Architecture (ANSI-SPARC


stands for American National Standards
Institute, Standards Planning And Requirements
Committee) is an abstract design standard for a
Database Management System (DBMS), first
proposed in 1975.

Most modern commercial DBMS are based on


this standard.
24
ANSI-SPARC Three-Level Architecture
External Level
– Users’ view of the database.
– Describes that part of database
that is relevant to a particular user.
Conceptual Level
– Community view of the database.
– Describes what data is stored in
database and relationships among
the data.
Internal Level
– Physical representation of the
database on the computer.
– Describes how the data is stored in
the database.
25
The Three Levels of ANSI-SPARC Architecture

What data is stored in database ?

How data is stored in database ?

26
Objectives of Three-Level Architecture

• All users should be able


to access same data.

• A user’s view is immune


to changes made in
other views.

• Users should not need to


know physical database
storage details.
27
Objectives of Three-Level Architecture
• DBA should be able to
change database storage
structures without
affecting the users’ views.

• Internal structure of
database should be
unaffected by changes to
physical aspects of storage.

• DBA should be able to


change conceptual
structure of database
without affecting all users.
28
Data Independence and the ANSI-SPARC Three-Level
Architecture
A major objective for the three-level architecture is to provide
data independence

Describes all the entities,


attributes, relationships &
integrity constraints

Contains definition of stored


data, indexes and storage
structures
29
Data Independence

Logical Data Independence Physical Data Independence


– Refers to immunity of – Refers to immunity of
external schemas to changes conceptual schema to
in conceptual schema. changes in the internal
– Conceptual schema changes schema.
(e.g. addition/removal of – Internal schema changes (e.g.
entities/attributes) should using different file
not require changes to organizations, storage
external schema or rewrites structures/devices) should
of application programs. not require change to
conceptual or external
schemas. 30
4. Multi-user DBMS Architectures

• The common architectures that are used


to implement multi-user database
management systems:
– Teleprocessing
– File-Server
– Client-Server

31
31
Teleprocessing
• One computer with a single CPU and a number of
terminals.
• Processing performed within the same physical
computer. User terminals are typically “dumb”,
incapable of functioning on their own, and cabled
to the central computer.

32
32
File-Server Architecture
• File-server is connected to
several workstations across
a network.
• Database resides on file-
server.
• DBMS and applications run
on each workstation.

33
File-Server Architecture

Disadvantages :
• Significant network traffic.
• Copy of DBMS on each
workstation.
• Concurrency, recovery and
integrity control more complex
(multiple DBMSs accessing the
same files.)

34
Traditional Two-Tier Client-Server
• Client (tier 1) manages user interface and runs
applications.
• Server (tier 2) holds database and DBMS.

35
Summary of Client-Server Functions

36
36
Three-Tier Client-Server
• 2-tier architecture presented two
problems preventing true
scalability:
– ‘Fat’ client, requiring
considerable resources on
client’s computer to run
effectively.
– Significant client side
administration overhead.

• By 1995, three layers proposed,


each potentially running on a
different platform.

37
Three-Tier Client-Server
• Advantages
– ‘Thin’ client, requiring less
expensive hardware.
– Application maintenance
centralized.
– Easier to modify or replace one
tier without affecting others.
– Separating business logic from
database functions makes it
easier to implement load
balancing.
– Maps quite naturally to Web
environment. 38
Modern Database Management, Hoffer 39
N-Tier Client-Server Architectures
• The three-tier
architecture can be
expanded to n tiers, with
additional tiers providing
more flexibility and
scalability.
• Applications servers host
API to expose business
logic and business
processes for use by other
applications.
40
40
Transaction Processing Monitors
• Forms the middle tier of
a three-tier architecture
• TP monitor is a program
that controls data
transfer between clients
and servers in order to
provide a consistent
environment,
particularly for Online
Transaction Processing
(OLTP).

41
How TP Monitor provides for consistent environment?

• Transaction Routing: The TP Monitor can increase


scalability by directing transactions to specific DBMS.

• Managing distributed transactions: The TP


Monitor can manage transactions that require access data
held in multiple DBMS.

• Load Balancing: The TP Monitor can balance client


request across multiple DBMS on one or more computer.

42
How TP Monitor provides for consistent environment?

• Increased Reliability: The TP Monitor acts as a


transaction manager, performing the necessary actions to
maintain the consistency of the database. If the database fails,
the TP Monitor may be able to resubmit the transaction to
another DBMS or hold the transaction until the DBMS become
available again.

• Funneling: Instead of each user connecting to the DBMS,


the TP Monitor can establish connection with DBMS as and
when required and funnel user requests through these
connections.

43
Distributed DBMSs
• A distributed database is
a logically interrelated
collection of shared data
(and a description of this
data), physically
distributed over a
computer network.
• Distributed DBMS
permits the management
of the distributed
database and makes the
distribution transparent 44
to users. 44
References
• Database Systems: A Practical Approach to
Design, Implementation and Management.
Connolly, T. M. and Begg, C. E. .
• Modern Database Management.Hoffer, J.A.,
Prescott, M., and McFadden,F.
• Database System Concepts . Silberschatz, A.,
Korth, H,. and Sudarshan, S.
• Fundamentals of Database Systems.
Elmasri, R. and Navathe, S.B.

45
45

You might also like