DBMS Updated Unit 1

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 107

Noida Institute of Engineering and

Technology Greater Noida


Department of CSE

RCS 501
Data Base Management System

By
Vineet Kumar
Associate Prof. ( CSE) & Dean (SW)

04/03/2020 Vineet Kumar 2


Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Syllabus
UNIT 1
Introduction: Overview, Database System vs File System,
Database System Concept and Architecture, Data Model
Schema and Instances, Data Independence and Database
Language and Interfaces, Data Definitions Language, DML,
Overall Database Structure. Data Modeling Using the Entity
Relationship Model: ER Model Concepts, Notation for ER
Diagram, Mapping Constraints, Keys, Concepts of Super Key,
Candidate Key, Primary Key, Generalization, Aggregation,
Reduction of an ER Diagrams to Tables, Extended ER Model,
Relationship of Higher Degree.
04/03/2020 Vineet Kumar 3
Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Syllabus
UNIT 2
Relational data Model and Language: Relational Data Model
Concepts, Integrity Constraints, Entity Integrity, Referential
Integrity, Keys Constraints, Domain Constraints, Relational
Algebra, Relational Calculus, Tuple and Domain Calculus.
Introduction on SQL: Characteristics of SQL, Advantage of SQL.
SQl Data Type and Literals. Types of SQL Commands. SQL
Operators and Their Procedure. Tables, Views and Indexes.
Queries and Sub Queries. Aggregate Functions. Insert, Update
and Delete Operations, Joins, Unions, Intersection, Minus,
Cursors, Triggers, Procedures in SQL/PL SQL
04/03/2020 Vineet Kumar 4
Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Syllabus
UNIT 3
Data Base Design & Normalization: Functional dependencies,
normal forms, first, second, 8 third normal forms, BCNF, inclusion
dependence, loss less join decompositions, normalization using
FD, MVD, and JDs, alternative approaches to database design
UNIT 4
Transaction Processing Concept: Transaction System, Testing of
Serializability, Serializability of Schedules, Conflict & View
Serializable Schedule, Recoverability, Recovery from Transaction
Failures, Log Based Recovery, Checkpoints, Deadlock Handling.
Distributed Database: Distributed Data Storage, Concurrency
04/03/2020 Control, Directory System. Vineet Kumar 5
Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Syllabus
UNIT 5
Concurrency Control Techniques: Concurrency Control,
Locking Techniques for Concurrency Control, Time Stamping
Protocols for Concurrency Control, Validation Based Protocol,
Multiple Granularity, Multi Version Schemes, Recovery with
Concurrent Transaction, Case Study of Oracle.
References:
1. Korth, Silbertz, Sudarshan,” Database Concepts”, McGraw Hill
2. Date C J, “An Introduction to Database Systems”, Addision Wesley
3. Elmasri, Navathe, “ Fundamentals of Database Systems”, Addision Wesley
4.Bipin C. Desai, “ An Introduction to Database Systems”, Galgotia
Publications
04/03/2020 Vineet Kumar 6
Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Course Objective
Present an introduction to database management
systems, with an emphasis on how to organize,
maintain and retrieve - efficiently, and effectively -
information from a DBMS.
Differentiate between database system and file
system.
Knowledge of the different models like database
modeling, relational, hierarchical and network models.
Explain basic issues of transaction processing and
concurrency control.
04/03/2020 Vineet Kumar 7
Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Course Outcomes
[CO1] Differentiate database systems from existing file
systems and describe each in both function and benefit.

[CO2] Describe and analyze the terminology, features,


classifications and characteristics of database systems.

[CO3] Write relational algebra expression for queries and to


compare the relational model with structured query
language.

04/03/2020 Vineet Kumar 8


Noida Institute of Engineering and
Technology Greater Noida
Department of CSE
Course Outcomes
[CO4] Implement the real-world system using Entity
Relationship diagram, Extended Entity Relationship diagram
and to demonstrate the basics of query evaluation and apply
query optimization technique.

[CO5] To explain and use design principles for logical design


of databases, including the E‐R method and normalization
approach.
 
[CO6] Understand and apply transaction properties and
concurrency control for enforcing the database consistency
and recovery at the time of database failure, enforce entity
04/03/2020 Integrity, referential integrity,
Vineetkey
Kumar constraints, and domain 9
Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Program Outcomes
[PO1] Engineering Knowledge:
Apply the knowledge of mathematics, science, engineering
Fundamentals and an engineering specialization to the solution of
complex engineering problem

[PO2] Problem Analysis


An ability to analyze a problem, and identify and define the computing
requirements appropriate to its solution.

[PO 3] Design Development of solution:


an ability to design, implement, and evaluate a software or a sw/hw
system, component, or process to meet desired needs within realistic
constraints such as memory, runtime efficiency, as well as appropriate
constraints related to economic, environmental, social, political,
04/03/2020 ethical, health and safety, manufacturability,
Vineet Kumar and sustainability 10
considerations;
Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Program Outcomes
• [PO 4] Conduct investigations of complex problems
an ability to design and conduct experiments, as well as to analyze
and interpret data using research based knowledge and research
method;

