You are on page 1of 47

Database Management Systems

neha.bharill@mahindrauniversity.edu.in
Course Code: CS/AI 3103

August 18, 2022

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 1 / 47


Course Contents

UNIT:1-Introduction to File and Database Systems.

UNIT:1-Data Modelling Using ER Model.

UNIT:2-Relational Models SQL

UNIT:3-Functional Dependencies and Normalization for Relational Datab


Design.

UNIT:4-Transaction Management, Concurrency Control, Recovery Man-


agement.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 2 / 47


Books

Elmasri, Ramez, Shamkant B. Navathe, Fundamentals of Database


Systems, Pearson Education, 5th Ed., 2007.

Korth H F and A Silberschatz, Database System Concepts, MGHISE,


3rd Ed., 1997.

Ivan Bayross, SQL, PL/SQL the Programming Language of Oracle,


BPB Publications, 4th Ed., 2010.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 3 / 47


Evaluation Scheme

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 4 / 47


Unit I
Lecture Session-1

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 5 / 47


Introduction to DBMS

Content
Basic Concepts of Database Systems.

Database Management System.

Functions of DBMS.

Traditional File System for Storing Data.

Advantages of DBMS over traditional file systems.

Disadvantage of Database System.

Popular Database Vendors and Products.

Application of Database System.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 6 / 47


Basic Concepts of Database Systems
DATA
Known fact that can be recorded and that has implicit meaning. This data can be stored
in a file on a computer. Data can exists in a variety of forms like text, number or both
(text, number).
Ex. Name, Tel.no, city etc.

Database
Is a logically coherent collection of data with some inherent meaning. It consists of four
elements:
Data
Relationship: Correspondence between the various data elements.
Constraints: Defines correct database status.
Schema: The overall design of the database.

Figure: Components of a Database


Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 7 / 47
Database Management System
A database management system is a collection of programs that enables user to stores data in
such a way that it becomes easier to retrieve, manipulate, and produce information.

A database system consist of four major components.


Data
Hardware
Software
Database users

Figure: A simplified Database System Environment


Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 8 / 47
Functions of DBMS

Defining the database


Specifying the structures, data types, constraints of data stored in the database.
Database definition is stored by the DBMS in the form of a database catalog or dictionary
called meta-data.

Constructing the database:


Process of storing the data on some storage medium that is controlled by the DBMS.

Manipulating and sharing database for various applications:


This encompasses activities like querying the database, inserting new records into the
database, updating some data items, and deleting certain items from the database.
Sharing database allows multiple users and programs to access the database
simultaneously.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 9 / 47


File Processing System

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 10 / 47


Traditional File System for storing data

Example
Savings bank enterprise stores information about customers and savings accounts etc.
One way to keep the information on computers is to store in files provided by operating
systems (OS).

Disadvantages
Difficulty in accessing data:possible operations need to be hardcoded in programs.
Data Redundancy and Inconsistency: Data redundancy leads to higher storage and
access cost.
Data Isolation: Data scattered in various files, and files may be different formats.
Integrity Problem: Data value stored in the database must satisfy certain types of
consistency constraints.
Atomicity Problems: The funds transfer should be atomic.
Concurrent-access anamolies: Concurrent access may result in inconsistent data
Enforcing security constraints is difficult.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 11 / 47


Advantages of DBMS over Traditional File System

Real-world Entity: A modern DBMS is more realistic and uses real-world entities to design
its architecture. For Example:a school database may use students as an entity and their
age as an attribute.

Relation-based tables: DBMS allows entities and relations among them to form tables.

Isolation of data and application: A database is an active entity, whereas data is said to be
passive, on which the database works and organizes.

Reduction of redundancy: DBMS follows the rules of normalization, which splits a relation
when any of its attributes is having redundancy in values.

Inconsistency can be avoided: Consistency is a state where every relation in a database


remains consistent.

Propagating Updates: Changes made to record of one file, automatically made to other
files related to that record.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 12 / 47


Advantages of DBMS over Traditional File System

Query Language: DBMS is equipped with query language, which makes it more efficient
to retrieve and manipulate data.

Integrity can be Maintained : Data contained in the database is both accurate and
consistent. Example: The balance of a bank account may never fall below a prescribed
amount like 500 Rs.

Atomicity: The transaction must be atomic, i.e., it must happen in its entirely or not at
all. It is difficult to ensure atomicity in a conventional file processing system.

Multiuser and Concurrent Access: DBMS supports multi-user environment and allows
them to access and manipulate data in parallel.

Multiple views: DBMS offers multiple views for different users. A user who is in the Sales
department will have a different view of database than a person working in the Production
department.

Security: DBMS offers methods to impose constraints while entering data into the
database and retrieving the same at a later stage. DBMS offers many different levels of
security features, which enables multiple users to have different views with different
features.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 13 / 47


Disadvantage of Database System

Cost.

Complexity.

Danger of a overkill: Not suitable for a single user applications.

Qualified Professional.

Lower Efficiency.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 14 / 47


