213-02 Envi - Revised
213-02 Envi - Revised
DB Environment
ITIS 213
Objectives
Purpose of three-level database architecture.
Contents of external, conceptual, and internal levels.
Purpose of external/conceptual and conceptual/internal mappings.
Meaning of logical and physical data independence.
Distinction between DDL and DML.
A classification of data models.
Purpose/importance of conceptual modeling.
Typical functions and services a DBMS should provide.
Function and importance of system catalog.
Software components of a DBMS.
Meaning of client–server architecture and advantages of this type of
architecture for a DBMS.
Function and uses of Transaction Processing Monitors.
2 / 85
Three-Level Architecture
Early proposal for a standard terminology and general
architecture for DBSs was produced in 1971
3 / 85
Three-Level Architecture
3 distinct levels at which data items can be described:
◦ External level: the way the users perceive the data
◦ Conceptual level: provides both the mapping and the desired
independence between the external and the internal levels.
◦ Internal level: the way the DBMS and the OS perceive the data
5 / 85
External Level
Users’ view of the DB, it describes that part of DB that
is relevant to a particular user.
6 / 85
External Level
Different users may have different views of the same
data
◦ day month year or year month day
7 / 85
Conceptual Level
Community view of the DB, describes what data is
stored in DB and relationships among the data.
8 / 85
Conceptual Level
Represents:
◦ All entities, their attributes, and their relationships
◦ The constraints on the data
◦ Semantic information about the data
◦ Security and integrity information
9 / 85
10 / 85
Conceptual Level
Must not contain any storage-dependent details.
Example:
◦ Description of an entity should contain only data type of
attributes and their length, but not any storage considerations
such as the number of bytes occupied.
11 / 85
Internal Level
Physical representation of the DB on the computer.
12 / 85
Internal Level
It interfaces with the OS access methods (i.e. file
management techniques for storing and retrieving data
records) to:
◦ place the data on the storage devices
◦ build the indexes
◦ retrieve the data
It concerns with:
◦ Storage space allocation for data and indexes
◦ Record descriptions for storage (with stored sizes for data
items)
◦ Record placement
◦ Data compression and data encryption techniques
13 / 85
The Physical Level
Managed by the OS under the direction of the
DBMS. But the function of the OS and DBMS
may vary from system to system.
◦ Some DBMS take advantage of many of the OS
access methods, while others use only the most
basic ones and create their own file organizations.
14 / 85
The Physical Level
The physical level consists of items only the
OS knows such as exactly how the
sequencing is implemented and whether the
fields of internal records are stored as
continuous bytes on the disk.
15 / 85
Schema, Mappings, & Instances
The overall description of the DB is called the
DB schema.
16 / 85
Schema, Mappings, & Instances
Types of schema in the DB defined according
to the 3-level architecture:
◦ External schema (or subschemas): correspond to
different views of the data.
◦ Conceptual schema: describes all the entities,
attributes, and relationships together with integrity
constraints.
◦ Internal schema: complete description of the
internal model, containing the definitions of stored
records, the methods of representation, the data
fields, and the indexes and storage structures used.
◦ There is only one conceptual schema and one
internal schema per DB.
17 / 85
Schema, Mappings, & Instances
The DBMS is responsible for mapping
between these 3 types of schema.
18 / 85
Schema, Mappings, & Instances
The conceptual schema is related to the
internal schema through a
conceptual/internal mapping.
This enables the DBMS to find the actual
mapping.
19 / 85
Schema, Mappings, & Instances
The DBMS allows any differences in:
◦ entity names
◦ attribute names
◦ attribute order
◦ data types, and so on
to be resolved.
Each external schema is related to the
conceptual schema by the
external/conceptual mapping allowing the
DBMS to map names in the user’s view on to
the relevant part of the conceptual schema.
20 / 85
Schema, Mappings, & Instances
21 / 85
Schema, Mappings, & Instances
Example: DBMS
maps the sNo field
of the 1st external
view to the staffNo
field of the
conceptual record.
24 / 85
Physical Data Independence
The following figure illustrates where each
type of data independence occurs in relation
to the 3-level architecture.
25 / 85
Physical Data Independence
The 2-stage mapping in the ANSI-SPARC
architecture may be inefficient, but provides
greater data independence.
For more efficient mapping, the ANSI-SPARC
27 / 85
DB Languages
Many DBMS have a facility for embedding the
sublanguage in a high-level language (e.g C+
+ which is called here a host language.
To compile the embedded file:
29 / 85
Data Definition Language (DDL)
The result of the compilation of the DDL
statements is a set of tables stored in special
files collectively called the system catalog (or
data dictionary, data directory).
The system catalog integrates the metadata,
30 / 85
Data Definition Language (DDL)
The DBMS normally consults the system
catalog before the actual data is accessed in
the DB.
Theoretically, different DDLs can be identified
32 / 85
Data Manipulation Language (DML)
Data manipulation applies to
At higher levels, emphasis is placed on ease of
use and effort is directed at providing efficient
◦ The external level user interaction with the system
33 / 85
Data Manipulation Language (DML)
The part of DML that involves data retrieval is
called query language. It is a High level special
purpose language used to satisfy diverse requests
for the retrieval of data held in the DB
Types of DMLs (based on their underlying retrieval
constructs):
◦ Procedural DML
Specifies how the output of a DML statement is to be
obtained
Treat records individually
◦ Non-procedural DML
Describe only what output is to be obtained
Operate on sets of records
34 / 85
1. Procedural DML
A language that allows the user to tell the system
what data is needed and exactly how to retrieve the
data.
The user must express all the data access
operations that are to be used by calling
appropriate procedures to obtain the information
required.
Procedural DMLs are embedded in a high level
programming language that contains constructs to
facilitate iteration and handle navigational logic.
Network and hierarchical DMLs are procedural
35 / 85
2. Non-Procedural DMLs
Also called declarative language which allows the
user to state what data is needed rather than how it
is to be retrieved.
Allow the required data to be specified in a single
retrieval or update statement.
User specifies what data is required without
specifying how it is to be obtained.
The DBMS translates a DML statement into one or
more procedures that manipulate the required sets
of records.
Easier to learn than procedural language such as
SQL and QBE(Query by Example).
36 / 85
4th Generation Languages (4GLs)
An operation that requires hundreds of lines
in a 3GL, requires significantly fewer lines in
4GL.
3GL is procedural, 4GL is non-procedural
In 4GL the user does not define steps, but
defines parameters
4GL relies on 4GL tools
4GL can improve productivity by a factor of
ten
37 / 85
4th Generation Languages (4GLs)
4GL encompasses:
◦ Presentation language, such as query languages
and report generators
◦ Specialty languages, such as spreadsheet and DB
languages
◦ Application generators that define, insert, update,
and retrieve data from the DB to build applications
◦ Very high-level languages that are used to generate
application code
38 / 85
4GLs: Form Generators
Interactive facility for rapidly creating data
input and display layouts for screen forms.
Allows users to define what the screen is to
39 / 85
4GLs: Report Generators
Facility for crating reports from data stored in
the DB.
Similar to a query language in that it allows
looks like.
We can let the report generator automatically
◦ Visually oriented
We use a facility similar to a forms generator to define
the same information.
41 / 85
4GLs: Graphics Generators
Facility to retrieve data from the DB and
display it as a graph showing trends and
relationships in the data.
◦ Bar charts
◦ Pie charts
◦ Line charts
◦ Scatter charts
42 / 85
4GLs: Application Generators
Facility for producing a program that
interfaces with the DB.
Reduces the design time
Consists of pre-written modules that
45 / 85
Data Model Components
Structural part: construction rules of DB
46 / 85
Purpose of Data Model
To represent data and to make the data
understandable the DB can easily be
designed
47 / 85
Levels of Data Models According to
the ANSI SPARC Architecture
External data model: to represent each user’s
view of the organization, sometimes called
the universe of discourse (UoD).
48 / 85
Categories of Data Models
Object-based data model
}
Used to describe data at the
conceptual and external level
Record-based data model
Physical data model
Describes data at the
internal level
49 / 85
1. Object-based Data Models
Uses concepts such as entities, attributes and
relationships.
50 / 85
Common Types of Object-based Data
Model
Entity-Relationship
Semantic
Functional
Object Oriented
51 / 85
2. Record-based Data Models
The DB consists of a number of fixed-format
records possibly of different types.
Each record type defines a fixed number of
}
processing, i.e specifying what data is to be
◦ Network data model retrieved.
52 / 85
2. Record-based Data Models
Used to specify the overall structure of the DB
and a higher-level description of the
implementation.
Drawback:
53 / 85
A. Relational Data Model
Based on the concept of mathematical
relations.
Data and relationships are represented as
tables.
Each table has a number of columns with a
unique name.
54 / 85
A. Relational Data Model
55 / 85
A. Relational Data Model
It requires that the DB be perceived by the
user as table.
This perception applies only to the logical
56 / 85
B. Network Data Model
Data is represented as collections of records,
and relationships are represented by sets.
Records appear as nodes (or segments), and
Associates’ IDMS/R.
57 / 85
C. Hierarchical Data Model
Restricted type of network model
Data is represented as collections of records
58 / 85
C. Hierarchical Data Model
59 / 85
Physical Data Models
Describe how data is stored in the computer,
representing information such as
◦ Record structures
◦ Record orderings
◦ Access paths
60 / 85
Conceptual Modeling
Conceptual schema is the heart of the DB
It supports all the external views and is
61 / 85
Conceptual Modeling
Conceptual modeling (or conceptual DB
design) is the process of constructing a
model of the information use in an enterprise
that is independent of implementation
details, such as the target DBMS, application
programs, programming languages, or any
other physical considerations.
It is independent of all implementation
63 / 85
Functions of a DBMS
2. A User-Accessible Catalog
◦ To store description of data items and which is
accessible to users:
Names, types and sizes of data items
Names of relationships
Integrity constraints on the data
Names of authorized users who have access to data
Data items that each user can access and types of access
allowed, e.g insert, update, delete, or read access
External, conceptual, and internal schemas and the
mappings between the schemas
Usage statistics, e.g. frequencies of transactions and
counts on the number of accesses made to objects in DB
64 / 85
Functions of a DBMS
DBMS System catalog is a fundamental
component, many software components rely
on it for information.
Benefit of a system catalog:
65 / 85
Functions of a DBMS
Benefit of a system catalog (Cont):
◦ Redundancy and inconsistencies can be identified
more easily since the data is centralized.
◦ Changes to the DB can be recorded.
◦ The impact of a change can be determined before it
is implemented, since the system catalog records
each data item, all its relationships, and all its
users.
◦ Security can be enforced.
◦ Integrity can be ensured.
◦ Audit information can be provided.
66 / 85
Functions of a DBMS
3. Transaction Support
◦ Mechanism which will ensure either that all the
updates corresponding to a given transaction are
made or that none of them is made
◦ Ex:
Add a new member of staff to the DB
Update the salary of a member of staff
Delete a property from the register 67 / 85
Functions of a DBMS
◦ Ex:
Delete a member of staff from the DB
Reassign the properties that he or she managed to
another member of staff
68 / 85
Functions of a DBMS
4. Concurrency Control Services
◦ To ensure that the DB is updated correctly when
multiple users are updating the DB concurrently
69 / 85
Functions of a DBMS
T1 T2
Withdrawing Depositing
T1 T $10
2 balx $100
t1 read(balx) 100
t2 read(balx) balx=balx+100100
t3 balx=balx-10 write(balx) 200
t4 write(balx) 90
t5 90
◦ If T1 and T2 were executed serially, the final balance
would be $190 regardless of which was performed
first.
◦ But they start nearly at the same time and both read
$100. T2 then increases balx by $100 to $200 and
stores the update in the DB. Meanwhile, T 1
decrements its copy of balx by $10 to $90 and
stores this value in the DB, overwriting the previous 70 / 85
Functions of a DBMS
5. Recovery Services
◦ To recover the DB in the event of damage
◦ Causes of damage:
System crash
Media failure
Hardware or software error causing the DBMS to stop
Power failure
Result of the user detecting an error during the
transaction and aborting the transaction before it
completes
71 / 85
Functions of a DBMS
6. Authorization Services.
◦ Only authorized users can access the DB
◦ Ex: only branch manager is allowed to see salary-
related information for staff
◦ To protect the DB from unauthorized access,
intentional or unintentional (security)
72 / 85
Functions of a DBMS
7. Support for Data Communication
◦ DBMS must be capable of integrating with
communication software
◦ Most users access the DB from workstations
connected:
directly to the computer hosting the DBMS or
Remotely through a network
◦ The DBMS receives a communication messages and
response in a similar way
◦ All transmissions are handled by Data
Communication Manager (DCM)
◦ DCM is not part of the DBMS but integrated with the
DBMS
73 / 85
Functions of a DBMS
8. Integrity Services
◦ Both the data in the DB and the changes to the data
follow certain rules
◦ DB integrity: correctness and consistency of stored
data. It is another type of data protection
◦ Integrity is concerned with the quality of data
◦ Integrity is usually expressed in terms of
constraints (consistency rules that the DB is not
permitted to violate)
74 / 85
Functions of a DBMS
9. Services to Promote Data Independence.
◦ To support the independence of programs from the
actual structure of the DB
◦ Data independence is achieved through a view or
subschema mechanism.
◦ Physical data independence is easier to achieve
◦ Logical data independence is more difficult (in
some systems, any type of change to the logical
structure is prohibited)
◦ It is easy to add new entity, attribute, and
relationship but difficult to remove
75 / 85
Functions of a DBMS
10. Utility Services
◦ Help the DBA to administer the DB
◦ Some utilities work at the external level and
consequently can be produced by the DBA. Others
work at the internal level and can be provided by
the DBMS vendor
◦ Examples
Import facilities (from flat files) and export facilities
Monitoring facilities: to monitor the DB usage
Statistical analysis: to examine performance
Index reorganization facilities
Garbage collection and reallocation: to remove deleted
records physically from the storage devices to
consolidate the space released 76 / 85