• [PO 5] Modern tool usage


an ability to use the techniques, skills, and modern engineering
tools necessary for practice as a engineering professional;

• [PO 6] The Engineer and Society


an understanding of professional, ethical, legal, security and social
issues and responsibilities;

04/03/2020 Vineet Kumar 11


Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Program Outcomes
• [PO 7] Environment and sustainability
Recognition of the need of professional engineering solution for
societal and environmental development.

• [PO 8] Ethics
Apply ethical principles and commit to professional ethics and
responsibilities and norms of the engineering practice.

• [PO 9] Individual and Team work


An ability to function effectively individually or in teams to
accomplish a common goal.

04/03/2020 Vineet Kumar 12


Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Program Outcomes
• [PO 10] Communication
an ability to communicate effectively with a range of audiences by
writing reports, documentation and presentation;

• [PO 11] Project Management and Finance


Demonstrate knowledge and understanding of engineering and
management principles and apply these to one’s own work, as a
member and leader in a team, to manage projects and in
multidisciplinary environments

• [PO 12] Life Long Learning


a recognition of the need for, and an ability to engage in life-long
learning and continuing professional development;
04/03/2020 Vineet Kumar 13
Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

CO-PO Mapping
Correlation levels are taken 1, 2 and 3 as defined below:
1: Slight (Low) 2: Moderate (Medium) 3: Substantial (High)
If there is no correlation, put ‘-’

04/03/2020 Vineet Kumar 14


Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

UNIT 1

Introduction: Overview, Database System vs File System,


Database System Concept and Architecture, Data Model
Schema and Instances, Data Independence and Database
Language and Interfaces, Data Definitions Language, DML,
Overall Database Structure. Data Modeling Using the Entity

Relationship Model: ER Model Concepts, Notation for ER


Diagram, Mapping Constraints, Keys, Concepts of Super Key,
Candidate Key, Primary Key, Generalization, Aggregation,
Reduction of an ER Diagrams to Tables, Extended ER Model,
Relationship of Higher Degree.
04/03/2020 Vineet Kumar 15
Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Introduction to DBMS

Introduction: Overview, Database System vs File System,


Database System Concept and Architecture, Data Model
Schema and Instances, Data Independence and Database
Language and Interfaces, Data Definitions Language, DML,
Overall Database Structure. Data Modeling Using the Entity

Relationship Model: ER Model Concepts, Notation for ER


Diagram, Mapping Constraints, Keys, Concepts of Super Key,
Candidate Key, Primary Key, Generalization, Aggregation,
Reduction of an ER Diagrams to Tables, Extended ER Model,
Relationship of Higher Degree.
04/03/2020 Vineet Kumar 16
Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Introduction to DBMS
Good data management is an essential prerequisite to
corporate success.

Data Information
Information Knowledge
Knowledge Judgment
Judgment Decision
Decision Success

provided that data is:


• complete
• accurate
• timely
• easily available
04/03/2020 Vineet Kumar 17
Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Introduction to DBMS
What is Data?
Data : is the raw facts and figures. It is represented with the
help of characters like alphabets(A-Z), digits(0-9) and special
characters (+,-,/,*,<,>,= etc.)
Example : 36 , Ravi,
What is Information ?
Information . Processed data is called information.
it  is a set of organized or classified data so that it has
some meaningful values.
Example : Age 36 is information, Name of Person is Ravi
04/03/2020 Vineet Kumar 18
Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Introduction to DBMS
What is Data Base?
Database made up of two separate words, i.e. Data and base
means database is a base of data.
Database is a collection of related data organized in a way that
data can be easily accessed, managed and updated.

Database actually a place where related piece of


information is stored and perform various operation can be
performed on it.

04/03/2020 Vineet Kumar 19


Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Introduction to DBMS
What is Data Base Management System?
A software package/ system to facilitate the creation and
maintenance of a computerized database.
Example :

04/03/2020 Vineet Kumar 20


Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Introduction to DBMS
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
04/03/2020 Vineet Kumar 21
Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Introduction to DBMS
Database Design Steps
1. Requirements Analysis
2. Conceptual Modelling (ER Model)
3. Logical Modelling (Relational Model)
4. Schema Refinement (Normalization)

04/03/2020 Vineet Kumar 22


Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Earlier Existing System

File Processing System


A file processing system is a collection of files and
programs that access/modify these files.

Typically, new files and programs are added over


time (by different programmers) as new
information needs to be stored and new ways to
access information are needed.
04/03/2020 Vineet Kumar 23
Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Database System Vs. File System

I. Data Redundancy problem


