Anda di halaman 1dari 101

Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition

Copyright © 2004 Pearson Education, Inc.


Brownsmith, J. D., UNCA, Copyright 2004.

Copyright © 2004 Pearson Education, Inc.


Note

These slides have been edited (improved by


adding slides, figures and symbols, and in minor
ways) by Dr. JDBrownsmith

Copyright © 2004 Pearson Education, Inc.


Chapter 2

Database System
Concepts and
Architecture

Copyright © 2004 Pearson Education, Inc.


*
Review: Data and Metadata

 Database System: The DBMS software together with the data


itself. Sometimes, the applications are also included.

database system

data
Application DBMS data
catalog metadata

data - lots of it - e.g., 8 terabytes


metadata - describes the data types, structure, constraints
Slide 2-4
Client/Server Database System

Client Side Server Side


N
e
A t
Application P DBMS data
w catalog
I
o
r
k

Slide 2-5
**
Client/Server Database System

Client Side Server Side


N
laptop etowah.cs.unca.edu
e
A D
r t
Application P DBMS data
i w catalog
I v
e o
r r
k
SQL csci342
postgreSQL
pg74.1jdbc3.jar v 7.4
StudentRecordsDriver.java
Slide 2-6
I copy that Houston. The Client
side contains the application,
UI, and DB Driver. But I need
to know more than that for this
mission to succeed.
Over.

Slide 2-7
*
Data Model and Schema

used database
data in the Database
model creation Schema
data
of DBMS catalog

data

data model - concepts related to the structure of the database

schema - description of the database, stored in catalog


(aka "database schema", "database metadata schema")
Slide 2-8
*
2.1 Data Models
Data Model: A set of concepts to describe the
structure of a database, and certain constraints
that the database should obey.
data types, relationships, constraints

Data Model Examples:


– Relational - describes database structure as tables
– Network - describes database structure as a network
– Object Oriented - describes database structure as objects

p 26-27
Slide 2-9
2.1 Data Models
Basically, a data model is:

• A map or diagram that represents the


information needs of a system.

• A representation, usually graphic, of a


complex real-world data structure

Why do we need one?

It is an aid to thinking.

Slide 2-10
*
Data Models at Design Time

Database System Development Phases:

• Planning phase defines the goals of the database


• Analysis phase determines requirements
• Design phase: Create/use data models to
determine what data should be stored in the
database.
• Implementation phase: build, test, install
• Support phase: maintain, enhance, support users.

Slide 2-11
Data Model is a Conceptual Framework

Think of a data model as "data representation".

The relational data representation specifies that


you create tables, attributes, relationships, constraints;
all according to the relational data model rules/guidelines.
The result is called a schema.

The entity-relationship (ER) data representation specifies


that you create a diagram using rectangles, triangles, circles,
and lines according to the ER data models rules/guidelines.
The result is called a schema diagram.

Slide 2-12
*
2.1 Data Models

This course is about the relational data model


(where data is organized into tables), but there are
other kinds of data models.

Categories of Data Models


Data Models
A B C

relational
...

What are the categories? What category does relational fit into?
What other kinds of data models are there? p 26-27
Slide 2-13
**
Data Models
Data Model: A set of concepts to describe the
database structure and constraints.
data model categories
data model types high-level implementation physical
• UML is a

• Entity-Relationship
• Network
• Hierarchical
• Relational
• Object Oriented
• Object Relational

Slide 2-14
*
Categories of Data Models

High-level data models: Provide concepts that are


close to the way many users perceive data.

Implementation data models: balances user views


with some computer storage details.

Physical data models: Provide concepts that


describe details of how data is stored in the
computer.

p 26-27
Slide 2-15
*
Notes

Write the answer to Question 2.1 (p 46) here. Define:

data model

Write the answer to Question 2.2 (p 46) here (describe the


main categories of data models).

Slide 2-16
*
2.2 Schema Architecture
Database Schema: The description of a database.
Includes descriptions of the database structure and
the constraints that should hold on the database.

Schema has a database implementation.

p 26-27
Slide 2-17
FIGURE 2.2 The three-schema architecture. **

Slide 2-18
*
2.2 Schema Architecture

Where
are
we
headed?

Some examples of schemas


using different data models
Categories of Schema
p 26-27
Slide 2-19
*
FIGURE 2.1 Schema diagram for the database
in Figure 1.2.
Schema

This is the way the schema looks when we use the relational data model
Slide 2-20
*
Figure 2.8 The schema of Figure 2.1 in network
model notation.