Popular Database Vendors and Products

Table: Vendors Details

Company Product
Oracle Oracle 8i, 9i, 10g etc.
IBM DB2, Universal Server
Microsoft Access, Sql Server
Sybase Adaptive Server
Informix Dynamic Server

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 15 / 47


Application of Database System

Universities
Hospital
Banking system
Railway Reservation System
Airlines
Human Resources
IT Industry
Credit and Transaction
Sales
Telecommunication
Library Management System

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 16 / 47


Unit I
Lecture Session-2

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 17 / 47


Content

Data View
Level of Abstraction
Database Schema
Database Instance
Data Independence
Database Architectures
Database Language and Interfaces
Meta Data
Data Dictionary

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 18 / 47


Data View

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


abstract view of data.
It means the system hides certain details of how data are stored and
maintained.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 19 / 47


Levels of Abstraction

Physical Level
It is the lowest level of abstraction.
It describes how the data are actually stored in the database.
It describes complex low-level data structures in detail.

Logical Level
Higher level than the physical level.
It describes what data are actually stored in the database.
It also describes relationship existing among those data.

View Level
The upper most level is called view level.
It describes only the part of the database.
It simplify the interaction with the system and hide the complexity that arises in the
logical level.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 20 / 47


Levels of Data Abstraction

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 21 / 47


Example

A university organization may have several such record types, including

At the physical level, an instructor, department, or student record can be described as a


block of consecutive storage locations.
The compiler hides this level of detail from programmers.
Similarly, the database system hides many of the lowest-level storage details from
database programmers.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 22 / 47


Database Schema

Description
The overall design of the database is called database schema.
It represents the logical view of the entire database.
It defines how the data is organized and relations among them are associated.
It defines the descriptive details of the database, depicted by means of schema diagram.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 23 / 47


Three-Schema Architecture
A database can be described using three different levels of abstractions.
Description at each level can be defined by a schema.

Physical Schema or Internal Schema


It describes the database design at the physical level.
It defines how the data will be stored in a secondary storage.
It pertains to the actual storage of data in a form of files, indices, etc.

Logical Schema or Conceptual Schema


It describes the database design at the logical level.
It defines all the logical constraints that need to be applied on the data stored.
It defines tables, views, integrity constraints and concentrates on describing entities,
datatype, relationship and constraints.

View Schema or External Schema


It describes the database at external level.
This allows data access to be customized at the level of individual
users/groups/applications.
Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 24 / 47
Three Schema Architecture

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 25 / 47


Instance

Definition
The collection of information stored in the database at a particular moment is called instance of
the database.

Difference between Schema and Instance


Database schema defines the variable declarations in tables that belong to a particular
database
The value of these variables at a moment of time is called the instance of that database.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 26 / 47


Data Independence

It is defined as the capacity to change the schema at one level of a database system without
having to change the schema at the next higher level.

Logical Data Independence


It is the capacity to change the conceptual schema without having to change external schemas
or application program.

Physical Data Independence


It is the capacity to change the internal schema without having to change the conceptual
schema.

The changes in physical features of storage, i.e., changes to the physical storage format
should not affect schema at conceptual level.

Example: Suppose we want to replace hard-disks with SSD it should not have any impact
on the logical data or schemas.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 27 / 47


DBMS Architectures

Key Points
DBMS design depends on its architecture.
It can be centralized or decentralized or hierarchical.
The architecture of DBMS can be seen as either single tier or multi-tier.
The architecture divides the system into related but n independent modules.

1-tier Architecture
The DBMS is the only entity where the user directly sits on the DBMS and uses it.
Any changes done here will directly be done on the DBMS itself.
Database designers and programmers normally prefer to use single-tier architecture.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 28 / 47


2-tier Architecture
If the architecture of DBMS is 2-tier, then it must have an application through which the
DBMS can be accessed.
In a two-tier architecture, the application resides at the client machine.
Application invokes database system functionality at the server machine through query
language statements.
Application program interface standards like ODBC and JDBC are used for interaction
between the client and the server.

(a) (b)

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 29 / 47


Advantages and Disadvantages of 2-tier Architecture

Advantages
The advantages of this architecture are its simplicity and seamless
compatibility with existing systems.

Disadvantages
The Two-tier architecture is not scalable because each client requires its
own database session.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 30 / 47


3-tier Architecture

Client End
The client machine acts as merely a front end and does not directly connect to the server.
The application client first communicate with the application server usually through any
form of interface.

Application Server
The application layer sits in the middle and acts as a mediator between the end-user and
the database.
The application server communicates with the database system to access data.

Database (Data) Tier


At this tier, the database resides along with its query processing languages.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 31 / 47


3-tier Architecture

Advantages
High Performance, light weight persistent object.
High degree of flexibility in deployment platform and configured.

Disadvantages
This architecture is less standard than Enterprise Java Beans.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 32 / 47


Database Architecture

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 33 / 47


Database users
Naive users
User who interact with the system by invoking an application program that has been written
previously.

