You are on page 1of 39

Chapter 1: Introduction

Purpose of Database Systems


View of Data
Data Models
Data Definition Language
Data Manipulation Language
Transaction Management
Storage Management
Database Administrator
Database Users
Overall System Structure

Database System Concepts

1.1

Silberschatz, Korth and Sudarshan

Database Management System (DBMS)


Collection of interrelated data
Set of programs to access the data
DBMS contains information about a particular enterprise
DBMS provides an environment that is both convenient and efficient

to use.
Database Applications:

Banking: all transactions


Airlines: reservations, schedules
Universities: registration, grades
Sales: customers, products, purchases
Manufacturing: production, inventory, orders, supply chain
Human resources: employee records, salaries, tax deductions

Databases touch all aspects of our lives

Database System Concepts

1.2

Silberschatz, Korth and Sudarshan

Purpose of Database System


In the early days, database applications were built on top of file

systems

Drawbacks of using file systems to store data:


Data redundancy and inconsistency
Multiple file formats, duplication of information in different files

Difficulty in accessing data


Need to write a new program to carry out each new task

Data isolation multiple files and formats


Integrity problems
Integrity constraints

program code

(e.g. account balance > 0) become part of

Hard to add new constraints or change existing ones

Database System Concepts

1.3

Silberschatz, Korth and Sudarshan

Purpose of Database Systems (Cont.)


Drawbacks of using file systems (cont.)
Atomicity of updates
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

Concurrent access by multiple users


Concurrent accessed needed for performance
Uncontrolled concurrent accesses can lead to inconsistencies

E.g. two people reading a balance and updating it at the same


time

Security problems
Database systems offer solutions to all the above problems

Database System Concepts

1.4

Silberschatz, Korth and Sudarshan

Levels of Abstraction
A database system is a collection of interrelated files and a set of

programs that allow users to access and modify these files.

A major purpose of a database system is to provide users with an

abstract view of the data.

Since

many database-systems users are not computer trained,


developers hide the complexity from users through several levels of
abstraction, to simplify users interactions with the system

An architecture for a database system

Database System Concepts

1.5

Silberschatz, Korth and Sudarshan

Levels of Abstraction Contd..


Physical level
lowest level of abstraction

describes how a record (e.g., customer) is stored.


describes complex low-level data structures
Database administrators may be aware of certain details of the physical
organization of the data.
Logical level:
next-higher level of abstraction

describes what data stored in database, and the relationships among the
data.
Database administrators, use the logical level of abstraction
who must decide what information to keep in the database
Programmers using a programming language, database administrators
work at this level

Database System Concepts

1.6

Silberschatz, Korth and Sudarshan

View of Data
View level
highest level of abstraction
Many users of the database system do not entire database
Simplify users interaction with the system.
The system may provide many views for the same database.
Prevent users from accessing certain parts of the database.
Example:
type customer = record
name : string;
street : string;
city : integer;
end;

Database System Concepts

1.7

Silberschatz, Korth and Sudarshan

Instances and Schemas


Schema
The overall design of the database is called the database schema the logical structure of

the database
Schemas are changed infrequently, if at all

Physical schema: database design at the physical level


Logical schema: database design at the logical level
Subschema : database design at the view level
Instance
The collection of information stored in the database at a particular moment is called an
instance of the database.
Database changes over time, it is the actual content of the database at a particular point
in time
Analogy
program written in a programming language
A database schema corresponds to the variable declarations
The values of the variables in a program at a point in time correspond to an instanceof

a database schema
Database System Concepts

1.8

Silberschatz, Korth and Sudarshan

Data Independence
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.
Physical Data Independence
The ability to change the physical schema without changing the logical schema
For example, a change to the internal schema, such as using different file organization

or storage structures, storage devices, or indexing strategy, should be possible without


having to change the conceptual or external schemas
Logical data independence
The ability to change the logical (conceptual) schema without changing the External

