Unit-1 Dbms
Unit-1 Dbms
Course Objectives
06-12-2021 Side 1
Database Management System
06-12-2021 Side 2
Database Management System
Learning Outcomes
list and define the fundamental concepts of DBMS.
Introduction to SQL:
Characteristics of SQL. Advantage of SQL. SQL data types 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 in SQL. induction over
06-12-2021 Side 5
Unit-III
Data Base Design & Normalization
06-12-2021 Side 6
Unit-IV
Transaction Processing Concepts
Transaction system, Testing of serializability, Serializability of
schedules, conflict & view serializable schedule, recoverability,
Recovery from transaction failures, log based recovery,
checkpoints, deadlock handling.
06-12-2021 Side 7
Overview of Database Management System
Data is a collection of facts and figures that can be processed
to produce the information.
06-12-2021 Side 8
Characteristics of DBMS
Real-world entity
Relation-based tables
Less redundancy
Consistency
Query Language
Multiple views
Security
06-12-2021 Side 9
Users of DBMS
Administrator
Designers
End users
06-12-2021 Side 10
Advantages of DBMS
Controls database redundancy: It can control data redundancy
because it stores all the data in one single database file and that recorded
data is placed in the database.
06-12-2021 Side 11
Advantages of DBMS
06-12-2021 Side 12
Disadvantages of DBMS
Cost of Hardware and Software: It requires a high speed of data
processor and large memory size to run DBMS software.
Size: It occupies a large space of disks and large memory to run them
efficiently.
06-12-2021 Side 13
Database Management Vs File Management System
File Management System Database Management System
Small systems like C++ or Java Large systems like Oracle or Sybase.
program.
Relatively cheap Relatively expensive
Have isolated data and simple Have shared data and complex &
backup/recovery mechanism sophisticated backup/recovery mechanism.
06-12-2021 Side 14
Database System Concepts and Architecture
DBMS Architecture
The DBMS design depends upon its architecture. The basic
client/server architecture is used to deal with a large number
of PCs, web servers, database servers and other components
that are connected with networks.
06-12-2021 Side 15
Types of DBMS Architecture
06-12-2021 Side 16
1-Tier Architecture
In this architecture, the database is directly available to the user.
It means the user can directly have the DBMS and use it.
06-12-2021 Side 19
3-Tier Architecture
The 3-Tier architecture contains another layer between the
client and server. In this architecture, client can't directly
communicate with the server.
The application on the client-end interacts with an
application server which further communicates with the
database system.
End user has no idea about the existence of the database
beyond the application server. The database also has no
idea about any other user beyond the application.
The 3-Tier architecture is used in case of large web
application.
06-12-2021 Side 20
3-Tier Architecture
06-12-2021 Side 21
Three Level Architecture of DBMS
06-12-2021 Side 22
Three Level Architecture of DBMS
It is also known as three schema architecture of DBMS.
06-12-2021 Side 24
Conceptual Level
It describes the design of a database at the conceptual level.
Conceptual level is also known as logical level.
Defines how the data is organized and how the relations among
them are associated.
06-12-2021 Side 28
Database Schema
A database schema can be divided broadly into two
categories:
06-12-2021 Side 30
Database Instance
A DBMS ensures that its every instance (state) is in a valid
state, by diligently following all the validations,
constraints, and conditions that the database designers have
imposed.
06-12-2021 Side 32
Hierarchical Data Model
In this model, files are related in a parent/child manner.
Like file system, this model also had some limitations like
complex implementation, lack structural independence.
06-12-2021 Side 34
Network Data Model
In this model, files are related as owners and members.
06-12-2021 Side 39
Physical Data Independence
It indicates that the physical storage structures or devices
could be changed without affecting the conceptual schema.
All the schemas are logical, and the actual data is stored in
bit format on the disk.
06-12-2021 Side 42
Data Definition Language (DDL)
DDL stands for Data Definition Language. It is used to
define database structure or pattern.
06-12-2021 Side 45
Data Manipulation Language (DML)
Merge: It performs UPSERT operation, i.e., insert or
update operations.
06-12-2021 Side 46
Data Control Language (DCL)
DCL stands for Data Control Language. It is used to
retrieve the stored or saved data.
The DCL execution is transactional. It also has rollback
parameters.
(But in Oracle database, the execution of data control
language does not have the feature of rolling back.)
The tasks performed by DCL are:
Grant: used to give user access privileges to a database.
Revoke: It is used to take back permissions from the user.
There are the following operations which have the
authorization of Revoke:
CONNECT, INSERT, USAGE, EXECUTE, DELETE,
UPDATE and SELECT.
06-12-2021 Side 47
Transaction Control Language (TCL)
06-12-2021 Side 48
Data Sub Language (DSL)
It is a combination of both DML and DDL.
DSL = DDL + DML
06-12-2021 Side 49
Storage Definition Language (SDL)
06-12-2021 Side 50
View Definition Language (VDL)
It is defined as a language used to specify user’s views
(external schema) and their mappings to the conceptual
schema.
06-12-2021 Side 52
Fourth-Generation Languages (4GL)
It is compact, efficient and non-procedural programming
language that is used to improve the productivity of the
DBMS.
SQL
Report Generators
Spreadsheets
Code Generators
06-12-2021 Side 55
Overall Database Structure
Query Processor include
DDL interpreter, which interprets DDL statements and
records the definitions in the data dictionary.
DML compiler, which translates DML statements in a
query language written into an evaluation plan consisting
of low-level instructions that the query evaluation engine
understands.
A query can usually be translated into any of several alternative
evaluation plans that all give the same result. The DML
compiler also performs query optimization, that is, it picks the
lowest cost evaluation plan among the alternatives.
Query evaluation engine, which executes low-level
instructions generated by the DML compiler.
06-12-2021 Side 56
Overall Database Structure
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.
The storage manager is responsible for the interaction with
the file manager.
The raw data are stored on the disk using the file system,
which is usually provided by a conventional operating system.
The storage manager translates the various DML statements
into low-level file-system commands.
Thus, the storage manager is responsible for storing,
retrieving, and updating data in the database.
06-12-2021 Side 57
Overall Database Structure
A transaction is a collection of operations that performs a
single logical function in a database application.
Each transaction is a unit of both atomicity and consistency.
Thus, we require that transactions do not violate any
database-consistency constraints.
That is, if the database was consistent when a transaction
started, the database must be consistent when the transaction
successfully terminates.
Transaction - manager ensures that the database remains in a
consistent (correct) state despite of system failures (e.g.,
power failures and operating system crashes) and transaction
failures.
06-12-2021 Side 58
Overall Database Structure
The storage manager components include:
Authorization and integrity manager: tests for the
satisfaction of integrity constraints and checks the authority of
users to access data.
Transaction manager: ensures that the database remains in a
consistent state despite of system failures, and that concurrent
transaction executions proceed without conflicting.
File manager: manages the allocation of space on disk and the
data structures used to represent information stored on disk.
Buffer manager: is responsible for fetching data from disk
storage into main memory and deciding what data to cache in
main memory. The buffer manager is a critical part of the
database system, since it enables the database to handle data
sizes that are much larger than the size of main memory.
06-12-2021 Side 59
Entity
An entity can be a real-world object, that can be easily
identifiable.
For example, in a school database, students, teachers and
courses offered can be considered as entities.
All these entities have some attributes or properties that give
them their identity.
An entity set is a collection of similar types of entities. An
entity set may contain entities with attribute sharing similar
values.
For example, a Students set may contain all the students of
University, similarly a Teachers set may contain all the
teachers of University from all faculties.
06-12-2021 Side 60
Attributes
Entities are represented by means of their properties,
called as attributes.
06-12-2021 Side 65
Relationship
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.
One-to-one − One entity from entity set A can be associated
with at most one entity of entity set B and vice versa.
06-12-2021 Side 66
Relationship
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.
06-12-2021 Side 67
Entity- Relationship Diagram
Attributes
Attributes are the properties of entities. Attributes are
represented by means of ellipses. Every ellipse represents one
attribute and is directly connected to its entity (rectangle).
06-12-2021 Side 69
Relationship
Many-to-many − One entity from A can be associated
with more than one entity from B and vice versa.
06-12-2021 Side 70
Entity- Relationship Diagram
ER Model is represented by means of an ER diagram. Any
object, for example, entities, attributes of an entity,
relationship sets, and attributes of relationship sets, can be
represented with the help of an ER diagram.
Entity
Entities are represented by means of rectangles. Rectangles
are named with the entity set they represent.
06-12-2021 Side 71
Entity- Relationship Diagram
06-12-2021 Side 72
Entity- Relationship Diagram
Multivalued attributes are depicted by double ellipse.
06-12-2021 Side 73
Entity- Relationship Diagram
Derived attributes are depicted by dashed ellipse.
06-12-2021 Side 74
Entity- Relationship Diagram
Relationship
Relationships are represented by diamond-shaped box.
Name of the relationship is written inside the diamond-box.
All the entities (rectangles) participating in a relationship, are
connected to it by a line.
Binary Relationship and Cardinality
A relationship where two entities are participating is called
a binary relationship.
Cardinality is the number of instance of an entity from a
relation that can be associated with the relation.
06-12-2021 Side 75
Entity- Relationship Diagram
One-to-one − When only one instance of an entity is
associated with the relationship, it is marked as '1:1'. The
following image reflects that only one instance of each
entity should be associated with the relationship. It depicts
one-to-one relationship.
06-12-2021 Side 76
Entity- Relationship Diagram
One-to-many − When more than one instance of an entity is
associated with a relationship, it is marked as '1:N'. The
following image reflects that only one instance of entity on
the left and more than one instance of an entity on the right
can be associated with the relationship. It depicts one-to-
many relationship.
06-12-2021 Side 77
Entity- Relationship Diagram
Many-to-one − When more than one instance of entity is
associated with the relationship, it is marked as 'N:1'. The
following image reflects that more than one instance of an entity
on the left and only one instance of an entity on the right can be
associated with the relationship. It depicts many-to-one
relationship.
06-12-2021 Side 78
Entity- Relationship Diagram
Many-to-many − The following image reflects that more than
one instance of an entity on the left and more than one
instance of an entity on the right can be associated with the
relationship. It depicts many-to-many relationship.
06-12-2021 Side 79
E-R model
ER model stands for an Entity-Relationship model.
06-12-2021 Side 81
Components of E-R Diagram
06-12-2021 Side 82
Notation of ER diagram
Database can be represented using the notations. In ER diagram,
many notations are used to express the cardinality. These notations
are as follows:
06-12-2021 Side 83
Mapping Constraints
A mapping constraint is a data constraint that expresses the
number of entities to which another entity can be related via a
relationship set.
06-12-2021 Side 85
Types of key
06-12-2021 Side 86
Primary key
It is the first key which is used to identify one and only one
instance of an entity uniquely. An entity can contain multiple
keys as we saw in PERSON table. The key which is most
suitable from those lists become a primary key.
06-12-2021 Side 87
Primary key
06-12-2021 Side 88
Candidate Key
A candidate key is an attribute or set of an attribute which
can uniquely identify a tuple.
The remaining attributes except for primary key are
considered as a candidate key. The candidate keys are as
strong as the primary key.
For example: In the EMPLOYEE table, id is best suited for
the primary key. Rest of the attributes like SSN,
Passport_Number, and License_Number, etc. are considered
as a candidate key.
06-12-2021 Side 89
Super Key
Super key is a set of an attribute which can uniquely identify
a tuple. Super key is a superset of a candidate key.
06-12-2021 Side 90
Foreign Key
Foreign keys are the column of the table which is used to
point the primary key of another table.
06-12-2021 Side 92
Generalization
Generalization is like a bottom-up approach in which two or
more entities of lower level combine to form a higher level
entity if they have some attributes in common.
In generalization, an entity of a higher level can also combine
with the entities of the lower level to form a further higher
level entity.
Generalization is more like subclass and superclass system,
but the only difference is the approach. Generalization uses the
bottom-up approach.
In generalization, entities are combined to form a more
generalized entity, i.e., subclasses are combined to make a
superclass.
For example, Faculty and Student entities can be generalized
and create a higher level entity Person.
06-12-2021 Side 93
Generalization
06-12-2021 Side 94
Specialization
Specialization is a top-down approach, and it is opposite to
Generalization. In specialization, one higher level entity can
be broken down into two lower level entities.
06-12-2021 Side 96
Aggregation
06-12-2021 Side 98
Reduction of ER diagram to Table
06-12-2021 Side 99
Reduction of ER diagram to Table
Entity type becomes a table.
In the given ER diagram, LECTURER, STUDENT, SUBJECT
and COURSE forms individual tables.