This is the way the schema looks when we use the network data model
Slide 2-21
*
FIGURE 2.1 Schema diagram for the database
in Figure 1.2.
Schema

This is the way the schema looks when we use the network data model
Slide 2-22
*
Another Schema diagram
Schema

This is the way the schema looks when we use the hierarchical data model
Slide 2-23
FIGURE 2.2 The three-schema architecture. **

Slide 2-24
*
Categories of Schema
External schema describes part of a database that
a particular user or users are interested in.
Using the relational model, these are views

Conceptual schema describes the structure of he


whole database for a community of users.
Using the relational model, these are tables

Internal schema describes the physical storage


structure of the database.
These are not tables, this is the data as stored by the
DBMS. p 26-27
Slide 2-25
*
Database Schema
• Database Schema: data
The description of a database catalog

• Schema Diagram: A diagrammatic display of


(some aspects of) a database schema.

data
catalog

Slide 2-26
Let's see. STUDENTS take
COURSES which have
PREREQUISITES and SECTIONS.
But does GRADE_REPORT belong
with STUDENTS or COURSES?

Slide 2-27
*
FIGURE 2.1 Schema diagram for the database
in Figure 1.2.
"schema
construct"
Schema

Slide 2-28
*
Notes

Write the answer to Question 2.1 (p 46) here. Define:

database schema

internal schema

conceptual schema

external schema

Slide 2-29
Who is the User of Schema?
Database Schema: The description of a database.
Includes descriptions of the database structure and
the constraints that should hold on the database.

DBA: creates, reads, understands the


schema diagram

Computer Software and files:

data DBMS catalog: stores the schema for use on access


catalog

Slide 2-30
Other Topics: Database Instances
• Database Instance: The actual data stored in a
database at a particular moment in time. Also
called database state (or occurrence).

data

Slide 2-31
Database Schema Vs. Database State

• Database State: Refers to the content of a database at


a moment in time.
• Initial Database State: Refers to the database when
it is loaded
• Valid State: A state that satisfies the structure and
constraints of the database.
• Distinction
• The database schema changes very infrequently. The
database state changes every time the database is updated.
• Schema is also called intension, whereas state is called
extension.
Slide 2-32
2.2 Three-Schema Architecture

• A three-schema archiecture supports DBMS


characteristics of:
• Program-data independence.
• Support of multiple views of the data.

Slide 2-33
FIGURE 2.2 The three-schema architecture. **

Slide 2-34
Three-Schema Architecture

• Defines DBMS schemas at three levels:


• External schemas at the external level to describe the
various user views. Usually uses the same data model
as the conceptual level.
• Conceptual schema at the conceptual level to describe
the structure and constraints for the whole database for
a community of users. Uses a conceptual or an
implementation data model.
• Internal schema at the internal level to describe
physical storage structures and data access paths.
Typically uses a physical data model.

Slide 2-35
Don't forget - that's External,
Conceptual, then Internal.
And have a nice day, or else.

Slide 2-36
Conceptual Schema

At this level, we abstract out details like


computer storage structures, their Schemas

restrictions, or operational efficiencies.


External

The conceptual view of a relational database


is as a collection of relations or tables, each Conceptual

with fixed attributes and primary keys


ranging over given domains. Internal

Slide 2-37
Example of a Conceptual Schema **

String sqlCommand = "CREATE TABLE " + tableName +


"(" +
"user_id varchar(16) PRIMARY KEY," +
"user_name varchar(128)," +
"user_authorization_code varchar(8)," +
"account_status varchar(16)," +
"credit_rating varchar(4)," +
"billing_cycle varchar(8)," +
"amount_billed_to_date varchar(16)," +
"date_of_last_invoice varchar(16)," +
"amount_of_last_invoice varchar(16)," +
"date_of_last_activity varchar(12)," +
"number_of_queries varchar(16)," +
"amount_due varchar(16)" +
")";

This external/conceptual schema describes the structure of a table.


This schema is defined in a Java assignment statement.
Slide 2-38
Example Schema Processing

Java java.exe
Application javac.exe
Java
Java Virtual
.java Compiler .class
Machine
Java Java JDBC
Source byte-code Driver

contains PostgreSQL
conceptual data
DBMS catalog

schema
This schema is installed in the PostgreSQL DBMS catalog.
Slide 2-39
Notes

Consider the StudentRecords programming project where


you created and populated tables. How was the schema
defined?

Slide 2-40
Three-Schema Architecture

