DBMS
DBMS
of Technology, Gorakhpur
Dr. D. S. Singh
Associate Professor
Department of ITCA
MMMUT Gorakhpur
Email: [email protected]
17-03-2021 Side 1
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
17-03-2021 Side 2
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
17-03-2021 Side 3
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
Unit-I
Introduction
Introduction: An Overview and motivation of Database
Management System, Characteristics of database approach,
Advantages of using DBMS approach, Database System vs File
System, Database System Concept and Architecture, Data Model &
its types, Schema and Instances, Data Independence, Database
Language and Interfaces, Data Definitions Language, DML,
Overall Database Structure.
Unit-II
Relational data Model and Language
Relational Data Model Concepts, Consistency constraints,
Integrity Constraints, Entity Integrity, Referential Integrity,
Keys Constraints, Domain Constraints, Relational Algebra,
Relational Calculus, Tuple and Domain Calculus.
Introduction to 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
17-03-2021 Side 6
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
Unit-III
Data Base Design & Normalization
Database Anomalies, Functional Dependencies, Normal
Forms, First, Second, Third Normal Forms, BCNF, Fourth and
Fifth Normal Forms, Closure of a set of FDs and MVDs,
Armstrong’s axioms, Minimal or Canonical cover of FDs,
Inclusion Dependence, Loss Less Join Decompositions,
Dependency Preserving, Normalization using FD, MVD, and
JDS, Alternative Approaches to Database Design.
17-03-2021 Side 7
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
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.
Distributed Database
Characteristics of Distributed Database, Advantages and
disadvantages of distributed database, Distributed Data Storage.
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.
17-03-2021 Side 8
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
17-03-2021 Side 9
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
17-03-2021 Side 10
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
Characteristics of DBMS
➢ Real-world entity
➢ Relation-based tables
➢ Less redundancy
➢ Consistency
➢ Query Language
➢ Multiple views
➢ Security
17-03-2021 Side 11
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
Users of DBMS
➢ Administrator
➢ Designers
➢ End users
17-03-2021 Side 12
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
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.
17-03-2021 Side 13
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
Advantages of DBMS
17-03-2021 Side 14
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
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.
17-03-2021 Side 15
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
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.
17-03-2021 Side 16
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
17-03-2021 Side 17
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
17-03-2021 Side 18
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
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.
2-Tier Architecture
➢ The 2-Tier architecture is same as basic client-server. In the
two-tier architecture, applications on the client end can
directly communicate with the database at the server side.
For this interaction, API's like: ODBC, JDBC are used.
17-03-2021
establishes a connection with the server side. Side 20
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
2-Tier Architecture
17-03-2021 Side 21
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
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.
3-Tier Architecture
17-03-2021 Side 23
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
17-03-2021 Side 24
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
Internal Level
➢ The internal level has an internal schema which describes
the physical storage structure of the database.
17-03-2021 Side 26
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
Conceptual Level
➢ It describes the design of a database at the conceptual level.
Conceptual level is also known as logical level.
External Level
➢ At the external level, a database contains several schemas
that sometimes called as subschema. The subschema is used
to describe the different view of the database.
Database Schema
➢ Skeleton that represents the logical view of the entire database.
➢ Defines how the data is organized and how the relations among
them are associated.
Database Schema
17-03-2021 Side 30
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
Database Schema
A database schema can be divided broadly into two
categories:
Database Instance
➢ Database schema is the skeleton structure of database.
17-03-2021 Side 32
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
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.
Data Models
➢ Data models define how the logical structure of a database
is modeled.
➢ Data Models are fundamental entities to introduce
abstraction in a DBMS.
➢ Data models define how data is connected to each other and
how they are processed and stored inside the system.
➢ The very first data model could be flat data-models, where
all the data used are to be kept in the same plane.
➢ Earlier data models were not so scientific; hence they were
prone to introduce lots of duplication and update anomalies.
17-03-2021 Side 34
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
➢ Like file system, this model also had some limitations like
complex implementation, lack structural independence.
17-03-2021 Side 35
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
17-03-2021 Side 36
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
Data Independence
➢ A database system normally contains a lot of data in addition
to users’ data. For example, it stores data about data, known
as metadata, to locate and retrieve data easily.
Data Independence
➢ The major objective of 3-level architecture of DBMS is to
provide data independence which means that upper levels
are unaffected by changes in lower levels.
Data Independence
➢ Metadata itself follows a layered architecture, so that when
we change data at one layer, it does not affect the data at
another level. This data is independent but mapped to each
other.
17-03-2021 Side 41
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
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.
17-03-2021 Side 44
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
17-03-2021 Side 48
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
17-03-2021 Side 50
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
17-03-2021 Side 51
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
17-03-2021 Side 52
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
17-03-2021 Side 54
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
✓SQL
✓Report Generators
✓Spreadsheets
✓Code Generators
17-03-2021 Side 57
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
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.
17-03-2021 Side 62
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
Attributes
➢ Entities are represented by means of their properties,
called as attributes.
Type of Attributes
These attribute types can come together in a way like:
Keys
➢ Key is an attribute or collection of attributes that uniquely
identifies an entity among entity set.
➢ For example, the roll_number of a student makes him/her
identifiable among students.
✓ 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.
17-03-2021 Side 66
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
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. Like entities, a relationship too can have attributes.
These attributes are called descriptive attributes.
Degree of Relationship
➢ The number of participating entities in a relationship
defines the degree of the relationship.
➢ For example, Binary = degree 2,Ternary = degree 3
17-03-2021 Side 67
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
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.
17-03-2021 Side 68
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
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.
17-03-2021 Side 69
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
Relationship
✓ 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.
17-03-2021 Side 70
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
Relationship
✓Many-to-many − One entity from A can be associated
with more than one entity from B and vice versa.
17-03-2021 Side 71
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
Entity
Entities are represented by means of rectangles. Rectangles
are named with the entity set they represent.
17-03-2021 Side 72
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
17-03-2021 Side 74
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
17-03-2021 Side 75
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
17-03-2021 Side 76
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
17-03-2021 Side 77
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
17-03-2021 Side 78
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
17-03-2021 Side 79
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
17-03-2021 Side 80
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
17-03-2021 Side 81
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
E-R model
➢ ER model stands for an Entity-Relationship model.
E-R model
For example, Suppose we design a school database. In this
database, the student will be an entity with attributes like address,
name, id, age, etc. The address can be another entity with
attributes like city, street name, pin code, etc and there will be a
relationship between them.
17-03-2021 Side 83
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
17-03-2021 Side 84
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
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:
17-03-2021 Side 85
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
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.
17-03-2021 Side 87
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
Types of key
17-03-2021 Side 88
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
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.
17-03-2021 Side 89
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
Primary key
17-03-2021 Side 90
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
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.
17-03-2021 Side 91
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
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.
17-03-2021 Side 92
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
Foreign Key
❖ Foreign keys are the column of the table which is used to
point the primary key of another table.
Foreign Key
17-03-2021 Side 94
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
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.
17-03-2021 Side 95
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
Generalization
17-03-2021 Side 96
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
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.
Specialization
17-03-2021 Side 98
Madan Mohan Malaviya Univ. of Technology, Gorakhpur
Aggregation
Aggregation
References
1. Date C J, “An Introduction To Database System”, Addision Wesley.
3. https://www.javatpoint.com/dbms-tutorial
4. https://www.tutorialspoint.com/dbms/index.htm