Sie sind auf Seite 1von 68

DATABASE MANAGEMENT

SYSTEM
(DBMS)

MBA-12 Batch (2015-17)

DBMS
Two methods are used for organizing
data:
File-oriented approach
Database-oriented approach

MBA-12 Batch (2015-17)

File-oriented approach
Traditional method of organizing
data.
Application data are organized into
one or more files and the application
program processes data stored in
these files to generate output.

MBA-12 Batch (2015-17)

Limitations of file-oriented
approach
Data Redundancy & Inconsistency
Difficulty in accessing data
Data Isolation
Integrity Problems
Atomicity Problem
Concurrent-access anomalies
Security Problems
MBA-12 Batch (2015-17)

Data Redundancy &


Inconsistency
Data Redundancy - same information or records
may be duplicated in several files.
Ex. A person is having savings account and
current
account.
Suppose
address
and
telephone number is present in savings account
details and if the same thing is present in
current account details, then it is duplication of
information which leads to higher storage and
access cost.
Data Inconsistency - copies of the same data
may no longer agree.
MBA-12 Batch (2015-17)

Difficulty in accessing data


Data those are needed can not be
retrieved in a convenient and
efficient manner.

MBA-12 Batch (2015-17)

Data Isolation
Data are scattered in various files
and files may be in different formats.
So that to write new application
program to retrieve the appropriate
data is difficult.

MBA-12 Batch (2015-17)

Integrity Problems
The data values stored in the database must
satisfy
certain
types
of
consistency
constraints.
Ex. The balance of customer account may
never fall below a minimum amount. So the
application programmer must enforce certain
constraints in the system by adding appropriate
code in various application programs. When
new constraints are added, it is difficult to
change the programs to enforce them. Then the
problem is compounded when constraints
involve several data items from different files.
MBA-12 Batch (2015-17)

Atomicity Problem
It is crucial to ensure that once a
failure has been detected, data are
restored to the consistent state that
existed prior to the failure.

MBA-12 Batch (2015-17)

Concurrent-access anomalies
Multiple users can not update data
simultaneously
leads
data
inconsistency.

MBA-12 Batch (2015-17)

Security Problems
Every user of the system can not able to
access all data.
Ex. In a banking system, the payroll
personnel can see only the part of the
system that has information about various
bank employees. But they do not access
information about customer accounts. Since
application programs are added to the
system in an ad hoc manner, it is difficult to
enforce such security constraints.
MBA-12 Batch (2015-17)

Database-oriented approach
Database Management (DBMS) consists of
interrelated data and a set of programs to
retrieve/ access those data.
The collection of data is called as
database which contains information
relevant to an enterprise.

MBA-12 Batch (2015-17)

Purpose of DBMS
To provide an environment that is both
convenient and efficient to use in retrieving
and storing database information.
The management of data involves the definition
of structures for data storage and the provision
for the manipulation of data.
It also ensures system security which prevents
data loss due to system failure and unauthorized
access.
MBA-12 Batch (2015-17)

Components of DBMS
Four major components. Such are:
1) Data: Data stored in a system is partitioned
into one or more databases.
- Database can be either integrated or shared.
An integrated db is a collection of related
tables/relations.
A shared db is the data in a table can be used
by other tables in the db.
MBA-12 Batch (2015-17)

Contd
2)

Hardware:

This
consists
of
secondary storage devices (i.e. disks and
drums) where the db resides. Other
associated devices and control unit also
forms a part of the hardware.

MBA-12 Batch (2015-17)

Contd
3) Software: Between the physical db, where
the data actually stored and the users there is a
layer, called DBMS.
All requests from users for accessing the db are
handled by DBMS. The requests include adding
and removing, retrieving and updating data in
tables. Here DBMS serves as an interface
between the users and the hardware.
MBA-12 Batch (2015-17)