II. Data consistency problem
III. Data isolation problem
IV. Integrity problem
V. Sharing of Data
VI. Atomicity problem
VII. Concurrent Access problem
VIII.Backup and Recovery Procedures problem
IX. Data Independence 
04/03/2020
X. Data Security problemVineet Kumar 24
Noida
Database Institute
System Vs. of
FileEngineering
System and
Technology Greater Noida
Department of CSE
Database System Vs. File System
DBMS Advantages over File System :-
The database management system has a number of advantages as compared to
traditional computer file-based processing approach.
1. Controlling Data Redundancy 
In non-database systems each application program has its own private files. In
this case, the duplicated copies of the same data is created in many places. In
DBMS, all data of an organization is integrated into a single database file. The
data is recorded in only one place in the database and it is not duplicated.
2.Data Consistency 
• By controlling the data redundancy, the data consistency is obtained. If a data
item appears only once, any update to its value has to be performed only
once and the updated value is immediately available to all users. If the DBMS
has controlled redundancy, the database system enforces consistency.
Noida Institute of Engineering and
Technology Greater Noida
Department of CSE
DatabaseDatabase
System Vs. File
System System
Vs. File System
DBMS Advantages over File System :-
3. Data Isolation problem:- In file system the data are scattered in various
file, and files may be different formats. So writing new application program
to retrieve the appropriate data is difficult.

4.Integration of Data
• When new constraints are added in file processing system, It is difficult to
change the program to enforce them, The problem is compounded when
constraint involve several data item from different files.
Integrity constraints or consistency rules can be applied to database the
constraints is that it applied data item within a single record or the may be
applied to relationships between records.
Database System
Noida Vs. of
Institute File System and
Engineering
Technology Greater Noida
Department of CSE

Database System Vs. File System

5.Sharing of Data
In DBMS, data can be shared by authorized users of the organization. The
database administrator manages the data and gives rights to users to
access the data. Many users can be authorized to access the same piece of
information simultaneously. The remote users can also share same data.
Similarly, the data of same database can be shared between different
application programs.

6. Atomicity Problem
In many applications , It is crucial that if failure occur, the data is restored to
the consistent state that existed prior to the failure.
Atomicity means:- either all or not at all.
Database System
Noida
Noida Vs. of
Institute
Institute File
of System and
Engineering
Engineering and
Technology
Technology Greater
Greater Noida
Noida
Department
Department of
of CSE
CSE
Database System Vs. File System
DBMS Advantages over File System :-
7.Control Over Concurrency 
In a computer file-based system, if two users are allowed to access data
simultaneously, it is possible that they will interfere with each other. For
example, if both users attempt to perform update operation on the same record,
then one may overwrite the values recorded by the other. Most database
management systems have sub-systems to control the concurrency so that
transactions are always recorded with accuracy.
8.Backup and Recovery Procedures 
• In a computer file-based system, the user creates the backup of data regularly to
protect the valuable data from damage due to failures to the computer system
or application program. It is very time consuming method, if amount of data is
large. Most of the DBMSs provide the 'backup and recovery' sub-systems that
automatically create the backup of data and restore data if required.
Database System
Noida Vs. of
Institute File System and
Engineering
Technology Greater Noida
Department of CSE

Database System Vs. File System

9.Data Independence 
• The separation of data structure of database from the application program
that uses the data is called data independence. In DBMS, you can easily change
the structure of database without modifying the application program.
Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Database System Vs. File System


S.NO. Database System File System
1 Data redundancy problem is not found Here Redundancy Problem Exist
2 Data Consistency does not exists Exist here
3 Accessing Database is easier Accessing database is difficult
4 The problem of data isolation not Data are scattered in various file
found on it in different format writing new
program for accessing them
5 Concurrent access and crash Recovery Here There is no concurrent
access and recovery
6 Atomicity and integration problem are Atomicity and integration
not found problem are found
7 Security of database good in DBMS Here is not good
Disadvantage
Noida Of DBMS of Engineering and
Institute
Technology Greater Noida
Department of CSE

Disadvantages of DBMS

There are various disadvantages of DBMS are:-


1. Cost of Hardware and Software
2. Complexity of Backup and recovery
3. Cost of Staff training
4. Cost of Data conversion
Disadvantage
Noida Of DBMS of Engineering and
Institute
Technology Greater Noida
Department of CSE

DBMS

A database Management System is a collection of programs that enables


users to create and maintain a database.
DBMS is a general purpose software system that facilitate the process of
defining , constructing , manipulation and sharing database among
various users and application.
Defining a database involves specifying the data types, structures and
constraints for the data to be stored in the database.
Constructing the database is the process of storing the data itself on
some storage medium.
Manipulating a database includes querying the database to retrieve the
information, updating the database and generating the report form
Sharing a database allows multiple users and programs to access the
database concurrently
Components
Noida of Database
Institute of Engineering and
Technology Greater Noida
Department of CSE
Components of DBMS
Database and DBMS software together is Database system
A database System involves four major components

I. Data
II. Hardware
III. Software
IV. Users
Disadvantage
Noida Of DBMS of Engineering and
Institute
Technology Greater Noida
Department of CSE

Characteristics of DBMS

Self describing nature of a database.


Insulation between programs and data, and data
abstraction.
Support of multiple views of the data
Sharing of data and multiuser transaction processing
Disadvantage
Noida Of DBMS of Engineering and
Institute
Technology Greater Noida
Department of CSE

Self Describing Nature of a Database.

The database system contains not only the database itself