schema (User View)


For example, the addition or removal of new entities, attributes, or relationships to the

conceptual schema should be possible without having to change existing external


schemas or having to rewrite existing application programs.
View level data independence
always independent no effect, because there doesn't exist any other level above view

level

Database System Concepts

1.9

Silberschatz, Korth and Sudarshan

Data Models
A collection of tools for describing

data
data relationships
data semantics
data constraints
Entity-Relationship model
Relational model
Other models:
object-oriented model
Object-relational data models
Older models: network model and hierarchical model (Class
notes)

Database System Concepts

1.10

Silberschatz, Korth and Sudarshan

CATEGORIES OF DATA MODELS

Basically, there are two categories of data models:-

Object Based Logical Models.


Record Based Logical Models.

Database System Concepts

1.11

Silberschatz, Korth and Sudarshan

Entity Relationship Model


The entity-relationship (E-R) data model is based on a perception

of a real world that consists of a collection of basic objects, called


entities, and of relationships among these objects.

An entity is a thing or object in the real world that is


distinguishable from other objects.

For example, each person is an entity, and bank accounts can be

considered as entities.
Entities are described in a database by a set of attributes.
A relationship is an association among several entities.
For example, a depositor relationship associates a customer with

each account.
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
Database System Concepts

1.12

Silberschatz, Korth and Sudarshan

Entity Relationship Model


Account entity set : the attributes account-number and balance
Customer entity set : attributes customer-name, customer-street

address and customer-city


Mapping cardinalities: which express the number of entities to

which another entity can be associated via a relationship set.

Database System Concepts

1.13

Silberschatz, Korth and Sudarshan

Entity-Relationship Model
Example of schema in the entity-relationship model

Database System Concepts

1.14

Silberschatz, Korth and Sudarshan

Object-Oriented Model
Like the E-R Model, this model also models a database as a Collection of Objects.
An Object Body encapsulates Data (Variables) as well as Methods (Functions) to
manipulate the Data (Variables).
The Objects that contain same Type of Data Variables and same Type of Functions are
grouped together as a Class.
Thus, a Class may be viewed as a Type Definition of the Objects.
The only way an Object A can access the Data Items of another Object B is by
invoking the Methods of B.
A can accomplish this by making calls to the methods of B, through Bs Interface.
The methods defined within an object are made visible to the external world, through
its Interface.

Database System Concepts

1.15

Silberschatz, Korth and Sudarshan

Relational Model
The relational model uses a collection of tables to represent both data

and the relationships among those data.


Each Table is called a Relation, which is assigned a unique name.
Each relation has a number of Columns, representing the Fields (or

Attributes) of the relation


Each column has a unique name
A Relation can be viewed as a set of Tuples of the same type.
The relationships amongst the tables will be modeled as Foreign Key-

Primary Key Relationships.


The Relational Model has become extremely popular because: It is extremely simple and easy to implement.
It has a strong mathematical foundation.
It has been highly standardized.
Database System Concepts

1.16

Silberschatz, Korth and Sudarshan

A Sample Relational Database

Database System Concepts

1.17

Silberschatz, Korth and Sudarshan

Problem to solve
The Course-Student-Teacher Database Schema in Relational Model will be represented
by six Tablesthree tables to represent entities i.e. STUDENT (giving details of all students), TEACHER
(giving details of all teachers), COURSE (giving details of all courses); and three tables to
represent relationships i.e. COURSE-TEACHER (indicating relationships OFFERED BY
and OFFERS), COURSE-STUDENT (indicating relationships ATTENDS and ATTENDED
BY) and TEACHER-STUDENT (indicating relationships TAUGHT BY and TEACHES).

Database System Concepts

1.18

Silberschatz, Korth and Sudarshan

Database System Concepts

1.19

Silberschatz, Korth and Sudarshan

Introduction
1. Database is collection of ____.
A None of these
B Programs
C Data
D Modules