Example
Transfer Program, ATM Machine

Application Programmers
Professional Programmers are responsible for developing application program.
Application program could be written in COBOL, PASCAL, etc.
Application programmer can choose many tool to develop user interfaces.

Sophisticated Users
These users interact with the system without writing program.
They generate their request in the form of database query language.
Each query is submitted to the query processor whose function is to break down DML
statement into instruction that the data storage manager understand.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 34 / 47


Work of Sophisticated Users

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 35 / 47


Database users

Online Users
These users communicate with database directly via. an online terminal.
Online users can also be navie users but require additional help.

Example
Suppose a users wishes to find account balance over world wide web. They can access the portal
and retrieve the balance.

Specialized Users
Users who are responsible to write specialized database applications that do not fit into the
conventional data processing system.

Example
Expert System, Artificial Intelligence system, Knowledge base system with complex data type.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 36 / 47


Database Administrator (DBA)
A person having central control of both, the data and the programs that access those data is
called DBA.

Role of DBA
The DBA is a special user who is created when the system is installed.

It provides the necessary technical support for implementing the decision taken by
administrator.

It decides the privileges and gives authentication to the user as per the privileges.

It responsibilities include upgrading, implementation, trading, granting of authorization


etc.

Function of DBA
Defining the Schema.
Installing and upgrading.
user interaction.
Defining Integrity Constraint.
Defining Security.
Granting of Authorization of Data Access

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 37 / 47


Authentication Role of DBA

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 38 / 47


Query Processor

It help the database system to simplify and facilitate access of data.


It is used to compile and interpret the user’s query and convert it into an efficient series of
operations.

DDL and DML Compiler


The compiler translates the DDL and DML statement into low-level instruction command.
Compiler and linker generates the application program object code that is processed to
the storage manager and then processed to the disk storage for operations.

Query Evaluation Engine


It executes the low level instruction code that is generated by the DDL and DML compiler.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 39 / 47


Database Language and Interfaces
Data Definition Language (DDL)
DDL is used by the DBA and by database designers to define the schema.
DBMS has DDL Compiler whose function is to process DDL Statements.
DDL provides the facility to setup, change and remove the data structure from table.

Table: DDL Commands

S.no Commands Functions


1 Create Creates a new table, a view of a table, or other object in the database.
2 Alter Modifies an existing database object, such as a table.
3 Drop Deletes an entire table, a view of a table or other objects in the database.
4 Rename It is used to change the table name.
5 Truncate remove the schema of the table.

Key points of DDL


DDL defines the conceptual schema.
Also present details about implementing the schema in Physical device.
DDL updates a special set of table called Data Dictionary.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 40 / 47


Database Language and Interfaces

Data Manipulation Language (DML)


DBMS provides a set of operations on a database through a language called DML.
The manipulation operations include retrieval, insertion, deletion, and modification of
data.

Table: DML Commands


S.no Commands Functions
1 Select Retrieves certain records from one or more tables.
2 Insert Creates a record.
3 Update Modifies records.
4 Delete Deletes records.
5 Merge Merge the records.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 41 / 47


DML Language Partition

Procedural DML
It requires what data the user wants to retrieve and how to get the data.

Non-procedural DML
It requires what data user wants only without indicating how to get that data.
The DML components of SQL Language is non-procedural.

Query Language
Data manipulation is called query that request the retrieval of information.
The portion of a DML that involves information retrieval is called query language.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 42 / 47


Storage Manager

It acts as a mediator between the disk storage and the query processor.

It is responsible for interacting with file manager.

It translates various DDL and DML statement into low-level system commands for
retrieving data from disk storage.

It is responsible for storing, retrieving and updating data in the database.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 43 / 47


Components of Storage Manager

Buffer Manager
It fetches data from disk storage into main memory and decides what data to cache in main
memory.

File Manager
It manages the allocation of space on disk storage and utilize efficient techniques of data
structure to represent data on the disk.

Privilege Manager
It checks the authentication of the users while accessing or manipulating the data.

Transaction Manager
It is responsible for keeping database in a consistent despite of system failure.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 44 / 47


Meta Data

Data about data is called metadata.


It describes data that is stored in the database.
The data that provides information about the tables, views, constraints, etc. stored within
the database.

Table: Student Database


Student Name College Name Roll no.
Animesh SIST 123
Kailash NRI 124
Manoj TIT 125
Nishant JNCT 126

Example
Fetch student name and college name whose roll no. is 125.
Roll no. describes a data that gives you related information about another data which is
collectively known as meta data.
Schema of a table is an example of metadata.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 45 / 47


Data Dictionary or System Catalog
It contains metadata.
It contains the actual description used by the DBMS.
In general, the data dictionary is active and integrated in most dbms.
It is considered to be a special type of table which can only be accessed and updated by
the database system itself.
The database system consult the data dictionary before reading and modifying the actual
data.

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 46 / 47


The End

Neha Bharill (Mahindra University) Chapter-1 August 18, 2022 47 / 47

You might also like