Contd
4) Users: Users are classified into 3 groups.
a) Application Programmers: responsible
for writing application programs. The
application
programs
are
written
in
languages such as COBOL, C, Pascal etc.
These programs retrieve existing information,
insert new information and delete or update
existing information in the db.
b) End Users: responsible for interacting
with DBMS through computer terminals.
For example: End users use SQL for
interacting with DBMS.
MBA-12 Batch (2015-17)

Components of DBMS (contd.)


c)
Database
Administrators
(DBAs):
responsible for providing necessary technical
support for implementing the strategic and
policy decisions related to data in the database.
-They are responsible for creating the actual db.
-They are also responsible for ensuring that the
system performance is optimized.
-They are responsible for the backup and
recovery of a db.
MBA-12 Batch (2015-17)

Applications of DBMS
Banking for customer information, accounts, loans and various
banking
transaction.
Airlines for reservation and schedule information.
Universities for student information and registration.
Credit card Transaction for purchases on credit cards.
Telecommunication for keeping records of calls made, generation
of monthly bills, maintaining balances on prepaid calling SIM
cards.
Finance for storing information about sales purchases, etc.
Human Resource Management for information about employees,
salaries and other benefits and fetch information for generating
cheques.
MBA-12 Batch (2015-17)

Characteristics of DBMS
A db provides fast and easy access to data.
Data Integrity: is the ability to correctly and
consistently navigate and manipulate tables in a
db.
Data Independence: refers to the storage of data
in such a way that it is not affected by modification
in data structure or changes in the application
program. Data Independence are of two types:
Physical Data Independence
Logical Data Independence
MBA-12 Batch (2015-17)

Contd
Prevent Data Redundancy and Inconsistency
Sharing of data: Different users should be able to
access the data from the db at the same time.
Data Security: To ensure safety, data stored in
databases should be made accessible only to
authorized users. Regular back up procedure is
required to minimize data loss due to system
failure.

Data Maintenance: procedures should be


followed for adding, updating and deleting records
from db.
MBA-12 Batch (2015-17)

Contd
-

Regulate
Standards:
In
most
organizations, databases are centralized,
i.e. all data stored in a central location.
DBAs regulate the standards for accessing
databases.

MBA-12 Batch (2015-17)

Disadvantages of DBMS
Increased
becomes

Complexity:

extremely

complex

multi

user

DBMS

software

due

to

its

expected functionality. So it is necessary for database


designers,

developers,

DBAs

and

end-users

to

understand the functionalities of the complex software.

Requirement of specialized and skilled


manpower: Due to rapid changes in database
technology and organizations business needs, the
organizations need to hire specialized manpower or
train their existing manpower on regular basis to design
and implement databases.
MBA-12 Batch (2015-17)

Contd
Increased installation and
management costs
Need for explicit backup and recovery

MBA-12 Batch (2015-17)

Instance & Schema


The collection of information stored in
the database at a particular moment is
called an instance of the database.
The overall design of the database is
called as the schema.
Database schema corresponds to the
variable declarations (along with
associated type definition) in a
program.
MBA-12 Batch (2015-17)

Instance & Schema (contd.)


Each variable has a particular value at a given
time, so the values of the variables in a program
at a point in time corresponds to an instance of
the database schema.
Database has several schemas partitioned
according to the levels of abstraction. The
physical schema describes the database design
at the physical level; the logical schema
describes the database design at the logical
level and the database may also have several
schemas at the view level, called as subschema.
MBA-12 Batch (2015-17)

Levels of Abstraction/Views of
data in the database
The major purpose of DBMS is to
provide users with an abstract view
of data. So the system hides certain
details of how the data are being
stored and maintained inside the
DBMS.
Basically there are 3 levels of
abstraction. Such are:
MBA-12 Batch (2015-17)

View Level
View1

View2

View3

View n

Logical Level

Physical Level

(Figure: Three levels of data abstraction)

MBA-12 Batch (2015-17)