but also a complete definition or description of the
database structure and constraints
This definition stored in DBMS catalog, which contains
information of structure, type and storage format of each
data items and various constraints
The information stored in the catalog is called Metadata.
Data about data is called Metadata
Disadvantage
Noida Of DBMS of Engineering and
Institute
Technology Greater Noida
Department of CSE
Insulation between programs and data, and data abstraction

The structure of the data files is stored in DBMS catalog


separately from the access program, known as Program-
Data Independence.
Similarly , Database system supports Program-Operation
Independence
The characteristics that allows Program-Data Independence
and Program-Operation Independence is called Data
Abstraction
View of Data
Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Data Abstraction

A database system is a collection of interrelated files(data) and a set of


programs that allow users to access and modifies these (files)data. A major
purpose of a database system is to provides users with an abstract view of
the data. That is, the system hides certain details of how the data are stored
and maintained.

Data Abstraction
We have three level of abstraction
I. Physical level
II. Logical level
III. View Level
Data Abstraction in DBMS
Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Abstraction in DBMS

Provides view of the


External Level
database

What data are to be stored


Conceptual Level
and relationship among data

How data are stored


Internal Level
View of Data
Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Support of multiple views of the data

A database system has many users , each of whom require a different


perspective of the database.
A view maybe a subset of database or it may contain virtual data that is
derived from the data base file.

Sharing of data and multiuser transaction processing

Allows multiple users to access the database at the same time.


Disadvantage
Noida Of DBMS of Engineering and
Institute
Technology Greater Noida
Department of CSE

Actors of DBMS

Database Administrator
Database Designers
End Users
Casual End Users
Naïve or parametric End Users
Sophisticated End Users
Stand Alone Users
System Analyst and Application Programmers
Disadvantage
Noida Of DBMS of Engineering and
Institute
Technology Greater Noida
Department of CSE

Data Model

A collection of concepts that can be used to describe the


structure of database
It provides the necessary means to achievements of data
abstraction
Most data model also include set of basic operations of
retrieval and updates
Disadvantage
Noida Of DBMS of Engineering and
Institute
Technology Greater Noida
Department of CSE

Categories of Data Model

Categorization according to the concepts they used to


describe the database structure
High level or conceptual Data Model
 Provide concepts that describe the way many user perceive the data
Low level or Physical Data Model
 Provide concepts that describe the details of how data is stored in
computer.
Representational Data Model
 Provide concepts that may be understood by end user but that are
not too far removed from the way data is organized within the
system
Disadvantage
Noida Of DBMS of Engineering and
Institute
Technology Greater Noida
Department of CSE

Categories of Data Model

Categorization according to the Representational or


implementation
1. Hierarchical Model
2. Network Database Model
3. Relational Model
4. Object Oriented Model
Disadvantage
Noida Of DBMS of Engineering and
Institute
Technology Greater Noida
Department of CSE
1. Hierarchical Model

• In this model, the data is sorted


hierarchically.
• It represents the data in a
hierarchical tree structure.
• It uses pointer to navigate
between the stored data.
Disadvantage
Noida Of DBMS of Engineering and
Institute
Technology Greater Noida
Department of CSE
2. Network Database Model
• Network Database Model is same like
Hierarchical Model, but the only difference is
that it allows a record to have more than one
parent.

• In this model, there is no need of parent to


child association like the hierarchical model.

• It replaces the hierarchical tree with a graph.

• It represents the data as record types and one-


to-many relationship.

• This model is easy to design and understand.


Disadvantage
Noida Of DBMS of Engineering and
Institute
Technology Greater Noida
Department of CSE
3. Relational Model
• This model was first proposed by E. F.
Codd.

• It represents data as relations or tables.

• Relational database simplifies the


database structure by making use of
tables and columns.
Disadvantage
Noida Of DBMS of Engineering and
Institute
Technology Greater Noida
Department of CSE
4. Object Oriented Model
• Object model stores the data in the form of objects, classes and inheritance.

• This model handles more complex applications, such as Geographic Information System
(GIS), scientific experiments, engineering design and manufacturing.

• It is used in File Management System.

• It represents real world objects, attributes and behaviors.

• It provides a clear modular structure.

• It is easy to maintain and modify the existing code.


Schema andInstitute
Noida Instanceof Engineering and
Technology Greater Noida
Department of CSE
Schema
 A database schema is the skeleton structure that represents the logical
view of the entire database.
 It is not expected to change frequently.
 When we define a new database we specify its database schema.
 It defines how the data is organized and how the relations among them are
associated.
 It formulates all the constraints that are to be applied on the data.

• Example:
Studen ID SName Age Branch Address
Schema andInstitute
Noida Instanceof Engineering and
Technology Greater Noida
Department of CSE
Schema

Instance:-Database change overtime as information is inserted and deleted.


The collection of information stored in the database at a particular
moments is called an instances of the database.
It is also called database state or snapshot.
( actual content of the database at a particular point in
time)
Difference Between Schema and
Noida Institute of Engineering and
Table Technology Greater Noida
Department of CSE

Introduction to DBMS

• A database schema describes the structure and organization of data in a


database system, while a table is a data set in which the data is organized in
to a set of vertical columns and horizontal rows. The database schema
defines the tables in a database, the columns and their types.

