Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Database Management
Systems
What is a Database?
A database is any collection of data.
A DBMS is a software system
designed to maintain a database.
We use a DBMS when
there is a large amount of data
security and integrity of the data are
important
many users access the data
concurrently
Example Database
Application
Consider a Phone Company, such as
AT&T
Kinds of information they deal with:
customer records
employee records
billing information
management records
switching and wiring diagrams
Concerns of a Database
User
With all that data,
AT&T must be concerned with
questions such as:
Where is the information kept?
How is the data structured?
How is the data kept consistent?
How is the data described?
How is the data kept secure?
How do different pieces of data interrelate?
users of
the data
There is no control or
coordination of what
these programs do
with the data
applications
DBMS
users of
the data
Levels of Abstraction
Users
Physical schema
describes the files and
indexes used.
(sometimes called the
ANSI/SPARC model)
Physical Schema
DB
View 1
View 2
View 3
Physical schema:
Relations stored as unordered files.
Index on first column of Students.
Data Independence
Applications insulated from
how data is structured and
stored.
Logical data independence:
Protection from changes in
logical structure of data.
View 1
View 2
View 3
Conceptual Schema
Physical Schema
Physical data
independence: Protection
from changes in physical
structure of data.
DB
Count
Having
distinct
Group(agg)
Join
Select
Join
Emp
Proj
Emp
Emp
Asgn
Employees
Projects
Assignments
Levels of Abstraction
Example of a Relation
University Database
Three-Schema Architecture
Defines DBMS schemas at three levels:
Internal schema at the internal level to
describe physical storage structures and
access paths (e.g indexes).
Conceptual schema at the conceptual level
to describe the structure and constraints for
the whole database for a community of users.
External schemas at the external level to
describe the various user views.
The three-schema
architecture
User/application view
defined by user or
application
programmer in
consultation with DBA
Defined by DBA
DBMS Languages
The first step to create a database through DBMS
is to specify conceptual and internal schemas for
the database
Data Definition Language (DDL): is used by
database designers to define schemas
Data Manipulation Language (DML)
View Definition Language (VDL): is to specify
user views
In current DBMS, the preceding types of
languages are usually not considered distinct
languages
ANSI/SPARC Architecture
ANSI - American
National Standards
Institute
SPARC - Standards
Planning and
Requirements
Committee
1975 - proposed a
framework for DBs
A three-level
architecture
Internal level: For
systems designers
Conceptual level: For
database designers and
administrators
External level: For
database users
Internal Level
Deals with physical
storage of data
Structure of records on
disk - files, pages,
blocks
Indexes and ordering of
records
Used by database
system programmers
Internal Schema
RECORD EMP
LENGTH=44
HEADER: BYTE(5)
OFFSET=0
NAME: BYTE(25)
OFFSET=5
SALARY: FULLWORD
OFFSET=30
DEPT: BYTE(10)
OFFSET=34
Conceptual Level
Deals with the
organisation of the
data as a whole
Abstractions are used to
remove unnecessary
details of the internal
level
Used by DBAs and
application
programmers
Conceptual Schema
CREATE TABLE
Employee (
Name
VARCHAR(25),
Salary REAL,
Dept_Name
VARCHAR(10))
External Level
Provides a view of the
database tailored to a
user
Parts of the data may
be hidden
Data is presented in a
useful form
Used by end users and
application
programmers
External Schemas
Payroll:
String Name
double Salary
Personnel:
char *Name
char *Department
Mappings
Mappings translate
information from one
level to the next
External/Conceptual
Conceptual/Internal
These mappings
provide data
independence
Physical data
independence
Changes to internal
level shouldnt affect
conceptual level
Logical data
independence
Conceptual level
changes shouldnt
affect external levels
ANSI/SPARC Architecture
User 1
External Schemas
User 2
External
View 1
User 3
External
View 2
External/Conceptual Mappings
Conceptual Schema
Conceptual
View
Conceptual/Internal Mapping
Internal Schema
Stored
Data
DBA
Interfacing Components of
DBMS
users
software
hardware
data
DBMS Roles
application developers
DBMS
system
developers
database
designer
data
definition
processor
application
application
application
program(s)
application
program(s)
program(s)
program(s)
users of
the
data
query processor
security manager
concurrency manager
index manager
data
dictionary
data
system
administrator
(and DB
designer)
DBMS Roles
Actors On the Scene
(people interested in the actual
data):
database administrators
database designers
systems analysts and application
programmers
end users
DBMS Roles
Actors Behind the Scene:
people who maintain the
environment
but aren't interested in the actual
data
DBMS designers and implementers
tools developers
operators and maintenance personnel
database researchers
Software
controls the organization, storage, management, and retrieval of
data in a database.
It includes operating system, network software, and the
application programs
which encompasses the physical interconnections and devices
required to store and execute (or run) the software.
software consists of a machine language specific to an individual
processor.
It is usually written in high-level programming language more
efficient for humans to use .
Hardware
Hardware of a system can range from a PC to a network of
computers.
It also includes various storage devices like hard discs and
input and output devices like monitor, printer, etc.
DATA
User Interface
Data Manager
File Manager
Disk Manager
Physical Database
User Interface
The user interface is the is the aggregate of means by which the
people
the user interacts with the system a particular machine,
device, computer programme or other complex tools.
The user interface provides the means of:
-Input, allowing the users to manipulate the system.
-Output, allowing the system to produce the effects of the
users manipulation.
It refers to the graphical, textual and auditory information the
programme presents to the user and the control sequences the user
employs to the program.
Data Manager
It is a program which allows you to process and manipulate your data
in a easy and logical manner using a graphical interface.
Data Manager reads and writes delaminated files such as comma
separated files (CSV) and also can read data from ODBC Data
Sources.
It allows you to construct a conceptual design on how you are going
to process your data and transform it into another form.
You form your design by adding functional nodes and linking them
such that the links form the data flow through nodes on a graphical
work area.
You form your design by adding functional nodes and linking them
such that the links form the data flow through nodes on a graphical
work area.
Each node performs a single function on your data, once it completes
it passes your data to the node it is linked to and the process continues
until the data encounters a output node.
You can form a simple design or a complicated design with hundreds
of nodes and multiple input and output nodes.
File Manager
A file manager or file browser is a computer program that provides a
user interface to work with file systems.
They are very useful for speeding up interaction with files
The most common operations on files are create, open, edit, view,
print, play, rename, move, copy, delete, attributes, properties,
search/find, and permissions.
File managers may contain features inspired by web browsers,
including forward and back navigational buttons.
file managers also provide the ability to extend operations using user
written scripts.
It passes request to disk manager.
Disk Manager
Disk manager is a simple filesystem configurator that allows you to:
-Automatically detect new partitions at startup.
Interaction of DBMS
components
Transaction Manager
DBMS
user
interface
Data
Manage
r
File
Manag
er
Disk
Manag
er
Recovery Manager
Physical
Databas
e
Explanation of interactions
The user requests for specific information with the help of user
interface.
This request is processed by data manager and after processing ,data
manager request for specific records to the file manager.
The file manager then request for the specific block to the disk
manager.
The disk manager then then retrives the block and sends it to file
manager,which sends the required record to data manager.
The transaction manager supervises the data transactions that is carried
out between the data manager, file manager, and the disk manager.
The recovery manager keeps a check on the transacted data so that in
case of system failure, the data can be protected.
Advantages of Using a
DBMS
application
application
application
program(s)
application
program(s)
program(s)
program(s)
users of
the
data
query processor
security manager
concurrency manager
index manager
data
definition
processor
data
dictionary
data
software operating
between the data and
the applications can
provide many
capabilities
in a generic way
Persistence
A DBMS provides
persistent objects, types and data structures
persistent = having a lifetime longer than
the programs that use the data
any information that fits the data model
of a particular DBMS
can be made persistent with little effort
data model = concepts that can be used to
describe the data
Concurrency
A DBMS supports access by concurrent users
concurrent = happening at the same time
concurrent access, particularly writes (data changes),
Access Control
A DBMS can restrict access to
authorized users
security policies often require control
that is more fine-grained than that
provided by a file system
since the DBMS understands the data
structure, it can enforce fairly
sophisticated and detailed security
policies
Redundancy Control
A DBMS can assist in controlling redundancy
redundancy = multiple copies of the same data
with file storage, it's often convenient to store
multiple copies of the same data, so that it's "local"
to other data and applications
this can cause many problems:
wasted disk space
inconsistencies
need to enter the data multiple times
Complex Semantics
A DBMS supports representation
of complex relationships and integrity
constraints
the semantics (meaning) of an application often
includes many relationships and rules
about the relative values of subsets of the data
these further restrict the possible instances of the
database
relationships and constraints can be defined as part of
the schema
DBMS Structure
application
application
program(s)
application
program(s)
application
program(s)
program(s)
users of
the data
external/application view
internal/implementation view
DBMS
software
components
data
description
data
definition
processor
query processor
security manager
concurrency manager
index manager
data
dictionary
data
DBMS Languages
DML: data manipulation language
QL: query language
GPL: general purpose languages
application
application
application
program(s)
application
program(s)
program(s)
program(s)
users of
the
data
query processor
security manager
concurrency manager
index manager
DDL:
data
definition
language
data
definition
processor
data
dictionary
data
system
configuration
languages
Data Independence
physical data independence
conceptual and external schema are defined
in terms of the data model,
rather than the actual data layout
ensures that conceptual and external schemas
are not affected by changes to the physical data
layout
Disadvantages of DBMS
The disadvantages of
summarized as follows:
the
database
approach
are
Data Associations
Entities, Attributes and Relations
Copyright @ www.bcanotes.com
Copyright @ www.bcanotes.com
loan- amount
number
Attribut
An entity ises
represented by a set of attributes, that is
descriptive
properties possessed by all members of
an entity set.
Example:
customer = (customer-id, customer-name,
customer-street, customer-city)
loan = (loan-number, amount)
Copyright @ www.bcanotes.com
Composite Attributes
Copyright @ www.bcanotes.com
Relationship Sets
A relationship is an association among several
entities
Example:
Hayes
depositor
A-102
customer entityrelationship setaccount entity
Example:
Copyright @ www.bcanotes.com
Copyright @ www.bcanotes.com
Copyright @ www.bcanotes.com
Mapping Cardinalities
Express the number of entities to which another
entity can be associated via a relationship set.
Most useful in describing binary relationship sets.
For a binary relationship set the mapping
cardinality must be one of the following types:
One to one
One to many
Many to one
Many to many
Copyright @ www.bcanotes.com
Mapping Cardinalities
One to one
One to many
Note: Some elements in A and B may not be mapped to any elements in the other set
Copyright @ www.bcanotes.com
Many to one
Many to many
Note: Some elements in A and B may not be mapped to any elements in the other set
Copyright @ www.bcanotes.com
Copyright @ www.bcanotes.com
E-R Diagrams
Copyright @ www.bcanotes.com
Roles
Entity sets of a relationship need not be distinct
The labels manager' and worker are called roles; they specify how
employee entities interact via the works-for relationship set.
Roles are indicated in E-R diagrams by labeling the lines that connect
diamonds to rectangles.
Role labels are optional, and are used to clarify semantics of the
relationship
Cardinality Constraints
We
relationship borrower
A loan is associated with at most one customer via borrower
One-To-Many Relationship
In the one-to-many relationship a loan is associated
with at most one customer via borrower, a customer
is associated with several (including 0) loans via
borrower
Many-To-One Relationships
In a many-to-one relationship a loan is associated with several
Many-To-Many Relationship
Copyright @ www.bcanotes.com
Keys
A super key of an entity set is a set of one or more
Copyright @ www.bcanotes.com
144DATABASEMODELS
A database model defines the logical design of data. The model also
describes the relationships between different parts of the data. In the
history of database design, three models have been in use: the
hierarchical model, the network model and the relational model.
1.File-Based Systems or Primitive Data Models:
Entities or objects of interest are represented by
records that are stored together in files.
Relationships between objects are represented by
using directories of various kinds.
2.Traditional Data Models: Most commonly used
traditional models are: hierarchical, network and
relational data model.
3.Semantic Data Models: this type models was
influenced by the semantic networks developed by
In the relational model, data is organized in twodimensional tables called relations. The tables or relations
are, however, related to each other.
14.5THERELATIONALDATABASEMODEL
Relations
14.97
146OPERATIONSONRELATIONS
Insert
The insert operation is a unary operationthat is, it is
applied to a single relation. The operation inserts a new
tuple into the relation. The insert operation uses the
following format:
14.101
Delete
The delete operation is also a unary operation. The operation
deletes a tuple defined by a criterion from the relation. The
delete operation uses the following format:
14.102
Update
14.103
Select
The select operation is a unary operation. The tuples (rows)
in the resulting relation are a subset of the tuples in the
original relation.
14.104
Project
The project operation is also a unary operation and creates
another relation. The attributes (columns) in the resulting
relation are a subset of the attributes in the original relation.
14.105
Join
The join operation is a binary operation that combines two
relations on common attributes.
Union
The union operation takes two relations with the same set of
attributes.
14.107
Intersection
14.108
Difference
14.109
147DATABASEDESIGN
14.110
In this step, the database designer creates an entityrelationship (E-R) diagram to show the entities for which
information needs to be stored and the relationship between
those entities. E-R diagrams uses several geometric shapes,
but we use only a few of them here:
Rectangles represent entity sets
Ellipses represent attributes
Diamonds represent relationship sets
Lines link attributes to entity sets and link entity sets to
relationships sets
14.111
Example 14.1
Figure 14.16 shows a very simple E-R diagram with three entity
sets, their attributes and the relationship between the entity sets.
14.113
Example 14.2
We can have three relations (tables), one for each entity set
defined in Figure 14.16, as shown in Figure 14.17.
14.115
Example 14.3
There are two relationship sets in Figure 14.16, teaches and takes,
each connected to two entity sets. The relations for these
relationship sets are added to the previous relations for the entity
set and shown in Figure 14.18.
Normalization
14.118
14.119
14.120
148OTHERDATABASEMODELS
14.121
Distributed databases
14.123
Object-oriented databases