Physical Level: This is the lowest level


of abstraction and describes how the
data are actually stored. The physical
level describes complex low-level data
structures in details.
Logical Level: This is the next higher
level of abstraction describes what data
are stored in the database and what
relationships exist among those data.
MBA-12 Batch (2015-17)

View Level: This is the highest level


of abstraction, describes only part of
the entire database. Many users of
database system do not need all
information; instead they need to
access only a part of the database.
This level exists to simplify users
interactions with the system. So the
DBMS provides many views for same
database.
MBA-12 Batch (2015-17)

Data Independence
The ability to modify a schema
definition in one level without
affecting a schema definition in the
next higher level is called data
independence.

MBA-12 Batch (2015-17)

Data Independence (contd.)


There are 2 levels of data independence:
- Physical data independence: is the
ability to modify the physical schema without
causing
application
programs
to
be
rewritten.
-Logical data independence: is the ability
to modify the logical schema without causing
application programs to be rewritten.
MBA-12 Batch (2015-17)

Data Independence (contd.)


Logical data independence is more
difficult to achieve than physical data
independence,
since
application
programs are heavily dependent on
the logical structure of the data.

MBA-12 Batch (2015-17)

Data Models
A model is an abstraction process that
concentrates (highlights) on essential and
inherent aspects of the organizational
applications
and
ignores
(hides)
superfluous/accidental details.
A model is a representation of real-world
objects or events & their associations.
A data model (also called as Database
Model) is a mechanism which provides
abstraction for the database applications.
MBA-12 Batch (2015-17)

Data Models (contd.)


A data model is a conceptual method of
structuring data. It provides mechanism
to structure data (consist a set of rules
according to which databases can be
constructed),
allow
a
set
of
manipulative operations (i.e. updating
and retrieving data from database) and
enforce set of constraints (integrity
rules) to ensure accuracy of data.
MBA-12 Batch (2015-17)

Data Models (contd.)


A data model provides a way to
describe the design of a database at
the physical, logical and view level.
Data Models are broadly classified
into 3 categories:- Record-based data models
- Object-based data models
- Physical data models
MBA-12 Batch (2015-17)

Record-based data models


Used to specify the overall logical structure of
the database.
In this model, database consists of fixedformat records of different types. Each record
type defines a fixed number of fields/attributes
and each field is of fixed length.
Data integrity constraints cannot be explicitly
specified.
The 3 principal types of record-based models
are:a) Hierarchical data model
b) Network data model
c) Relational data model
MBA-12 Batch (2015-17)

Object-based data models


- Used to describe data & their relationships.
- It uses concepts like entities, attributes and
relationships.
- It has flexible data structuring capabilities.
- Data integrity constraints can be explicitly specified.
- Following are common types of object-based data
models:a) Entity-Relationship model
b) Semantic model
c) Functional model
d) Object-oriented model
MBA-12 Batch (2015-17)

Physical data models


Used to describe data at lowest level.
These models describe how data are
stored, record orderings and access
paths.
The most common physical data
models are:a) Unifying model
b) Frame-memory model
MBA-12 Batch (2015-17)

Relational Model:
The
Relational
model
uses
a
collection of tables to represent both
data and the relationships among
those data. Each table has multiple
columns and each column has a
unique name.

MBA-12 Batch (2015-17)

Network Model:
Data in the network model are
represented by collection of records
and relationships among data are
represented by links, which can be
viewed as pointers. The records in
the database are organized as
collections of arbitrary graphs.

MBA-12 Batch (2015-17)

Hierarchical Model:
The hierarchical model is similar to
the network model in the sense that
data and relationships among data
are represented by records and links
respectively. It differs from network
model in that the records are
organized as collections of trees
rather than arbitrary graphs.

MBA-12 Batch (2015-17)