• In addition the schema also defines what columns are defined as the
primary key of a table. Understandably, the schema of a database keeps
constant once created, while the actual data in the database tables may
change all the time.
Difference Between Schema and
Noida Institute of Engineering and
Table Technology Greater Noida
Department of CSE

Architecture of DBMS

• There
. are two types of application Architecture of DBMS
1. Two Tire Architecture
2. Three Tire Architecture
Difference Between Schema and
Noida Institute of Engineering and
Table Technology Greater Noida
Department of CSE

Architecture of DBMS
There are two types of application Architecture of DBMS
• 1.
. Two Tire Architecture
2. Three Tire Architecture

1. Two Tire Architecture ODBC

• It is used for User Interface program and Client


Application Programs that runs on client side.
•An interface called ODBC(Open Database
Connectivity) provides an API that allow client Database
side program to call the DBMS.. Server
•A client program may connect to several
DBMS's.
Difference Between Schema and
Noida Institute of Engineering and
Table Technology Greater Noida
Department of CSE

Architecture of DBMS
Disadvantages:
• .  In two tier architecture application performance will be degrade upon
increasing the users.
 Cost-ineffective.
 Tightly coupled.
 Not easy to scale .
 degrades performance when scale.

It is the most widely used architecture to design a DBMS.


The objective of the three level architecture is to separate
each user's view of the database from the Way the database
is physically represented.
Difference Between Schema and
Noida Institute of Engineering and
Table Technology Greater Noida
Department of CSE
3 Tier Architecture of DBMS

.
Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Architecture of DBMS
• 1. Physical Level
• Physical level describes the physical storage structure of
data in database.
• It is also known as Internal Level.
• This level is very close to physical storage of data.
• At lowest level, it is stored in the form of bits with the
physical addresses on the secondary storage device.
• At highest level, it can be viewed in the form of files.
• The internal schema defines the various stored data types.
It uses a physical data model.
Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Architecture of DBMS
• 2. Conceptual Level
• Conceptual level describes the structure of the whole database for a
group of users.
• It is also called as the data model.
• Conceptual schema is a representation of the entire content of the
database.
• These schema contains all the information to build relevant external
records.
• It hides the internal details of physical storage.
Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Architecture of DBMS
• 3. External Level
• External level is related to the data which is viewed by individual end
users.
• This level includes a no. of user views or external schemas.
• This level is closest to the user.
• External view describes the segment of the database that is required
for a particular user group and hides the rest of the database from that
user group.
Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Objectives of 3 Tier Architecture of DBMS

The objective of the three level architecture is to separate each user's view of
the database from the Way the database is physically represented. There
are several reasons why this separation is desirable: 

• Each user should be able to access the same data, but have a different
customized view of the data. Each user should be able to change the way
he or she views the data, and this change should not affect other users.
• Users should not have to deal directly with physical database storage
details, such as indexing or hashing. In other words a user's interaction
with the database should be independent of storage considerations
Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Objectives of 3 Tier Architecture of DBMS


• The Database Administrator (DBA) should be able to change the database
storage structures without affecting the user's views.

• The internal structure of the database should be unaffected by changes to


the physical aspects of storage, such as the changeover to a new storage
device.

• The DBA should be able to change the conceptual structure of the database
without affecting all users.
Noida Institute of Engineering and
Technology Greater Noida
2 Department of CSE

DBMS Language
1. Data Definition Language (DDL)
2. Data Manipulation Language (DML)
3. Data Control Language (DCL)
4. Transaction Control Language (TCL)
Noida Institute of Engineering and
Technology Greater Noida
2 Department of CSE

Data Definition Language (DDL)

• Specification notation for defining the database schema


Example:create table account (
account-number char(10),
balance integer)
• DDL compiler generates a set of tables stored in a data dictionary
• Data dictionary contains metadata (i.e., data about data)
• Database schema
• Data storage and definition language
• Specifies the storage structure and access methods used
• Integrity constraints
• Domain constraints
• Referential integrity (references constraint in SQL)
• Assertions
• Authorization
Example : Create Table, Drop, Alter
Noida Institute of Engineering and
Technology Greater Noida
2 Department of CSE

Data Manipulation Language (DML)

Language for accessing and manipulating the data organized by the


appropriate data model
DML also known as query language
Two classes of languages
Procedural – user specifies what data is required and how to get those
data
Declarative (nonprocedural) – user specifies what data is required
without specifying how to get those data
SQL is the most widely used query language

Example : Insert into, Delete, update , select


Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

Data Control Language (DCL)

DCL statement of DBMS control the access of data

GRANT statement
A privilege can either be granted to a User with the help of GRANT
statement.
The privileges assigned can be SELECT, ALTER, DELETE, EXECUTE, INSERT,
INDEX etc.
Revoke Statement
In addition to granting of privileges, you can also revoke (taken back) it by
using REVOKE command.
Noida Institute of Engineering and
Technology Greater Noida
2 Department of CSE

Transaction Control Language (TCL)


•Transaction Control Language (TCL) commands are used to manage the
transactions in the database.
•These are used to manage the changes made to the data in a table by
DML Statements.
•It also allows statements to be grouped together into logical transaction.