Schemas
Programs refer to an external schema,
and are mapped by the DBMS to the External
internal schema for execution.
Conceptual
Mappings among schema levels are
needed to transform requests and Internal

data.

Slide 2-41
2.2.2 Data Independence

Schemas
• Logical Data Independence: The
capacity to change the conceptual schema External
without having to change the external
schemas and their application programs.
Conceptual
• Physical Data Independence: The
capacity to change the internal schema Internal
without having to change the conceptual
schema.

Slide 2-42
Reference
Data Independence

When a schema at a lower level is changed,


only the mappings between this schema
and higher-level schemas need to be
changed in a DBMS that fully supports data
independence. The higher-level schemas
themselves are unchanged. Hence, the
application programs need not be changed
since they refer to the external schemas.

Slide 2-43
Notes

Slide 2-44
2.3 DBMS Languages

• Data Definition Language (DDL):


Used by the DBA and database designers Schemas
to specify the conceptual schema of a
database. In many DBMSs, the DDL is External
also used to define internal and external
schemas (views). Conceptual

Internal
In our StudentRecords project, the DDL
statements were the SQL statements:
CREATE TABLE, and DROP TABLE.

Slide 2-45
DBMS Languages

• Data Manipulation Language (DML):


Used to specify database retrievals and
updates.
• DML commands (data sublanguage) can be
embedded in a general-purpose programming
language (host language), such as COBOL, C
or an Assembly Language.
• Alternatively, stand-alone DML commands can
be applied directly (query language).

Slide 2-46
Notes

In our StudentRecords project, the DML


statements was: INSERT INTO <table>...

Recall that is was embedded in a Java String variable,


sqlCommand, and was executed as follows:
statement.execute(sqlCommand).

Slide 2-47
DBMS Languages

• High Level or Non-procedural


Languages: e.g., SQL, are set-oriented and
specify what data to retrieve than how to
retrieve. Also called declarative languages.

• Low Level or Procedural Languages:


record-at-a-time; they specify how to
retrieve data and include constructs such as
looping.
Slide 2-48
Notes

2.3.2 See Appendix

Slide 2-49
Figure 2.3 Component modules of a DBMS and their
interactions.
create database create table
create users update table

p. 35
Slide 2-50
You must be joking.
Right? Right?

Slide 2-51
*
2.4 Database System Utilities

• To perform certain functions such as:


• Loading data stored in files into a database. Includes
data conversion tools.
• Backing up the database periodically on tape.
• Reorganizing database file structures.
• Report generation utilities.
• Performance monitoring utilities.
• Other functions, such as sorting, user monitoring, data
compression, etc.

Slide 2-52
Slide 2-53
Will this class never end?

Slide 2-54
Notes

Slide 2-55
2.5

Centralized Architectures for DBMS

and

Client-Server Architectures for DBMS

Slide 2-56
Figure 2.4 A physical centralized architecture for
DBMS.

Slide 2-57
Centralized Architecture for DBMS

• Centralized DBMS:
(as shown on previous slide)
combines everything into single system
including-
DBMS software,
hardware,
application programs, and
user interface processing software.

Slide 2-58
2.5.2 Basic Client-Server Architecture

• Specialized Servers with Specialized


functions
• File Servers
• Printer Servers
• Web Servers
• E-mail Servers
• Clients

Slide 2-59
Basic Client-Server Architecture *

Client-Server Architectures for DBMS

Figure 2.5 Logical two-tier client/server architecture.


Slide 2-60
Basic Client-Server Architecture

Clients:

• Provide appropriate interfaces and a client-version of


the system to access and utilize the server resources.
• Clients maybe diskless machines or PCs or
Workstations with disks with only the client software
installed.
• Connected to the servers via some form of a network.
(LAN: local area network, wireless network, etc.)

Slide 2-61
Basic Client-Server Architecture

DBMS Server

• Provides database query and transaction


services to the clients
• Sometimes called query and transaction
servers

Slide 2-62
Two-Tier Client-Server Architecture

Figure 2.6 Physical two-tier client-server architecture.

Slide 2-63
Basic Client-Server Architecture
Our Programming Assignment Environment

etowah.cs.unca.edu
Java
Source
database
Java
Compiler csci343
DBMS various tables
server
Java
Virtual postgresql
Machine

Slide 2-64
Notes

Slide 2-65
If you thought two-tier was great, Mr. Anderson,
wait 'till you see three-tier.

Slide 2-66
Three-Tier Client-Server Architecture **

Figure 2.7 Logical three-tier client/server architecture.