2 __________________ is collection of interrelated data and set of


program to access them.
A Programming language
B Database
C Database Management System
D Data Structure

Database System Concepts

1.20

Silberschatz, Korth and Sudarshan

3. DBMS should provide following feature(s) ______.


A Safety of the information stored
B Authorized access
C All of these
D Protect data from system crash

4. Which of the following is considered as DBMS ?


A Access
B Foxpro
C All of these
D Oracle

5. Before use of DBMS information was stored using __________.


A File Management System
B Data System
C Cloud Storage
D None of these
Database System Concepts

1.21

Silberschatz, Korth and Sudarshan

Disadvantages of File
Question 1 Duplication of data at several places is called as
_______________.
A Data Redundancy
B Atomicity Problem
C Data Inconsistency
D Data Isolation
Question 2 Data Redundancy increases the cost of storing and

retrieving data.

A False
B True

Database System Concepts

1.22

Silberschatz, Korth and Sudarshan

Question 3: Suppose user have Saving Account and Checking


Account in the Bank. Saving Account Stores following
information - account-no name address mobile and Checking
Account stores - account-no name address mobile Which of the
information is not redundant.
A address
B mobile
C name
D account-no

Question 4 : If in redundant file common fields are not matching


then it results in _____________.
A Data Inconsistency
B Data Integrity Problem
C Data Isolation
D Data Redundancy

Question 5 : It is difficult to access conventional file system than


Database System.
A False B True
Database System Concepts

1.23

Silberschatz, Korth and Sudarshan

Levels of Abstraction
1. A main purpose of DBMS is to provide ____________ view of data
to user.
A Partial
B Complete
C None of these
D Abstract

2. ____________ means to hide certain details of how data is stored


and maintain.
A Data Abstraction
B Data Integrity
C Data Isolation
D None of these

Database System Concepts

1.24

Silberschatz, Korth and Sudarshan

3. There are _________ levels of data abstraction.


A3
B1
C4
D2

4. In data abstraction which is lowest level of abstraction ?


A None of these
B Conceptual Level
C View Level
D Physical Level

5. _______ of abstraction explains how data is actually stored and


describes the Data Structure and Access methods used by
database.
A View Level
B Physical Level
C Conceptual Level
Database System Concepts

1.25

Silberschatz, Korth and Sudarshan

Data Model
Question 1: Data Model is collection of conceptual tools for
describing A Data
B All of these
C Consistency Constaints
D Data Schema

Question 2
Data Models in DBMS are classified into ______ categories.
A4
B3
C5
D2

Database System Concepts

1.26

Silberschatz, Korth and Sudarshan

Question 3 Object based logical model(s) are used to describe data


A None of these
B View Level
C Physical Level
D Logical Level
Question 4 Which of the following is example of Object based logical

model ?

A Relational Model
B Hierarchical Model
C Entity Relationship Model
D Network Model
Question 5
Entity Relationship model consists of collection of basic objects called

_________ and relationship among these objects.

A entities
B models
C None of these
D functions
Database System Concepts

1.27

Silberschatz, Korth and Sudarshan

Instances & Schema


Question 1 Collection of information stored in database at particular

instance of time is called as __________.

A Instance of Database
B Database Schema
C Objects in Database
D Data Structure
Question 2 Overall design of the database is called as _________.
A None of these
B Database Instance
C Database Abstraction
D Database Schema

Database System Concepts

1.28

Silberschatz, Korth and Sudarshan

Question 3 Database supports _______ types of database schema's.


A3
B1
C2
D4
Question 4 Which of the following are valid types of Database Schema's ?
A Physical and Logical Schema
B Logical Schema
C Practical Schema
D Physical Schema
E Physical and Practical Schema
Question 5 Which of the following schema is present at highest level
A Physical Schema
B None of these
C Sub-Schema
D Logical Schema
Database System Concepts

