Chapter (2) - Enviroment
Chapter (2) - Enviroment
DB Environment
Ahmed M. Zeki
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 / 83
Three-Level Architecture
Early proposal for a standard terminology and general
architecture for DBSs was produced in 1971
3 / 83
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
4 / 83
ANSI-SPACR 3-level architecture
Objectives of the 3-level Architecture
The objective is to separate each user’s view of the DB
from the way the DB is physically represented. Why?
◦ Each user should be able to access same data, but have
different customized view.
◦ Each user should be able to change the way they view the data,
which should not affect other users.
◦ Users should not have to deal directly with physical DB
storage details (e.g. indexing, hashing).
◦ DBA should be able to change the DB storage structure
without affecting the users’ views.
◦ DBA should be able change the conceptual structure of the DB
without affecting all users.
5 / 83
External Level
Users’ view of the DB, it describes that part of DB that
is relevant to a particular user.
6 / 83
External Level
Different views may have different views of the same
data
◦ day month year or year month day
7 / 83
Conceptual Level
Community view of the DB, describes what data is
stored in DB and relationships among the data.
8 / 83
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 / 83
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.
10 / 83
Internal Level
Physical representation of the DB on the computer.
11 / 83
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
12 / 83
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.
13 / 83
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.
14 / 83
Schema, Mappings, & Instances
The overall description of the DB is called the
DB schema.
15 / 83
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.
16 / 83
Schema, Mappings, & Instances
The DBMS is responsible for mapping
between these 3 types of schema.
17 / 83
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.
18 / 83
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.
This enables the DBMS to map names in the
20 / 83
Schema, Mappings, & Instances
Example: DBMS
maps the sNo field
of the 1st external
view to the staffNo
field of the
conceptual record.
23 / 83
Logical Data Independence
Refers to the immunity of the external schemas to
changes in the conceptual schema.
◦ Ex: addition or removal of new entities, attributes, or
relationships, should be possible without having to change
existing external schemas or having to rewrite application
programs.
◦ Users for whom the changes have been made need to be aware
of them, but other users should not be.
24 / 83
Physical Data Independence
Refers to the immunity of the conceptual
schema to changes in the internal schema.
25 / 83
Physical Data Independence
From the users’ point of view, the only effect
that may be noticed is a change in
performance.
26 / 83
Physical Data Independence
The following figure illustrates where each
type of data independence occurs in relation
to the 3-level architecture.
27 / 83
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
DB Languages
constructs for all computing needs such as
conditional or iterative statements which are
provided by high-level programming languages
29 / 83
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:
31 / 83
Data Definition Language (DDL)
A language that allows the DBA or user to
describe and name the entities, attributes,
and relationships required for the application,
together with any associated integrity and
security constraints.
32 / 83
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,
33 / 83
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
35 / 83
Data Manipulation Language (DML)
Data manipulation applies to
At higher levels, emphasis is placed on ease of
◦ The external level use and effort is directed at providing efficient
user interaction with the system
36 / 83
Data Manipulation Language (DML)
The part of DML that involves data retrieval is
called query language:
37 / 83
Data Manipulation Language (DML)
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
38 / 83
1. Procedural DML
A language that allows the user to tell the
system what data is needed and exactly how
to retrieve the data.
39 / 83
1. Procedural DML
Procedural DMLs are embedded in a high
level programming language that contains
constructs to facilitate iteration and handle
navigational logic.
40 / 83
2. Non-Procedural DMLs
Also called declarative language.
42 / 83
2. Non-Procedural DMLs
SQL and QBE (Query By Example) include
some form of non-procedural language.
43 / 83
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
44 / 83
4th Generation Languages (4GLs)
4GL compasses:
◦ 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
45 / 83
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
46 / 83
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.
48 / 83
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
49 / 83
4GLs: Application Generators
Facility for producing a program that
interfaces with the DB.
Reduces the design time
Consists of pre-written modules that
52 / 83
Data Model Components
Structural part: construction rules of DB
53 / 83
Purpose of Data Model
To represent data and to make the data
understandable the DB can easily be
designed
54 / 83
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).
55 / 83
Categories of Data Models
Object-based data model
Record-based data model } Used to describe data at the
conceptual and external level
56 / 83
1. Object-based Data Models
Uses concepts such as entities, attributes and
relationships.
57 / 83
Common Types of Object-based
Data Model
Entity-Relationship
Semantic
Functional
Object Oriented
58 / 83
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.
59 / 83
2. Record-based Data Models
Used to specify the overall structure of the DB
and a higher level description of the
implementation.
Drawback:
60 / 83
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.
61 / 83
A. Relational Data Model
62 / 83
A. Relational Data Model
It requires that the DB be perceived by the
user as table.
This perception applies only to the logical
63 / 83
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.
64 / 83
C. Hierarchical Data Model
Restricted type of network model
Data is represented as collections of records
65 / 83
C. Hierarchical Data Model
66 / 83
Physical Data Models
Describe how data is stored in the computer,
representing information such as
◦ Record structures
◦ Record orderings
◦ Access paths
67 / 83
Conceptual Modeling
Conceptual schema is the heart of the DB
It supports all the external views and is
70 / 83
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
71 / 83
Functions of a DBMS
DBMS System catalog is a fundamental
component, many software components rely
on it for information.
Benefit of a system catalog:
72 / 83
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.
73 / 83
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
74 / 83
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
75 / 83
Functions of a DBMS
4. Concurrency Control Services
◦ To ensure that the DB is updated correctly when
multiple users are updating the DB concurrently
76 / 83
Functions of a DBMS
T1 T2
Withdrawing Depositing
T1 $10 T2 $100
balx
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.
◦
77 / 83
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
78 / 83
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)
79 / 83
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
80 / 83
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)
81 / 83
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
82 / 83
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 83 / 83