Slide 2-67
2.5.4 Three Tier Client-Server Architecture

• Common for Web applications

• Intermediate Layer called Application Server or


Web Server:
• stores the web connectivity software and the rules and
business logic (constraints) part of the application used to
access the right amount of data from the database server
• acts like a conduit for sending partially processed data
between the database server and the client.

• Additional Features- Security:


• encrypt the data at the server before transmission
• decrypt data at the client
Slide 2-68
How many times do I have to
tell you. The three levels of a
three-level client-server
architecture are:
Client, Web Server, Database
Server.

Slide 2-69
*
Notes

Write the answer to Question 2.4 (p 46) here (describe the


three-schema architecture).

Slide 2-70
Notes

Write the answer to Question 2.9 (p 46) here (differences


between two-tier and three-tier client/server architectures).

Slide 2-71
2.6 Classification of DBMSs

• Classification based on the data model


used:

• Relational DBMS
• Network DBMS
• Hierarchical DBMS
• Object-oriented DBMS
• Object-relational DBMS

Slide 2-72
2.6 Classification of DBMSs

• Classification based on the number of


users:

• Single-user (typically used with micro-


computers)

• Multi-user (most DBMSs).

Slide 2-73
2.6 Classification of DBMSs

• Classification based on the number of


sites:

• Centralized (uses a single computer with one


database)

• Distributed (uses multiple computers, multiple


databases)

Slide 2-74
2.6 Classification of DBMSs

single multi-
user user
• Relational DBMS ss ss ms
• Network DBMS
• Hierarchical DBMS
• Object-oriented DBMS
• Object-relational DBMS

our programming
ss = single site assignment environment
ms = multi-site

Slide 2-75
Variations of multi-site (Distributed)
Environments:

• Homogeneous DDBMS
The same DBMS software at all sites

• Heterogeneous DDBMS
Different DBMS software at sites

• Federated or Multidatabase Systems


Loosely coupled databases

Slide 2-76
Federated

A user of a DBMS has a schema view that refers


to DBMS at other sites as if the entire schema
and data were local.

Slide 2-77
Recall

Slide 2-78
Illustration of Federated Architecture

Slide 2-79
**
Ch 02 Review Questions

1. How is the concept of a data model used in a DBMS?

2. What is a database Schema?


3. Name the types of schemas
4. Name the user of each type of schema
5. Draw a diagram of a three-tier architecture and
label the parts
6. Name three different ways to classify DBMS

Slide 2-80
Notes

Slide 2-81
Appendix

Slide 2-82
History of Data Models

"Those who cannot learn from history are doomed to repeat it."
George Santayana (1863-1952).

Slide 2-83
History of Data Models (1/4)

 Relational Model: proposed in 1970 by E.F. Codd (IBM),


first commercial system in 1981-82. Now in several
commercial products (DB2, ORACLE, SQL Server,
SYBASE, INFORMIX).
 Network Model: the first one to be implemented by
Honeywell in 1964-65 (IDS System). Adopted heavily
due to the support by CODASYL (CODASYL - DBTG
report of 1971). Later implemented in a large variety of
systems - IDMS (Cullinet - now CA), DMS 1100 (Unisys),
IMAGE (H.P.), VAX -DBMS (Digital Equipment Corp.).
 Hierarchical Data Model: implemented in a joint effort by
IBM and North American Rockwell around 1965. Resulted
in the IMS family of systems. The most popular model.
Other system based on this model: System 2k (SAS inc.)

Slide 2-84
History of Data Models (2/4)

 Object-oriented Data Model(s): several models have been


proposed for implementing in a database system. One set
comprises models of persistent O-O Programming
Languages such as C++ (e.g., in OBJECTSTORE or
VERSANT), and Smalltalk (e.g., in GEMSTONE).
Additionally, systems like O2, ORION (at MCC - then
ITASCA), IRIS (at H.P.- used in Open OODB).
 Object-Relational Models: Most Recent Trend. Started
with Informix Universal Server. Exemplified in the latest
versions of Oracle-10i, DB2, and SQL Server etc. systems.

Slide 2-85
Hierarchical Data Model (3/4)

• ADVANTAGES:
• Hierarchical Model is simple to construct and operate on
• Corresponds to a number of natural hierarchically organized
domains - e.g., assemblies in manufacturing, personnel
organization in companies
• Language is simple; uses constructs like GET, GET
UNIQUE, GET NEXT, GET NEXT WITHIN PARENT etc.
• DISADVANTAGES:
• Navigational and procedural nature of processing
• Database is visualized as a linear arrangement of records
• Little scope for "query optimization"

