You are on page 1of 81

Database Management

Systems

Md. Rakibul Hoque


University of Dhaka
Organizing Data in a Traditional
File Environment

• File organization Term and Concepts


• Computer system organizes data in a hierarchy
• Bit: Smallest unit of data; binary digit (0,1)
• Byte: Group of bits that represents a single
character
• Field: Group of characters as word(s) or
number
• Record: Group of related fields
• File: Group of records of same type
Organizing Data in a Traditional
File Environment

• File organization Term and Concepts


• Computer system organizes data in a hierarchy
• Database: Group of related files
• Entity: Person, place, thing on which we
store information.
• Attribute: Each characteristic, or quality,
describing entity
• E.g., Attributes Date or Grade belong to entity
COURSE
Organizing Data in a Traditional
File Environment
The Data Hierarchy
A computer system
organizes data in a
hierarchy that starts
with the bit, which
represents either a 0 or
a 1. Bits can be
grouped to form a byte
to represent one
character, number, or
symbol. Bytes can be
grouped to form a field,
and related fields can
be grouped to form a
record. Related records
can be collected to form
a file, and related files
can be organized into a
database.
Organizing Data in a Traditional
File Environment
Traditional File Processing

The use of a traditional approach to file processing encourages each


functional area in a corporation to develop specialized applications and files.
Each application requires a unique data file that is likely to be a subset of the
master file. These subsets of the master file lead to data redundancy and
inconsistency, processing inflexibility, and wasted storage resources.
Database Management
System
 A database management system
(DBMS) is a collection of
interrelated data and a set of
programs to access those data. The
collection of data, usually referred to
a database, contains information
relevant to an enterprise.
Database Management
System
 A database management system is a collection
of programs that enable users to create and
maintain a database.
-----Elmarsi & Navathe
 A database management system, or DBMS, is
a software designed to assist in maintaining
and utilizing large collections of data. ---------
Ramakrishnan & Gehrke
Database Systems Vs File
Systems ( Why DBMS?)
 Ordinary file system has a number of major
drawbacks:

1. Data redundancy and inconsistency-


Multiple file formats, duplication of information
in different files.
2.Difficulty in accessing data
- Need to write a new program to carry out
each new task
Database Systems Vs File
Systems ( Why DBMS?)
3.Data isolation
-Multiple files and formats
4.Integrity problems
- Integrity constraints (e.g. account balance >
0) become part of program code
- Hard to add new constraints or change
existing ones.
Database Systems Vs File
Systems ( Why DBMS?)

5. Atomicity problems
- Failures may leave database in an
inconsistent state with partial updates
carried out. E.g., transfer of funds from
one account to another should either
complete or not happen at all.
Database Systems Vs File
Systems ( Why DBMS?)
 6. Concurrent-access anomalies
- Needed for system performance and
usability
- Uncontrolled concurrent accesses can lead
to inconsistencies. E.g. two people reading
a balance and updating it at the same time.
Database Systems Vs File
Systems ( Why DBMS?)

7. Security problems: Not every user of


the database system should be able to
access all the data.

Database systems offer solutions to


all these problems
Some Commercial Database
Management Systems

 For Personal Computers

1. Microsoft Access
2. FoxPro
3. dBase
Some Commercial Database
Management Systems

1. Oracle
2. Microsoft SQL Server
3. IBM DB2/DB2UDB
4. Informix
5. Sybase
6. MySQL
7. Ingress
8. Postgre SQL
Goals/Purposes of DBMS
 The primary goal of a DBMS is to provide an
environment that is both convenient and efficient for
people to use in retrieving and storing information.
 Database systems are designed to manage large
bodies of information. Management of data
involves both defining structures for storage of
information and providing mechanisms for
manipulation of information.
Goals/Purposes of DBMS

 The database system must ensure


the safety and security of the
information stored, despite system
crashes or attempts at unauthorized
access.
 The system must avoid possible
anomalous results if data are to be
shared among several users.
Database System
Applications