Object-Oriented Model:
Object-Oriented
model
is
based
on
collection of objects. An object contains
values stored in instance variables within
the object. An object also contains codes
(also called as Method) that operate on the
object. Objects those contain same types of
values and same methods are grouped
together into classes. A class may be
viewed as a type definition for objects. One
object can access the data of another object
is by invoking method of other object and
this action is called as message passing.
MBA-12 Batch (2015-17)

Each object has unique identity,


independent of the values that it
contains. Thus two objects containing
the same values are nevertheless
distinct. The distinction among
individual objects is maintained in
the physical level through the
assignment
of
distinct
object
identifiers.

MBA-12 Batch (2015-17)

Object-Relational Model:
The Object-Oriented models are
converted into relations and named
as Object-relational models.

MBA-12 Batch (2015-17)

E-R Modeling
A database can be modeled as:
a collection of entities,
relationship among entities.

An entity is an object that exists and is


distinguishable from other objects.
Example: specific person, company, event,
plant
Entities have attributes
Example: people have names and addresses

An entity set is a set of entities of the same type


that share the same properties.
Example: set of all persons, companies, trees, holidays
MBA-12 Batch (2015-17)

Entity Sets Customer and Loan


Customer
_id

Customer Customer Customer


_Street
_City
_name

MBA-12 Batch (2015-17)

Loan_
no

Amount

Relationship Sets
A relationship is an association among several
entities
Example:
Hayes
depositor
A-102
customer entity relationship set account entity
A relationship set is a relationships of the same
type and a mathematical relation among n 2
entities, each taken from entity sets
{(e1, e2, en) | e1 E1, e2 E2, , en En}
where (e1, e2, , en) is a relationship
Example:
(Hayes, A -102) depositor
MBA-12 Batch (2015-17)

Relationship Set borrower

MBA-12 Batch (2015-17)

Relationship Sets (Contd.)


An attribute can also be property of a relationship set.
For instance, the depositor relationship set between
entity sets customer and account may have the
attribute
access-date.

MBA-12 Batch (2015-17)

Degree of a Relationship Set


Refers to number of entity sets that participate in a
relationship set.
Relationship sets that involve two entity sets are
binary (or degree two). Generally, most relationship
sets in a database system are binary.
Relationship sets may involve more than two entity
sets.
Example: Suppose employees of a bank may have jobs
(responsibilities) at multiple branches, with different jobs at
different branches. Then there is a ternary relationship set
between entity sets employee, job, and branch

Relationships between more than two entity sets are


rare. Most relationships are binary.
MBA-12 Batch (2015-17)

Attributes
An entity is 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 )
Domain the set of permitted values for each attribute.
Attribute types:
Simple and composite attributes.
Single-valued and multi-valued attributes

Example: multivalued attribute: phone_numbers

Derived attributes and Stored or Base attributes


Can be computed from other attributes
Example: age, given date_of_birth
MBA-12 Batch (2015-17)

Composite Attributes

MBA-12 Batch (2015-17)

Constraints
(A) Mapping Cardinality
Constraints

Express the number of entities to which another


entity can be associated via a relationship set.
Most useful in describing binary relationship
sets.
For any relationship set the mapping cardinality
must be one of the following types:

One to one
One to many
Many to one
Many to many
MBA-12 Batch (2015-17)

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
MBA-12 Batch (2015-17)

Mapping Cardinalities

Many to Many
Many to One
Note: Some elements in A and B may not be mapped to any
MBA-12 Batch (2015-17)
elements in the other set

Mapping Cardinalities
For a binary relationship set the
mapping cardinality must be one of
the following types:
One to one
One to many
Many to many

MBA-12 Batch (2015-17)

(B) Keys
Key is used to uniquely identify a
record.
Keys allow us to identify a set of
attributes that suffice to distinguish
entities from each other.
Keys are also help to uniquely
identify relationships.
MBA-12 Batch (2015-17)