Slide 2-86
Network Data Model (4/4)

• ADVANTAGES:
• Network Model is able to model complex relationships and
represents semantics of add/delete on the relationships.
• Can handle most situations for modeling using record types
and relationship types.
• Language is navigational; uses constructs like FIND, FIND
member, FIND owner, FIND NEXT within set, GET etc.
Programmers can do optimal navigation through the database.
• DISADVANTAGES:
• Navigational and procedural nature of processing
• Database contains a complex array of pointers that thread
through a set of records.
Little scope for automated "query optimization”

Slide 2-87
History of Data Models

RDBMS Provides a declarative SQL language API


for users to specify what they want done.

Hierarchical and Network Data Models


- the programmer navigates through the database

end

Slide 2-88
Notes

Slide 2-89
2.3.2 DBMS Interfaces

• Stand-alone query language interfaces.


• Programmer interfaces for embedding DML in
programming languages:
• Pre-compiler Approach
• Procedure (Subroutine) Call Approach
• User-friendly interfaces:
• Menu-based, popular for browsing on the web
• Forms-based, designed for naïve users
• Graphics-based (Point and Click, Drag and Drop etc.)
• Natural language: requests in written English
• Combinations of the above

Slide 2-90
Other DBMS Interfaces

• Speech as Input (?) and Output


• Web Browser as an interface
• Parametric interfaces (e.g., bank tellers) using
function keys.
• Interfaces for the DBA:
• Creating accounts, granting authorizations
• Setting system parameters
• Changing schemas or access path

Slide 2-91
Two-Tier Client-Server Architecture

2.5.3 Two Tier Client-Server Architecture:


Summary
• User Interface Programs and Application
Programs run on the client side
• Interface called ODBC (Open Database
Connectivity – see Ch 9) provides an Application
program interface (API) allow client side
programs to call the DBMS. Most DBMS vendors
provide ODBC drivers.

Slide 2-92
Two-Tier Client-Server Architecture

Two Tier Client-Server Architecture:


Summary

• A client program may connect to several DBMSs.

• Other variations of clients are possible: e.g., in


some DBMSs, more functionality is transferred to
clients including data dictionary functions,
optimization and recovery across multiple servers,
etc. In such situations the server may be called the
Data Server.

Slide 2-93
out
Slide 2-94
2.1 Data Models

Data Model: A set of concepts to describe the


structure of a database, and certain constraints
that the database should obey.
Data Model Operations: Operations for
specifying database retrievals and updates by
referring to the concepts of the data model.
Operations on the data model may include basic
operations and user-defined operations.

Slide 2-95
Categories of Data Models

High-level (conceptual, semantic) data models:


Provide concepts that are close to the way many
users perceive data. (Also called entity-based or
object-based data models.)
Implementation (representational) data models:
Provide concepts that fall between the other two,
balancing user views with some computer storage
details.
Physical (low-level, internal) data models:
Provide concepts that describe details of how data
is stored in the computer.
p 26-27
Slide 2-96
*
Schema
• Database Schema: The description of a database.
Includes descriptions of the database structure and
the constraints that should hold on the database.
Schema is real (has an implementation), not just a concept.

types
Schema external conceptual internal
uses uses uses
concepts
Data Model Categories: high-level implementation physical
(conceptual)
Specific Data Model
Relational Relational
Example:
Slide 2-97
Other Topics: Schema Construct
• Schema Construct: A component of the schema
or an object within the schema, e.g., STUDENT,
COURSE.

Slide 2-98
DDL

Slide 2-99
2.3 DBMS Languages

• Data Definition Language (DDL):


Used by the DBA and database designers Schemas
to specify the conceptual schema of a
database. In many DBMSs, the DDL is External
also used to define internal and external
schemas (views). Conceptual

• In some DBMSs, separate storage Internal

definition language (SDL) and view definition


language (VDL) are used to define internal and
external schemas.
Slide 2-100
Other Tools

• Data dictionary / repository:


• Used to store schema descriptions and other information such
as design decisions, application program descriptions, user
information, usage standards, etc.
• Active data dictionary is accessed by DBMS software and
users/DBA.
• Passive data dictionary is accessed by users/DBA only.
• Application Development Environments and CASE
(computer-aided software engineering) tools:
• Examples – Power builder (Sybase), Builder (Borland)

Slide 2-101

Anda mungkin juga menyukai