Databases are widely used. Some representative


applications are:

1. Banking: For customer information, accounts,


loans and banking transactions.
2. Airlines/Railways/Road Transport: For ticket
reservation, schedules and routes.
Database System
Applications

3. Universities: For student information,


courses and grades (education
management).
4.Credit card transaction: For purchases
on credit card, monthly statement
generation
Database System
Applications

5.Telecommunication: For keeping


records of call made, generating
monthly bills, maintaining balances on
prepaid calling cards, storing
information about the communication
networks.
Database System
Applications

6.Finance: For storing information about


holdings, sales, and purchases of financial
instruments such as stocks and bonds.

7. Sales: For customer, product and


purchase information.
Database System
Applications
8. Manufacturing: For management of
supply chains and for tracking production
of items in factories, inventories of items
in warehouses/stores and order for items.

9. Human resources: For information


about employees, salaries, payroll taxes
and benefits and for generation of pay
checks.
View of Data

 A database system is a collection of


interrelated files and set of programs that
allow users to access and modify these
files. A major purpose of a database
system is to provide users an abstract
view of the data. That is, the system hides
certain details of how the data is stored
and maintained.
Data Abstraction

Several levels of data abstraction are


maintained to simplify users’
interaction with the system:

1. Physical level: The lowest level of


abstraction describes how data are
actually stored. It describes complex
low-level data structures in detail.
Data Abstraction

 2. Logical level: The next higher level


of abstraction describes what data
stored in database, and what
relationships exist among those data.
The logical level thus describes the
entire database in terms of a number
of relatively simple structures.
Data Abstraction

 For Example:
 create table customer (
customer_id varchar(10),
customer_name varchar
(35), customer_street
varchar (20),
salary number (10,2));
Data Abstraction
 3. View level: The highest level of
abstraction describes only part of the entire
database. Computer users see a set of
application programs that hide details of data
types. Several views of database are defined
and users see these views. In addition to
hiding details, the views also provide a
security mechanism to prevent users from
accessing certain part of the database.
Data Abstraction
Instances and Schemas

 Schema: The overall design of the


database is called the database
schema. Schemas are changed
infrequently, if at all. This corresponds
to the variable declaration (with type
definition) of a programming language.
Instances and Schemas

Schemas are:
1. Physical schema: Describes the database
design at physical level
2. Logical schema: Describes the database
design at logical level
3. View schema: Describes the database design
at view level
Instances and Schemas
Instances: Databases change over time as
information is inserted and deleted. The
collection of information stored in the
database at a particular moment is called an
instance of the database. While executing, each
variable of a programming language has a
particular value at a given instant. The values of
the variable in a program at a point in time
correspond to an instance of the database
schema.
Instances and Schemas

 Physical Data Independence – The ability to


modify the physical schema without changing
the logical schema is called physical data
independence.
- Applications depend on the logical schema (or
the view schema)
- In general, the interfaces between the various
levels and components should be well defined
so that changes in some parts do not seriously
influence others.
Data Models

 A data model is a collection of conceptual


tools for describing data, data relationship,
data semantics and consistency constraints.
A. Base Models: Describes the design of
the database at the logical level.
Data Models

 A. 1. Entity-Relationship Model: This


is a higher-level data model. It is
based on a perception of a real world
that consists of a collection of basic
objects, called entities and the
relationship among these objects.
Data Models

 Entity: An entity is a “thing” or “object”


in the real world that is distinguishable from
all other objects. An entity has a set of
properties, called attributes and the values
for some set of properties/attributes may
uniquely identify an entity. An entity may be
concrete, such as a person or a book, or it
may be abstract, such as loan, or a holiday,
or a concept.
Data Models

 customer- customer-id, customer-


name, customer-street, customer-city
 loan – loan-number, amount
Data Models

 Relationship: A relationship is an
association among several entities. A
depositor relationship associates a customer
with each account that he or she has.
The set of all entities of the same type and
the set of all relationships of the same type
are termed an entity set and relationship
set, respectively
Data Models
Data Models