Example
COMMIT command is used to permanent ally save any transaction into
database
ROLLBACK command rollback those changes if they were not committed .
SVEPOINT command used to save temporarily save a transaction.
Noida Institute of Engineering and Technology,
Greater Noida
Department of CSE
Overall database Structure

04/03/2020 VINEET KUMAR 65


Noida Institute of Engineering and
Technology Greater Noida
2 Department of CSE

Functional Components of DBMS are broadly classified as follows :


1. Query Processor :
(a) DML Compiler
(b) Embedded DML pre-compiler
(c) DDL Interpreter
(d) Query Evaluation Engine
2. Storage Manager :
(a) Authorization and Integrity Manager
(b) Transaction Manager
(c) File Manager
(d) Buffer Manager
3. Data Structure :
(a) Data Files
(b) Data Dictionary
(c) Indices
(d) Statistical Data
Noida Institute of Engineering and
Technology Greater Noida
2 Department of CSE

Query Processor Components :


• • DDL Interpreter : It interprets the DDL statements and records them in a
set of tables containing meta data or data dictionary.
• • DML Pre-compiler : It translates DML statements in a query language
into low level instructions that query evaluation engine understands. It
also attempts to transform user's request into an equivalent but more
efficient form.

• Query Evaluation Engine : It executes low-level instructions generated


by the DML compiler.
Noida Institute of Engineering and
Technology Greater Noida
Department of CSE

2. Storage Manager Components :


They provide the interface between the low-level data stored in the database
and application programs and queries submitted to the system.
It is responsible for storing retrieving and updating the data in the database.

• Authorization and Integrity Manager : It tests for the satisfaction of


integrity constraints checks the authority of users to access data.
• Transaction Manager : It ensures that the database remains in a
consistent state despite the system failures and that concurrent
transaction execution proceeds without conflicting.
• File Manager : It manages the allocation of space on disk storage and
the data structures used to represent information stored on disk.
• Buffer Manager : It is responsible for fetching data from disk storage into
main memory and deciding what data to cache in memory.
Noida Institute of Engineering and
Technology Greater Noida
2 Department of CSE

3. Data Structures
• Following data structures are required as a part of the physical system
implementation.
• Data Files : It stores the database.
• Data Dictionary : It stores meta data (data about data) about the structure of
the database.
• Indices : Provide fast access to data items that hold particular values.
• Statistical Data : It stores statistical information about the data in the
database. This information is used by query processor to select efficient ways to
execute query.
Noida Institute of Engineering and
Technology Greater Noida
2 Department of CSE

Entity –Relationship Model (ER Model)


What is ER-model?
ER Model stand for Entity Relationship-Model. Dr. Peter Pin-Shan Chen is the
originator of the Entity-Relationship Model. 
The ER model defines the conceptual view of a database.
It works around real-world entities and the associations among them.
ER-model to get high-level graphical view are called Entity-Relationship
Diagrams, or ER diagrams or ERDs.
There are three basic elements in ER-Diagrams:
i. Entities
ii. Attribute
iii. Relationship
Noida Institute of Engineering and
Technology Greater Noida
2 Department of CSE

Entity –Relationship Model (ER Model)


Entity
An entity is an object that exists and is distinguish from other objects.
An entity is a real world object that can be uniquely identified. It may have physical existence.
Example :-Place, person, job, University etc.
For instance, Rahul with Voter ID No. - IN870-12-3426 is an entity, as he can be uniquely identified as one
particular person in the universe.
An entity may be concrete (a person or a book, for example) or abstract (like a holiday or a
concept).
Entity Set
An entity set is a set of entities of the same type that share the same properties or attributes.
Example
A student set may contain all the students of a school
A teacher set may contain all the teacher of a school.
Noida Institute of Engineering and
Technology Greater Noida
2 Department of CSE

Entity –Relationship Model (ER Model)

Attribute
An entity is represented by a set of attributes. Attribute are unit
that describes the characteristic or properties of entities. In a
database entities are represent by table and attribute by
column.
E.g. attribute name, S.I.N., street, city for ``customer'' entity.
Relationship
Relationships describe the relations between the entities.
Noida Institute of Engineering and
Technology Greater Noida
2 Department of CSE

Entity –Relationship Model (ER Model)


Attributes

Emp.No. Emp Name Designation salary Dept_no


A1001 Ravi SALESPERSON 12000 2
A1002 RAMESH HR 20000 1
A1003 MANOJ ACCOUNTANT 15000 2
A1004 SHUBHAM MANAGER 40000 1
A0005 SANTOSH CLERAK 17000 2
Noida Institute of Engineering and
Technology Greater Noida
2 Department of CSE