Keys (contd.)
A super key of an entity set is a set of one or more attributes
whose values uniquely determine each entity.
Ex. Customer_id attribute of Customer entity set is sufficient to
distinguish one Customer entity from another. Thus
Customer_id is a super key for the entity Customer.
Similarly, the combination of Customer_id & Customer_name is
a super key for the entity Customer. But the Customer_name
attribute can not be a super key because many customers may
have same name.
A candidate key of an entity set is a minimal super key.
Candidate keys are proper subset of super keys.

{Customer_id } and {Customer_add, Customer_street } are


candidate keys of customer entity. But { Customer_id,
Customer_name} does not form a candidate key because
{ Customer_id } is alone a candidate key.
account_number is candidate key of account

Although several candidate keys may exist, one of the


candidate keys is selected
to be the primary key.
MBA-12 Batch (2015-17)

Keys for Relationship Sets


The combination of primary keys of the participating
entity sets forms a super key of a relationship set.
(customer_id, account_number) is the super key of depositor
relation
NOTE: this means a pair of entity sets can have at most one
relationship in a particular relationship set.
Example: if we wish to track all access_dates to each account by
each customer, we cannot assume a relationship for each access.
We can use a multivalued attribute though.

Must consider the mapping cardinality of the


relationship set when deciding what are the candidate
keys
Need to consider semantics of relationship set in
selecting the primary key in case of more than one
candidate key
MBA-12 Batch (2015-17)

E-R Diagrams

Rectangles represent entity sets.


Diamonds represent relationship sets.
Lines link attributes to entity sets and entity sets to
relationship sets.
Ellipses represent attributes
- Double ellipses represent multivalued attributes.
- Dashed ellipses denote derived attributes.
MBA-12 Batch (2015-17)

Underline indicates primary key attributes

E-R Diagram With Composite,


Multivalued and Derived
Attributes

MBA-12 Batch (2015-17)

Relationship Set with


Attributes

MBA-12 Batch (2015-17)

Integrity Constraints
Constraints are the rules or conditions which can be defined on the
specified column in order to prevent the entry of invalid data.
Integrity Constraints ensure that changes made to the database
by authorized users do not result in a loss of data consistency.
Therefore integrity constraints guard against accidental damage to
the
database.
Some preliminary examples of integrity constraints are:
- An account balance cannot be null.
- No two accounts can have the same account number.

Basically constraints are classified into 3 categories.

1.Domain integrity constraint [not null, check]


2. Entity integrity constraints [unique, primary
key]
3. Referential integrity constraints [foreign key]
MBA-12 Batch (2015-17)

Contd
not null: It does not support null values in
specified column.
Ex: ename varchar(20) not null
check: The check clause is used to ensure that
attribute values satisfy specific condition for the
whole tuples present in the relation.
Ex: create table branch
(branch_name varchar2(15),
branch_city varchar2(30),
assets numeric(16,2),
check (assets>=0)));
unique: It does not allow duplicate values in
specified column and it allows single null value.
MBA-12 Batch (2015-17)

Contd
Primary key: This is same as the
unique constraint which is used to
prevent duplicate values and also it
does not support null values.
Ex: create table customer
(customer_id integer,
customer_name char(20),
customer_city char(30),
primary key (customer_id));
MBA-12 Batch (2015-17)

Contd
Foreign key: This constraint is used for establishing the
relation between two tables and that relation is called as
parent-child relation. The foreign key constraint is
defined in the child table and is associated with the
primary key or unique key attribute of the parent table.

Foreign key supports null and duplicate values.

MBA-12 Batch (2015-17)

Ex: Foreign Key


CREATE TABLE Person
(PId int PRIMARY KEY,
FName varchar2(10),
LName varchar2(10),
Address varchar2(15));
CREATE TABLE Orders
(OId int PRIMARY KEY,
Qty int NOT NULL,
PId int FOREIGN KEY REFERENCES Persons
(PId));
MBA-12 Batch (2015-17)

Das könnte Ihnen auch gefallen