A. 2. Relational Model: This is a


lower level model. It uses a collection
of tables to represent both data and
relationships among those data.

Each table has multiple columns, and


each column has a unique name.
Data Models

 The relational model is an example of a record-


based model. This is because the database is
structured in fixed-format records of several
types. Each table contains records of a particular
type. Each record type defines a fixed no. of
fields, or attributes. The columns of the table
correspond to the attributes of the record type.
Data Models

 The relational model is the most widely


used data model and a vast majority of
current database systems are based on
the relational model.
The relational model is at a lower level of
abstraction than the E-R model.
Database designs are often carried out
in the E-R model and then translated to
the relational model.
Data Models
Data Models

 B. Other Models:
B. 1. Object-oriented data model: Drawing
increasing attention. It can be seen as
extending of E-R model with notions of
encapsulation, methods (functions) and
object identity.
B. 2. Object-relational data model:
Combines the features of object-oriented
data model and relational data model.
Data Models

 B. 3. Semi-structured data model:


Permits the specification of data where
individual data items of the same type
may have different sets of attributes.
The extensible markup language
(XML) is widely used to represent
semi-structured data.
Data Models

 C. Historical Models: These are in


little use now.
C. 1. Network data model

C. 2. Hierarchical model
A Hierarchical Database for a Human Resources
System
Hierarchical and Network DBMS

Network DBMS:
• Depicts data logically as many-to-many
relationships

The Network Data Model


Database Languages
 SQL (Structured Query Language) – Widely used
database language
 Parts of SQL
Data-Definition Language (DDL): A database schema is
specified by a set of definitions expressed by a special
language called a data-definition language.
create table account (
account-number char(10),
balance integer)
Database Languages

 Data storage and definition


language:
- Special type of DDL language in
which the storage structure and
access methods used by the database
system are specified
- Usually an extension of the data
definition language.
Database Languages

 The data values stored in the database


must satisfy certain consistency
constraints. The DDL provides facilities
to specify such constraints. The
database systems checks these
constraints every time the database is
updated.
Database Languages

 As DDL creates schema of a table it


also updates a special set of tables
called data directory or data dictionary.
A data dictionary contains metadata
(data about data). A database system
consults the data dictionary before
reading or modifying actual data.
Database Languages
1. relation-metadata (relation-name, no-of-
attributes, storage-organization, location)
2. attribute-metadata (attribute-name, relation-
name, domain-type, position, length)
3. user-metadata (user-name, encrypted-
password, group)
4. index-metadata (index-name, relation-name,
index-type, index-attributes)
5. view-metadata (view-name, definition)
Database Languages

Data-Manipulation Language (DML):


DML is a language that enables users to
access or manipulate data as organized
by appropriate data model. Data
manipulation includes:
i) The retrieval of information stored in the
database
Database Languages

ii) The insertion of new information into


the database
iii) The deletion of information from the
database
iv) The modification of information stored
in the database
Database Languages

Two classes of DML


Procedural DMLs – user specifies
what data are required and how to get
or compute the data.
Nonprocedural DMLs (Declarative
DMLs) – user specifies what data are
required without specifying how to get
or compute the data.
Database Languages

 Declarative DMLs are usually easier to


learn and use than procedural DMLs.
However, since a user does not have
to specify how to get the data, the
database system has to figure out an
efficient means of accessing data. The
DML component of SQL is
nonprocedural.
Database Languages

 Other Parts of SQL:

1. View definition
2. Transaction control
3. Embedded SQL and dynamic SQL
4. Integrity definition
5. Authority definition
Database Languages

 Query: A query is a statement


requesting the retrieval of
information. The portion of a DML
that involves information retrieval
is called a query language.
Database Languages

 Example1. Find the name of the customer


with customer-id 192-83-7465
Select customer.customer-name
from customer
where customer.customer-id= ‘192-83-7465’
Database Languages
 Example2. Find the balances of all accounts