1.29

Silberschatz, Korth and Sudarshan

Data Definition Language (DDL)


A database schema is specified by a set of definitions expressed in DDL. Data

Definition Language (DDL) is a standard for commands that define the different
structures in a database.
E.g.

create table account (


account-number char(10),
balance
integer)

DDL compiler generates a set of tables stored in a file called data dictionary or

data directory.
DDL statements create, modify, and remove database objects such as tables,

indexes, and users


Common DDL statements are CREATE, ALTER, and DROP.
This data stored in Data Dictionary is called Metadata (i.e., data about data)
Data storage and definition language
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 System Concepts

1.30

Silberschatz, Korth and Sudarshan

Data Manipulation Language (DML)


A data-manipulation language (DML)is a language that enables users to access

or manipulate data as organized by the appropriate data model.


DML also known as query language
Data manipulation is
The retrieval of information stored in the database (SELECT)

The insertion of new information into the database (INSERT)


The deletion of information from the database (DELETE)
The modification of information stored in the database (UPDATE)
There are basically two types of DML:

Procedural user specifies what data is required and how to get those data
Nonprocedural user specifies what data is required without specifying how
to get those data
SQL is the most widely used query language

Database System Concepts

1.31

Silberschatz, Korth and Sudarshan

SQL
SQL: widely used non-procedural language
E.g. 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
E.g. 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
Application programs generally access databases through one of
Language extensions to allow embedded SQL

Application program interface (e.g. ODBC/JDBC) which allow SQL queries to


be sent to a database

Database System Concepts

1.32

Silberschatz, Korth and Sudarshan

Overall Database Structure


In a Database System, the OS provides the basic services and DBMS is

built on that base. The functional components of a database system can


be broadly divided into: Query Processor Components.
Storage Manager Components.
Query Processor Components.

These include:-

(i) DML Compiler. It translates DML statements into low-level

instructions that are understood by the Query Evaluation Engine. Also,


the compiler optimizes the DML Queries, for efficient execution by the
Query Evaluation Engine. One of the inputs for Query Optimization is
the statistics gathered from the execution of previous queries. Such
statistics are kept in the Data Dictionary.

Database System Concepts

1.33

Silberschatz, Korth and Sudarshan

Database Users
Users are differentiated by the way they expect to interact with the system
Application programmers interact with system through DML calls
Sophisticated users form requests in a database query language
Specialized users write specialized database applications that do not fit

into the traditional data processing framework


Nave users invoke one of the permanent application programs that have

been written previously


E.g. people accessing database over the web, bank tellers, clerical staff

Database System Concepts

1.34

Silberschatz, Korth and Sudarshan

Database Administrator

Coordinates all the activities of the database system; the

database administrator has a good understanding of the


enterprises information resources and needs.

Database administrator's duties include:

Database System Concepts

Schema definition
Storage structure and access method definition
Schema and physical organization modification
Granting user authority to access the database
Specifying integrity constraints
Acting as liaison with users
Monitoring performance and responding to changes in
requirements

1.35

Silberschatz, Korth and Sudarshan

Transaction Management
A transaction is a collection of operations that performs a single

logical function in a database application

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.

Concurrency-control manager controls the interaction among the

concurrent transactions, to ensure the consistency of the


database.

Database System Concepts

1.36

Silberschatz, Korth and Sudarshan

Storage Management
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.

The storage manager is responsible to the following tasks:

interaction with the file manager


efficient storing, retrieving and updating of data

Database System Concepts

1.37

Silberschatz, Korth and Sudarshan

Overall System Structure

Database System Concepts

1.38

Silberschatz, Korth and Sudarshan

Application Architectures

Two-tier architecture: E.g. client programs using ODBC/JDBC to


communicate with a database
Three-tier architecture: E.g. web-based applications, and
applications built using middleware

Database System Concepts

1.39

Silberschatz, Korth and Sudarshan