Types of Attribute
• Simple attribute − Simple attributes are atomic values, which cannot be divided
further. For example, a student's phone number is an atomic value of 10 digits.
• Composite attribute − Composite attributes are made of more than one simple
attribute. For example, a student's complete name may have first_name and
last_name.
• Derived attribute − Derived attributes are the attributes that do not exist in the
physical database, but their values are derived from other attributes present in
the database. For example, average_salary in a department should not be saved
directly in the database, instead it can be derived. For another example, age can
be derived from data_of_birth.
• Single-value attribute − Single-value attributes contain single value. For example
− Social_Security_Number.
• Multi-value attribute − Multi-value attributes may contain more than one
values. For example, a person can have more than one phone number,
email_address, etc.
Noida Institute of Engineering and
Technology Greater Noida
2 Department of CSE

Keys
• Key is an attribute or collection of attributes that uniquely
identifies an entity among entity set.
EXAMPLE: roll no. is key attribute
• TYPES OF KEYS
• Super Key − A set of attributes (one or more) that
collectively identifies an entity in an entity set.
• Candidate Key − A minimal super key is called a candidate
key. An entity set may have more than one candidate key.
• Primary Key − A primary key is one of the candidate keys
chosen by the database designer to uniquely identify the
entity set.
Noida Institute of Engineering and
Technology Greater Noida
2 Department of CSE
Relationship
• The association among entities is called a relationship.
• For example, an employee works_at a department, a student enrolls in a course. Here,
Works_at and Enrolls are called relationships.

• Relationship Set
• A set of relationships of similar type is called a relationship set.
• Degree of Relationship
• The number of participating entities in a relationship defines the degree of the
relationship.
• Binary = degree 2
• Ternary = degree 3
• n-ary = degree n
• Mapping Cardinalities
• Cardinality defines the number of entities in one entity set, which can be
associated with the number of entities of other set via relationship set.
Noida Institute of Engineering and
Technology Greater Noida
2 Department of CSE
Mapping Cardinalities
One-to-one − One entity from entity set A
can be associated with at most one entity of
entity set B and vice versa.

One-to-many − One entity from entity set A


can be associated with more than one entities
of entity set B however an entity from entity
set B, can be associated with at most one
entity.
Noida Institute of Engineering and
Technology Greater Noida
2 Department of CSE
Mapping Cardinalities
Many-to-one − More than one entities from
entity set A can be associated with at most one
entity of entity set B, however an entity from
entity set B can be associated with more than
one entity from entity set A.

Many-to-many − One entity from A can be


associated with more than one entity from B
and vice versa.
Participation of an Entity Set in a
Relationship Set
 Total participation (indicated by double
line): every entity in the entity set
participates in at least one relationship
in the relationship set
 E.g. participation of loan in borrower is
total
 every loan must have a customer associated
to it via borrower
 Partial participation: some entities
may not participate in any relationship
in the relationship set
 E.g. participation of customer in borrower
is partial
Weak Entity Sets
• An entity set that does not have a primary key is referred to as a weak
entity set.

• Owner entity set and weak entity set must participate in a one-to-many relationship
set (one owner, many weak entities).

• Weak entity set must have total participation in this identifying relationship set.
Weak Entity Sets
Specialization
• Top-down design process; we designate subgroupings within an entity
set that are distinctive from other entities in the set.
• These sub groupings become lower-level entity sets that have
attributes or participate in relationships that do not apply to the
higher-level entity set.
• Depicted by a triangle component labeled ISA (E.g. customer “is a”
person).
• Attribute inheritance – a lower-level entity set inherits all the
attributes and relationship participation of the higher-level entity set
to which it is linked.
Noida Institute of Engineering and
Technology Greater Noida
2 Department of CSE
Notation of ER-Diagram
Symbol Shape Name
Entity

Weak Entity

Attribute

Key attribute

Multivalued attribute

Derived attribute
Composi
Composite Attribute te
Noida Institute of Engineering and
Technology Greater Noida
2 Department of CSE
Notation of ER-Diagram
Relationship
Strong relationship
Weak (identifying)
relationship

TYPES OF RELATION Total Participation


Noida Institute of Engineering and Technology,
Greater Noida
Department of CSE

E-R MODEL EXAMPLE

04/03/2020 VINEET KUMAR 86


Noida Institute of Engineering and Technology,
Greater Noida
Department of CSE

Problem1 :ON LINE BOOK SHOPING

04/03/2020 viNEET kUMAR 87


Noida Institute of Engineering and Technology,
Greater Noida
Department of CSE

Problem2
Construct an E-R diagram for a hospital
with a set of patients and a set of
medical doctors. Associate with each
patient a log of the various tests and
examinations conducted.

04/03/2020 VINEET KUMAR 88


Noida Institute of Engineering and Technology,
Greater Noida
Department of CSE

04/03/2020 VINEET KUMAR 89


Noida Institute of Engineering and Technology,
Greater Noida
Department of CSE

Problem3
Design an Entity Relationship (ER) model for a college database . Say we
have the following statements.
• A college contains many departments
• Each department can offer any number of courses
• Many instructors can work in a department
• An instructor can work only in one department
• For each department there is a Head
• An instructor can be head of only one department
• Each instructor can take any number of courses
• A course can be taken by only one instructor
• A student can enroll for any number of courses
• Each course can have any number of students

04/03/2020 viNEET kUMAR 90


Noida Institute of Engineering and Technology,
Greater Noida
Department of CSE