held by the customer with customer-id 192-83-
7465
 select account.balance
from depositor, account
where depositor.customer-id = ‘192-83-7465’
and
depositor.account-number = account.account-
number
Database Languages

 General format:

Select A1, A2, A3


from r1, r2, r3
where P
Database Users
Users are differentiated by the way they
expect to interact with the system. Four
different types:
1. Naive users – are unsophisticated users
who interact with the system by invoking
one of the permanent application programs
that have been written previously.
E.g. people accessing database over the
web, bank tellers, clerical staff
Database Users
 2. Application programmers – are computer
professionals who write application programs.
Application programmers can choose from
many tools to develop user interface.
 3. Sophisticated users – interact with the
system without writing programs. Instead,
they form their requests in a database query
language. Analysts who submits queries to
explore data in the database.
Database Users

 e.g., analyst looking at sales data


(OLAP – Online analytical processing),
data mining – finds certain kinds of
patterns in data.
Database Users

 4. Specialized users – are sophisticated


users who write specialized database
applications that do not fit into the
traditional data processing framework.
e.g., computer-aided design systems,
knowledge-base and expert systems and
environment-modeling systems – uses
complex data types.
Database Administrator
(DBA)
 Coordinates all the activities of the
database system; the database
administrator has a good understanding of
the enterprise’s information resources and
needs. DBA has central control of both data
and the programs that access that data.
Database Administrator
(DBA)
 The functions of Database administrator
(DBA) include:
_ Schema definition
_Storage structure and access method
definition
_Schema and physical-organization
modification
_Granting of authorization for data access
Database Administrator
(DBA)

_Specifying integrity constraints


_Acting as liaison with users
_Monitoring performance and
responding to changes in requirements
_Routine maintenance that includes:
Database Administrator
(DBA)

i) Periodically backing up the database to


prevent loss of data in case of disasters
ii) Ensuring that enough disk space is
available for normal operations and
upgrading disk space as required
iii)Monitoring jobs running on the
database and ensuring better
performance
Transaction Management

 A transaction is a collection of
operations that performs a single logical
function in a database application
_ e.g., deposit, withdrawal, transfer
between accounts

A – Atomicity, C – Consistency, I –
Isolation, D - Durability
Transaction Management

 Transaction-management component
ensures that the database remains in a
consistent (correct) state despite system
failures (e.g., power failures and
operating system crashes) and
transaction failures
_ e.g., system crash cannot wipe out
“committed” transactions
Transaction Management

 Concurrency-control manager
controls the interaction among the
concurrent transactions, to ensure the
consistency of the database
_ e.g., two users accessing the same
bank account cannot “corrupt” the
system or withdraw more than allowed
Database System Structure

 A database system is portioned into


modules that deal with each of the
responsibilities of the overall system.
The functional components of a
database system can be broadly
divided into the storage manager and
the query processor components.
Database System Structure
 The storage manager is important because
databases typically require a large amount of
storage space. Also, data are moved between
disk storage and main memory as needed.
Since the movement of data to and from disk
is slow relative to the speed of the CPU, it is
imperative that the database system structure
the data so as to minimize the need to move
data between disk and main memory.
Database System Structure

 The query processor is important


because it helps the database system
simplify and facilitate access to data. It
helps quick processing of updates and
queries.
Storage Manager

 A storage manager is a program


module that provides the interface
between the low-level data stored in
the database and the application
programs and queries submitted to
the system.
Storage Manager

 The storage manager is responsible to


the following tasks:
_interaction with the file manager (OS)
_efficient storage, retrieval and
updating of data
Storage Manager

 The storage manager components


include:
_ authorization/integrity manager
_ transaction manager
_ file manager
_ buffer manager
Storage Manager

 The storage manager stores:

_ data files (relations)


_ data dictionary (sometimes called
catalog)
_ indices
The Query Processor

 Components include:
1. DDL interpreter
2. DML compiler
3. Query evaluation engine
Thank
You

You might also like