Step 1 : Identify the Entities.

What are the entities here?


From the statements given, the entities are
•Department
•Course
•Instructor
•Student
04/03/2020 Vineet Kumar 91
Noida Institute of Engineering and Technology,
Greater Noida
Department of CSE

•Step 2 : Identify the relationships


•One department offers many courses. But one particular course
can be offered by only one department. hence the cardinality
between department and course is One to Many (1:N)
•One department has multiple instructors . But instructor
belongs to only one department. Hence the cardinality between
department and instructor is One to Many (1:N)
•One department has only one head and one head can be the
head of only one department. Hence the cardinality is one to
one. (1:1)

04/03/2020 VINEET KUMAR 92


Noida Institute of Engineering and Technology,
Greater Noida
Department of CSE

Step 2 : Identify the relationships (Contd.)

•One course can be enrolled by many students and


one student can enroll for many courses. Hence the
cardinality between course and student is Many to
Many (M:N)
•One course is taught by only one instructor. But one
instructor teaches many courses. Hence the
cardinality between course and instructor is Many to
One (N :1)
04/03/2020 VINEET KUMAR 93
Noida Institute of Engineering and Technology,
Greater Noida
Department of CSE

Step 3: Identify the key attributes


•"Departmen_Name" can identify a department uniquely. Hence
Department_Name is the key attribute for the Entity "Department".
•Course_ID is the key attribute for "Course" Entity.
•Student_ID is the key attribute for "Student" Entity.
•Instructor_ID is the key attribute for "Instructor" Entity.

Step 4: Identify other relevant attributes

•For the department entity, other attributes are location


•For course entity, other attributes are course_name,duration
•For instructor entity, other attributes are first_name, last_name, phone
•For student entity, first_name, last_name, phone
Step 5: Draw complete ER diagram
By connecting all these details, we can now draw ER diagram as given below.
04/03/2020 VINEET KUMAR 94
Noida Institute of Engineering and Technology,
Greater Noida
Department CSE

04/03/2020 Vineet Kumar 95


Noida Institute of Engineering and Technology,
Greater Noida
Department of CSE

Problem4
Consider a database used to record the
marks that students get in different
exams of different course offerings.
Construct an E-R diagram that models
exams as entities, and uses a
ternary relationship, for the above
database.
04/03/2020 VINEET KUMAR 96
Noida Institute of Engineering and Technology,
Greater Noida
Department of CSE

E-R

04/03/2020 VINEET KUMAR 97


Noida Institute of Engineering and Technology,
Greater Noida
Department of CSE

Notation to Express Entity with Complex


Attributes
Noida Institute of Engineering and Technology,
Greater Noida
Department of CSE
E-R Diagram for a University Enterprise
Noida Institute of Engineering and Technology,
Greater Noida
Department of CSE

ASSIGNMENT EXERCISE
UPS prides itself on having up-to-date information on the processing and current
location of each shipped item. To do this, UPS relies on a company-wide
information system. Shipped items are the heart of the UPS product tracking
information system. Shipped items can be characterized by item number (unique),
weight, dimensions, insurance amount, destination, and final delivery date.
Shipped items are received into the UPS system at a single retail center. Retail
centers are characterized by their type, uniqueID, and address. Shipped items
make their way to their destination via one or more standard UPS transportation
events (i.e., flights, truck deliveries).
These transportation events are characterized by a unique schedule Number, a
type (e.g, flight, truck), and a delivery Route.
Create an Entity Relationship diagram that captures this information about the
UPS system. Be certain to indicate identifiers and cardinality constraints.

04/03/2020 VINEET KUMAR 100


Noida Institute of Engineering and Technology,
Greater Noida
Department of CSE

The Enhanced ER Model

1. Generalization
2. Specialization
3. Aggregation

Generalization
Generalization is the process of
extracting common properties from
a set of entities and create a
generalized entity from it.
 It is a bottom-up approach in
which two or more entities can be
generalized to a higher level entity if
they have some attributes in
common.
04/03/2020 VINEET KUMAR 101
Generalization
• A bottom-up design process – combine a number of entity sets that
share the same features into a higher-level entity set.
• Specialization and generalization are simple inversions of each other;
they are represented in an E-R diagram in the same way.
• The terms specialization and generalization are used interchangeably.
Noida Institute of Engineering and Technology,
Greater Noida
Department of CSE

The Enhanced ER Model

Specialization
Specialization is opposite to
Generalization.
It is a top-down approach in which
one higher level entity can be broken
down into two lower level entity.
 In specialization, a higher level
entity may not have any lower-level
entity sets, it's possible.

04/03/2020 VINEET KUMAR 103


Specialization Example
Aggregation
 Consider the ternary relationship works-on, which we
saw earlier
 Suppose we want to record managers for tasks
performed by an
employee at a branch
Noida Institute of Engineering and Technology,
Greater Noida
Department of CSE

The Enhanced ER Model

Aggregation
Aggregration is a process when relation between two entities is treated as
a single entity.

04/03/2020 VINEET KUMAR 106


04/03/2020 VINEET KUMAR 107

You might also like