LM-DBMS
LM-DBMS
LM-DBMS
DEPARTMENT
OF
COMPUTER SCIENCE AND ENGINEERING
HANDOUT
on
Vision
Mission
============================================================
Program Outcomes:
Graduates of the Computer Science and Engineering Program will have
Engineering Graduates will be able to:
1. Engineering knowledge: Apply the knowledge of mathematics, science,
engineering fundamentals, and an engineering specialization to the solution
of complex engineering problems.
12. Life-long learning: Recognize the need for, and have the preparation
and ability to engage in independent and life-long learning in the broadest
context of technological change.
1 2 3 4 5 6 7 8 9 10 11 12
CO1 3 2
CO2 2 2 1 3
CO3 3 3 2 1
CO4 2 3 1
CO5 2 3 1
3- High 2- Medium 1-Low
Prescribed Text Books
1. Korth & Sudarshan, Database system concept, MH.
2. Raghu Ramakrishnan, Johannes Gehrke, Database Management
Systems, MH.
Reference Text Books
1. Elmasri Navrate, Fundamentals of Database Systems, Pearson
Education.
2. C.J.Date, Introduction to Database Systems, Pearson Education.
Axioms 1
attribute closure 2 3
Lossless join, dependency preserving decomposition 2
Normal forms-First, second third normal forms 2
Boyce- Codd normal form 1
UNIT – 4: TRANSACTION MANAGEMENT
Concurrency control 1
Concurrent execution of transactions, anomalies 2
Lock-based protocols:2PL, strict 2PL, rigorous 2PL 1
Timestamp-based protocols 3
2
Thomas write rule , Deadlock handling: deadlock
prevention 2
Failure classification 1
Different types of Recovery techniques-deferred update, 2
immediate update 3
Seminar Topics
Serializability
Normalization
Transaction Management
Lock-based protocols
Crash recovery techniques
UNIT-1
DATABASE MANAGEMENT SYSTEMS
Objectives:
Syllabus:
Learning Outcomes:
• But over a long period of time files may be in different formats, and
Application programs may be in different languages.
• So we can see there are problems with the straight file processing
approach:
• Data isolation
• Integrity problems
• Atomicity Problems
• Security problems
• Every user of the system should be able to access only the data
they are permitted to see.
• Data Abstraction
• The major purpose of a database system is to provide users with an
abstract view of the system. The system hides certain details of how
data is stored and maintained.
• Complexity should be hidden from database users.
• There are three levels of abstraction:
Physical Level
• Deals with how the data are stored.
• E.g. index, B-tree, hashing.
• Lowest level of abstraction.
• Complex low-level structures described in detail.
Conceptual Level
• Next highest level of abstraction.
View Level
• Highest level.
• Data models
Entity-Relationship model
• The set of all entities of the same type is called as the entity set.
• Similarly, the set of all relationships of the same type is called as the
relationship set.
Relational Model
• The degree, also called arity, of a relation is the number of fields in it.
• The cardinality of a relation is the number of tuples in it.
• For example, for the relation shown in figure 1.4, the degree of the
relation is 5, and cardinality is 6.
Network Model
Hierarchical Model
• It is similar to the network model.
• Entity-Relationship Model
• In this, data is represented as a collection of entities and relationships
among the entities.
• The set of all entities of the same type is called as the entity set.
• Similarly, the set of all relationships of the same type is called as the
relationship set.
7.1 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).
Fig. 1.11: E-R Diagram that shows composite, multivalued and derived
attributes.
7.2 Keys
• Key is a set of attributes that uniquely identify an entity set from set
of entities.
• E.g. suppose student entity consists of the attributes (Rollno, Name,
DOB, Address) then the attribute Rollno identifies uniquely a student
from set of students. Hence, Rollno is the key for student entity.
• Relationship Types
• Relationship is an association among two or more entities.
• There are three kinds of relationships
• Unary Relationship – is a relationship that associates an entity with the
same entity. E.g. Figure 1.12 shows Unary Relationship(works-for)
Fig. 1.14: Mapping cardinalities (a) one to one (b) one to many
Fig. 1.15: Mapping cardinalities (a) many to one (b) many to many
• Many to many. An entity in A is associated with any number of entities
in B, and an entity in B is associated with any number of entities in A.
Figure 1.15 shows many-to-one and many-to-many mapping cardinalities.
• Weak entity set – Entity set without primary key is termed as a weak
entity set.
• A weak entity set can be identified uniquely only by considering some
of its attributes in conjunction with the primary key of another entity,
called the owner set.
• Owner entity set and weak entity set must participate in a one-to-
many relationship.
• This relationship set is called the identifying relationship set of the
weak entity set. The weak entity set must have total participation in
the identifying relationship set.
• Strong entity set - An entity set that has a primary key is called as a
strong entity set.
E.g. Figure 1.18 shows weak and strong entity sets. Here, payment is a
weak entity set and loan is a strong entity set. Primary key for loan is
loan-number and primary key for payment is {loan-number,
payment-number}.
• Enhanced ER modeling
• Enhanced ER modelling includes specialization and generalization.
• Specialization – The process of identifying subsets of an entity set
that share some distinguishing characteristics is known as
specialization.
• It is also called as top-down design process.
• Here, after identifying a general entity, its sub entities are identified
that share the common characteristics of the general entity.
• Generalization – The process of identifying some common
characteristics of a collection of entity sets and creating a new entity
set that contains entities possessing these common characteristics is
known as generalization.
• It is also called as bottom-up design process.
• In ER diagram, generalization/specialization is denoted by ISA
relationship.
• We can inherit the properties of super class (general entity) into sub
class (specialized entities) by ISA relationship.
particular payment for a specific loan. The date and amount are
recorded for each payment
• the bank would keep track of deposits and withdrawals from
savings and checking accounts.
Keeping in mind the above requirements, the design of the database
proceeds as follows;
Step1: Identify the entity sets and their attributes
The entity sets that could be identified for Banking Enterprise are:
• branch entity set, with attributes branch-name, branch-city, and assets
• customer entity set, with attributes customer-id, customer-name,
customer-street, and customer-city
• employee entity set, with attributes employee-id, employee-name,
telephone-number, salary, and manager. Additional descriptive features
are the multi-valued attribute dependent-name, the base attribute start-
date, and the derived attribute employment-length
• Two account entity sets—savings-account and checking-account—with the
common attributes of account-number and balance; in addition, savings-
account has the attribute interest-rate and checking-account has the
attribute overdraft-amount
• The loan entity set, with the attributes loan-number, amount, and
originating-branch
• The weak entity set loan-payment, with attributes payment-number,
payment-date, and payment-amount
Step3: Draw the E-R diagram with the identified entity sets and their
relationships
Conversion Guidelines
Relational Schema:
Relational Schema:
Relational Schema:
• Conversion of Generalization
• Conversion of Aggregation
UNIT-I
Assignment-Cum-Tutorial Questions
SECTION-A
Objective Questions
1. Database applications were built directly on top of file system to
overcome the following drawbacks of using file-systems [ ]
(a) Data redundancy and inconsistency
(b) Difficulty in accessing data
(c) Data isolation
(d) Integrity problems
(A) (a) (B) (a) and (d)
(C) (a), (b) and (c) (D) (a), (b), (c) and (d)
2. Data model is a collection of conceptual tools for describing [ ]
(A) Data and data relationships (B) Semantics
(C) Consistency constraints (D) All of the above
3. Identify the correct statement related to Physical level Abstraction:
(A) describes how a record is stored [ ]
(B) describes how schema is stored in a data base
(C) hides details of data types
(D) describes the data relationships in a data base
5. An ER Model includes
I. An ER diagram portraying entity types.
II. Attributes for each entity type
III. Relationships among entity types.
IV. Semantic integrity constraints that reflects the business rules
about data not captured in the ER diagram. [ ]
and the time and place of the class meetings. For each student class pair
a grade is recorded. Determine the entities and relationships.
13) Design a university level database for maintaining the student details of
different colleges in the university. Only consider the personal details and
the college and branch details of the student belong. represent the same
using an ER diagram.
14) A company database needs to store information about employees( ssn,
name, designation, salary, address, phone), departments(dno, dname,
budget) and children of employees(name, age). Employee works in
departments; each department is managed by an employee, a child must
be identified uniquely by name when the parent(who is an employee;
assume that only one parent works for the company) is known. We are
not interested in information about child once the parent leaves the
organization. Draw an ER diagram that captures this information.
15) Convert the following ER diagram into Relational tables.
SECTION-C
UNIT – II
The degree, also called arity, of a relation is the number of fields in it.
The student table has five columns: sid, name, login, age, and gpa.
Each row of this table records information about a student.
Relation schema: A relation schema consists of a list of attributes
and their corresponding domains.
Domain of an attribute represents the set of permitted values of an
attribute.
For example, the domain of the name attribute of student relation is
the set of all possible student names.
Thus, the relation schema of the student relation can be written as
student(sid:integer, name:string, login:string, age:integer, gpa:float)
Relation instance – refers to a specific instance of a relation, i.e.
containing a specific set of rows.
For example, the instance of student relation has 6 rows
corresponding to 6 students.
Relation Cardinality - is the number of tuples or rows in the relation.
For example, cardinality of student relation is 6 as it has 6 rows.
Relation Degree or Arity- is the number of attributes (or columns) in
the relation.
For example, degree or arity of student relation is 5 as it has 5
columns.
NPTEL
Example:
CREATE TABLEStudent (sidnumber(3) UNIQUE,
namevarchar(60) NOT NULL,
loginvarchar(20),
Age number(3),
gpa number(2,2));
Key-
A key is a single or combination of multiple fields in a table. It is
used to fetch or retrieve record(s) from a table according to the
condition/requirement.
Keys are also used to create relationship among different database
tables or views.
We have following types of keys in SQL which are used to fetch
records from tables and to make relationship among tables or views.
Basic Operations:
selection ( σ ),
Projection ( ∏ ),
Union ( ∪ ) ,
Set difference ( - ) and
Cartesian Product (X)
Operation Purpose Notation
o SetIntersection(R1∩R2):ItgivesthesetthatcontainsalltuplesofR1
thatalsobelongto
R2(orequivalently,alltuplesofR2thatalsobelongtoR1),butnoothert
uples.Settheoretic notationforR1∩R2={x:x R1andx R2}.
o SemiJoin(R1⋉R2):Thisissimilartonaturaljoinandtheresultyielde
dbythisisonlythe
setofalltuplesinfirstrelationforwhichthereisatupleinsecondrelatio
nthatisequalon their common attribute names.
o Antijoin:(R1 R2):Itisconverseofsemijoinoperation.Itreturnsalltu
plesintheresult
ofexpressionR1suchthattherearenotuplesintheresultofR2withma
tchingvaluesforthe sharedattributes.
1. SQL:
Figure: SQLCommands
SQL Commands
Syntax:
Example
create table branch
(branch_name varhar(15),
branch_city varhar(30),
assets integer);
2) Character DataTypes:
SQL Operators- The symbols which are used to perform logical and
1) ArithmeticOperators:
Arithmetic Example/Descripti
Operators on
+ (Addition) A+B
– (Subtraction) A-B
* (multiplication) A*B
/ (Division) A/B
% (Modulus) A%B
2) RelationalOperators:
Relational operators in SQL are used to find the relation between two
columns. i.e. to compare the values of two columns in SQL statements.
Relational Example/Description
Operators
> x > y (x is greater than y)
< x < y (x is less than y)
>= x >= y (x is greater than or equal to
y)
<= x <= y (x is less than or equal to y)
= x <= y (x is less than or equal to y)
!= or <> x != y or x <> y (x is not equal to y)
!< x !< y (x is not less than y)
!> x !> y (x is not greater than y)
3. LogicalOperators:
Logical operators in SQL are used to perform logical operations on the
given expressions in SQL statements. There are many operators in SQL
which are used in SQL statements in the WHERE clause. They are,
AND
OR
NOT
BETWEEN…AND
IS NULL, IS NOTNULL
LIKE
UNIQUE
The drop table command deletes all information about the dropped
relation from the database.
The alter table command is used to add attributes to an existing
relation:
alter table radd A D
whereA is the name of the attribute to be added to relation r
and D is the domain of A.
All tuples in the relation are assigned null as the value for the
new attribute.
The alter table command can also be used to drop attributes of a
relation:
alter table r drop A
where A is the name of an attribute of relation r
Dropping of attributes not supported by many databases
Tables: consider the following figure for writing queries
customer relation
Ai represents an attribute
Rirepresents a relation
P is a predicate.
The result of an SQL query is a relation.
The select clause list the attributes desired in the result of a query
Example: find the names of all branches in the loan relation:
selectbranch_namefrom loan;
NOTE: SQL names are case insensitive (i.e., you may use upper- or
lower-case letters.)
Example: Branch_Name ≡ BRANCH_NAME ≡ branch_name
Some people use upper case wherever we use bold font.
The where clause specifies conditions that the result must satisfy.
To find all loan number for loans made at the Perryridge branch
with loan amounts greater than $1200.
selectloan_number
from loan
where branch_name ='Perryridge'and amount > 1200
whereborrower.loan_number = loan.loan_numberand
branch_name = 'Perryridge'
The Rename Operation:
selectcustomer_name
from customer
wherecustomer_streetlike '% Main%'
SQL supports a variety of string operations such as
concatenation (using “||”)
converting from upper to lower case (and vice versa)
finding string length, extracting substrings, etc.
6. NOT NULL - Indicates that a column cannot store NULL value. E.g.
Account_numberchar(10) not null.
Example:
CREATE TABLEStudent (sidnumber(3) NOT NULL,
Name varchar(60) NOT NULL,
Age number(3));
7. UNIQUE - The UNIQUE constraint imposes that every value in a
column or set of columns be unique. It means that no two rows of
a table can have duplicate values in a specified column or set of
columns. E.g. UNIQUE(Name, DOB).
Example:
CREATE TABLEStudent (sidnumber(3) UNIQUE,
Name varchar(60) NOT NULL,
Age number(3));
8. FOREIGN KEY – Ensure the referential integrity of the data in one
table to match values in another table. Ensure that the foreign key
in the child table must match with the primary key in the parent
table.
Example:
CREATE TABLEStudent (sidnumber(3) UNIQUE,
namevarchar(60) NOT NULL,
loginvarchar(20),
Age number(3),
gpa number(2,2));
only one PRIMARY KEY can be more than one UNIQUE constraint
defined for each table can be defined for each table
GROUP BY Cust_ID
Query Results
Cust_ID Sum
(Amount_in_Dollars)
101 8755.00
103 4555.00
104 3050.00
Figure: Example of Group BY Clause
HAVING: (NPTEL)
The HAVING clause is used along with the GROUP BY clause. The
HAVING clause can be used to select and reject row groups.
The format of the HAVING clause is similar to the WHERE clause,
consisting of the keyword HAVING followed by a search condition.
The HAVING clause thus specifies a search condition for groups.
GROUP BY Cust_ID
Cust_ID Sum
(Amount_in_Dollars)
101 8755.00
103 4555.00
1. UNION – Let R and S are two union compatible relations. Then the
UNION operation returns the tuples that occur either in R or S or
both.
Two relation instances are said to be union-compatible if the
following conditions hold:
they have the same number of the columns, and
Corresponding columns, taken in order from left to right, have the
same data types.
2. INTERSECT – Let R and S are two union compatible relations. Then
the INTERSECT operation returns the tuples that are common to the
two relations.
3. MINUS – If R and S are two union compatible relations then R MINUS
S returns the tuples that are present in R but not in S.
IBM_Desktop Dell_Desktop
Sailors Reserves
Boats
Find the names of sailors who have reserved a red or a green boat.
SELECT S.sname
FROM Sailors S, Reserves R, Boats B
WHERE S.sid = R.sid AND R.bid = B.bid AND B.color = ‘red’
UNION
SELECT S.sname
FROM Sailors S, Reserves R, Boats B
WHERE S.sid = R.sid AND R.bid = B.bid AND B.color = ‘green’;
Find the sids of sailors who have reserved both red and green boats.
SELECT S.sid
Find the sids of sailors who have reserved red boats but not green
boats.
SELECT S.sid
FROM Reserves R, Boats B
WHERE R.bid = B.bid AND B.color = ‘red’
MINUS
SELECT S.sid
FROM Reserves R, Boats B
WHERE R.bid = B.bid AND B.color = ‘green’;
Find the sids of sailors who have reserved red boats but not green boats.
SELECT S.sid
FROM Reserves R, Boats B
WHERE R.bid = B.bid AND B.color = ‘red’
MINUS
SELECT S.sid
FROM Reserves R, Boats B
WHERE R.bid = B.bid AND B.color = ‘green’;
EXAMPLES
5. Nested Queries:
A nested query is a query that has another query embedded within it.
The embedded query is called a sub query.
Find the names of sailors who have not reserved boat 103.
SELECT S.sname
FROM Sailors S
WHERE S.sid NOT IN ( SELECTR.sid
FROM Reserves R
WHERE R.bid = 103 )
UNIT-II
Assignment-Cum-Tutorial Questions
SECTION-A
Objective Questions
1. For every teacher record in a database, there is an attribute called
Department. This attribute specifies the department name. At times, the
name may contain the numeric department id concatenated with it.
However, it can never comprise only of the department id. Department
name is optional in a teacher record.
Identify the correct components for the domain of the attribute Department.
[ ]
3. Identify the valid data-types, which can be used in SQL to define the type
of data. [ ]
a) Varchar b) string c) real d) float
SECTION-C
SELECT P1.address FROM Cinema P1, Such that it always finds the
addresses of theaters of theaters with maximum capacity?
(a) WHERE P1.capacity > = All (select P2. capacity from Cinema P2)
(b) WHERE P1.capacity > = Any (select P2. capacity from Cinema P2)
(c) WHERE P1.capacity > All (select max (P2. capacity) from Cinema P2)
(d) WHERE P1.capacity >Any (select max (P2. capacity) from Cinema P2)
What pids are returned by the following SQL query for the above instance of
the tables?
Objectives:
Learning Outcomes:
UNIT-III
Unit - III
Database Design
Functional Dependencies and Normalization for Relational Databases
1. Functional Dependencies
The single most important concept in relational schema design is a
functional dependency.
A Functional Dependency describes a relationship between attributes within a
single relation.
An attribute is functionally dependent on another if we can use the value of
one attribute to determine the value of another. Formally, functional
dependency is defined as;
Functional dependency – In agiven relation R, X and Y are attributes.
Attribute Y is functionally dependent on attribute X if each value of X
determines exactly one value of Y. This is represented as X Y.
For example, consider the following relation
Reports(Student#, Course#, CourseName, Iname, Room#, Marks, Grade)
In this relation, {Student#, Course#} together can determine exactly one
value of Marks. This can be symbolically represented as
{Student#, Course#} Marks
This type of dependency is called as functional dependency. In the above
example Marks is functionally dependent on {Student#, Course#}.
Other functional dependencies in the above example are:
Course# CourseName
Course# Iname ( Assuming one course is taught by one and only one
instructor)
Iname Room# (Assuming each instructor has his/her own room)
Marks Grade
Course# Room#
Stu_name:
Roll_no Sname
111 parimal
222 parimal
stu_dept
Roll_no Dept
111 COMPUTER
222 ELECTRICAL
Now ,when these two relations are joined on the comman column 'roll_no'
,the resultant relation will look like stu_joined.
stu_joined :
Example:
Let a relation R(A,B,C,D) and set a FDs F = { A -> B , A -> C , C -> D} are
given.
A relation R is decomposed into -
R1 = (A, B, C) with FDs F1 = {A -> B, A -> C}, and
so, F' = F.
4.Attribute Closure:
The set of all those attributes which can be functionally determined
from an attribute set is called as closure of that attribute set.
A->BC
BC->DE
D->F
CF->G
Closure of Attribute A:
A+ ={A}
={ABC} ∵A->BC
={ABCDE} ∵BC->DE
={ABCDEF} ∵D->F
={ABCDEFG} ∵CF->G
={BCDE} ∵BC->DE
={BCDEF} ∵D->F
={BCDEFG} ∵CF->G
Normalization
Normalization is a systematic approach of decomposing tables to eliminate
data redundancy and undesirable characteristics like Insertion, Update and
Deletion anomalies.
These would include two properties
o Lossless join property- which guarantees that the generation of
spurious tuples will not occur.
o Dependency preservation property - This ensures that each
functional dependency is represented in some individual relation
resulting after decomposition.
Prime attribute - An attribute of relation schema R is called a prime
attribute of R if it is a member of some candidate key of R.
Non prime attribute - An attribute is called nonprime if it is not a prime
attribute—that is, if it is not a member of any candidate key.
If a relation schema has more than one key, each is called a candidate key.
One of the candidate keys is arbitrarily designated to be the primary key,
and the others are called secondary keys.
Normal forms: The normal form is a relation refers to the highest normal
form condition that it meets and hence indicates the degree to which it has
been normalized.
Normal forms are used to eliminate or reduce redundancy in database
tables.
First Normal Form (1NF)
A relation R is said to be in the first normal form if and only if all the
attributes of the relation R are atomic in nature.
For example, consider the Department table given in figure (b). It is not in
1NF because one of its attributes Dlocations is non-atomic as it contains
more than one value in row 1. To make it 1NF compliant, create a separate
row for each value of Dlocations of row 1 as shown in figure (c).
Figure (a) A relation schema (b) sample state of relation Department that is
not in 1NF (c)1NF version of the same relation
To make it 2NF compliant, remove all partial dependencies. For this, we need
to split EMP_PROJ table into 3 tables as EP1, EP2 and EP3 as shown above.
Now these 3 tables do not contain partial dependencies and hence they are
in 2NF.
Example2:Consider a relation R(A,B,C,D,E,F) with the functional
dependencies
A->BCDEF
BC->ADEF
B->F
D->E
Solution:
Candidate keys are {A,BC}
So, prime attributes are {A,B,C}
Non-prime attributes are {D,E,F}
In the third functional dependency (B->F) partial dependency (non-prime
attribute can’t be derived from subset of candidate key) exists.
Therefore, the given relation R is not in 2NF
So, the relation R can be divided into two relations R1(A,B,C,D,E) and
R2(B,F).
Third Normal Form (3NF):
Employee
Employee Table
Rate Table
Rate-Category Hourly-Rate
Now, both Employee and Rate tables are in 3NF as they do not have
transitive dependencies.
Example2:Consider a relation R(A,B,C,D,E) with the functional
dependencies
A->BCDE
BC->ADE
D->E
Solution:
Candidate keys are {A,BC}
So, prime attributes are {A,B,C}
Non-prime attributes are {D,E}
In the third functional dependency (D->E) Transitive dependency (non-prime
attribute can’t be derived from another non-prime attribute) exists.
Therefore, the given relation R is not in 3NF
So, the relation R can be divided into two relations R1(A,B,C,D) and R2(D,E).
Boyce-Codd Normal Form (BCNF):
A relation is said to be in BCNF if and only if all the determinants are
candidate keys. BCNF relation is a strong 3NF relation. i.e. all BCNF
relations are in 3NF but the reverse is not true.
For example, consider the following Result table.
Result Table
This table has two candidate keys – {Student#, Course#} and {EmailID,
Course#}.
This table is in 3NF because it has no partial and transitive dependencies
between key attributes and non-key attributes. But this table is not in BCNF
because all determinants are not candidate keys. This can be observed from
the following FDs;
{Student#, Course#} Marks
{EmailID, Course#} Marks
Student# EmailID
EmailID Student#
Though the determinants of first two FDs are candidate keys but the
determinants of the last two FDs are not candidate keys. Thus it is violating
the BCNF condition.
To make this table into BCNF compliant, we need to decompose the Result
table into two tables as shown below;
Student Table
Student# EmailID
Result Table
UNIT-III
Assignment-Cum-Tutorial Questions
SECTION-A
Objective Questions
1. The normalization of 1NF relations to 2NF involves: [ ]
A)Removal of partial dependencies
B) Removal of full dependencies
C) Removal of transitive dependencies
D) Removal of multi-valued dependencies
5. Identify the minimal key for the relational scheme R(A, B, C, D, E) with functional
dependencies F = {AB, BC, ACD}. [ ]
A) A B) AE C) BE D) CE
6. The best normal form of relation scheme R(A, B, C, D) along with the set of
functional dependencies F = {ABC, ABD, CA, DB} is [ ]
A) Boyce-Codd Normal form B) Third Normal form
C) Second Normal form D) First Normal form
List-I List-II
(a) Normalization (i) Enforces match of primary key to foreign key
(b) Data Dictionary (ii) Reduces data redundancy in a database
(c) Referential Integrity (iii) Define view(s) of the database for particular
user(s).
(d) External Schema (iv) Contains metadata describing database structure.
Codes:
(a) (b) (c) (d)
(A) (iv) (iii) (i) (ii)
(B) (ii) (iv) (i) (iii)
(C) (ii) (iv) (iii) (i)
(D) (iv) (iii) (ii) (i)
10. From the following instance of a relational schema R(A,B,C) we can conclude
that
A B C
1 1 1
1 1 0
2 3 2
2 3 2
X Y Z
1 4 2
1 5 3
1 6 3
3 2 2
Which of the following functional dependencies are satisfied by the instance?
A) XYZ and YX B) YZX and XZ
C) XYZ and ZY D) YZX and YZ
SECTION-B
SUBJECTIVE QUESTIONS
SECTION-C
Unit - IV
Transaction Management
1. Transaction Concept
Transaction: A transaction is a unit of program execution that
accesses and possibly updates various data items. As an example
consider the following transaction that transfers $50 from account A
to account B. It can be written as:
1. read(A)
2. A := A – 50
3. write(A)
4. read(B)
5. B := B + 50
6. write(B)
This transaction consists of 6 actions that need to takes place in order
to transfer $50 from account A to account B.
Ti : read(A);
A := A − 50;
write(A);
read(B);
B := B + 50;
write(B).
Let us now consider each of the ACID requirements.
Consistency: The consistency requirement here is that the sum of A and
B be unchanged by the execution of the transaction.
It can be verified easily that, if the database is consistent before an
execution of the transaction, the database remains consistent after the
execution of the transaction.
This is the reason for the atomicity requirement: If the atomicity property
is present, all actions of the transaction are reflected in the database, or
none are.
The basic idea behind ensuring atomicity is this: The database system
keeps track (on disk) of the old values of any data on which a transaction
performs a write, and, if the transaction does not complete its execution,
the database system restores the old values to make it appear as though
the transaction never executed.
3. Transaction State
Active, the initial state; the transaction stays in this state while it is
executing
Partially committed, after the final statement has been executed
Failed, after the discovery that normal execution can no longer proceed
Aborted, after the transaction has been rolled back and the database
has been restored to its state prior to the start of the transaction
Committed, after successful completion
write(A);
read(B);
B := B + temp;
write(B).
The following figure shows a serial schedule in which T1 executes before
T2.
5. Serializability
The database system must control concurrent execution of transactions,
to ensure that the database state remains consistent.
For this, we must first understand which schedules will ensure
consistency, and which schedules will not. For this, we need to consider
simplified view of transactions.
Simplified view of transactions
o We ignore operations other than read and write instructions
o We assume that transactions may perform arbitrary computations
on data in local buffers in between reads and writes.
o Our simplified schedules consist of only read and write
instructions
The following schedule consist only read and write instructions.
Schedule 7
Let S and S1 be two schedules with the same set of transactions. The
schedules S and S1 are said to be view equivalent if three conditions are
met, for each data item Q:
1. If in schedule S, transaction Ti reads the initial value of Q, then in
schedule S’ also transaction Ti must read the initial value of Q.
2. If in schedule S transaction Ti executes read(Q), and that value was
produced by transaction Tj (if any), then in schedule S’ also
transaction Ti must read the value of Q that was produced by the
same write(Q) operation of transaction Tj .
3. The transaction (if any) that performs the final write(Q) operation in
schedule S must also perform the final write(Q) operation in schedule
S’.
Schedule (c)
The schedules shown above are conflict serializable schedules since,
their precedence graphs are acyclic.
The following schedule is not conflict serializable as its precedence graph
consists a cycle.
6. Recoverability
If a transaction Ti fails, we need to undo the effect of this transaction to
ensure the atomicity property of the transaction.
In the following sections, we address the issue of what schedules are
acceptable from the viewpoint of recovery from transaction failure.
If T8 should abort, T9 would have read (and possibly shown to the user)
an inconsistent database state. Hence, database must ensure that
schedules are recoverable.
Schedule 12
UNIT-IV
Assignment-Cum-Tutorial Questions
SECTION-A
Objective Questions
1. Identify the characteristics of transactions [ ]
A) Atomicity B) Durability C) Isolation D) All of the mentioned
2. Which of the following has “all-or-none” property? [ ]
A) Atomicity B)Durability C) Isolation D) All of the mentioned
3. Which one of the following is NOT a part of the ACID properties of database
transactions? [ ]
A. Atomicity B) Isolation C) Consistency D) Deadlock-freedom
4. The database system must take special actions to ensure that transactions
operate properly without interference from concurrently executing database
statements. This property is referred to as: [ ]
A) Atomicity B) Durability C) Isolation D) All of the mentioned
5. The property of transaction that persists all the crashes is [ ]
A) Atomicity B)Durability C) Isolation D) All of the mentioned
6. Consider the following transaction involving two bank accounts x and y.
read(x); x := x – 50; write(x); read(y); y := y + 50; write(y); The constraint
that the sum of the accounts x and y should remain constant is known as:
A. Atomicity B) Isolation C) Consistency D) Durability[ ]
7. Precedence graphs help to find a [ ]
A) Serializable schedule C) Recoverable schedule
B) Deadlock free schedule D) Cascadeless schedule
8. Consider the following four schedules due to three transactions(indicated by
the subscript) using read and write on a data item x, denoted by r(x) and w(x)
respectively. Which one of them is conflict serializable? [ ]
9. Consider the transactions T1, T2, and T3 and the schedules S1 and S2 given
below. [ ]
T1: r1(X); r1(Z); w1(X); w1(Z)
T2: r2(Y); r2(Z); w2(Z)
T3: r3(Y); r3(X); w3(Y)
S1: r1(X); r3(Y); r3(X); r2(Y); r2(Z);
w3(Y); w2(Z); r1(Z); w1(X); w1(Z)
S2: r1(X); r3(Y); r2(Y); r3(X); r1(Z);
r2(Z); w3(Y); w1(X); w2(Z); w1(Z)
Which one of the following statements about the schedules is TRUE?
A. Only S1 is conflict-serializable.
B. Only S2 is conflict-serializable.
C. Both S1 and S2 are conflict-serializable.
D.Neither S1 nor S2 is conflict-serializable.
10. Consider the following two phase locking protocol. Suppose a transaction T
accesses (for read or write operations), a certain set of objects {O1,...,Ok}.
This is done in the following manner:
Step 1. T acquires exclusive locks to O1, . . . , Ok in increasing order of their
addresses. Step 2. The required operations are performed. Step 3. All locks are
released. This protocol will; [ ]
A. guarantee serializability and deadlock-freedom
B. guarantee neither serializability nor deadlock-freedom
C. guarantee serializability but not deadlock-freedom
D.guarantee deadlock-freedom but not serializability
11. Which of the following property state that the data used during the
execution of a transaction cannot be used by a second transaction until the
first one is completed. [ ]
A) Consistency B) Atomicity C) Durability D) Isolation
12. Which property states that only valid data will be written to the database?
A. Consistency B) Durability C) Atomicity D) Isolation
SECTION-B
SUBJECTIVE QUESTIONS
1) Define Transaction and briefly explain ACID properties.
2) Draw transaction state diagram and describe each state that a transaction
goes through during its execution.
3) What is schedule? Explain different types of schedules.
4) How can you test whether a given schedule is conflict-serializable? Is every
conflict-serializable schedule is serializable? Justify.
5) Construct a precedence graph for serial schedule and non serial schedule.
6) Create a concurrent schedule for executing the following transactions;
T1: transfer funds $1000 from account A to account B
T2: Increase the balance amount of account A to 10%
7) Consider the following two transactions:
T1: read(A);
read(B);
if A = 0then B := B + 1;
write(B).
T2: read(B);
read(A);
if B = 0then A := A + 1;
write(A).
Let the consistency requirement be A = 0 V B = 0, with A = B = 0 the
initial values.
a. Show that every serial execution involving these two transactions preserves
the consistency of the database.
b. Show a concurrent execution of T1 and T2 (shown in the above problem) that
produces a nonserializable schedule.
8) Is there a concurrent execution of T1 and T2 (shown in the above problem)
that produces a serializable schedule?
9) Test whether the following schedule is conflict serializable (Subscripts denote
transactions)?
S1: R1(X); R2(X); W1(X); R3(X); W2(X);
10) Consider the following three schedules due to three transactions (indicated
by the subscript) using read and write on a data item X, denoted by R(X) and
W(X) respectively. Construct the precedence graph for each schedule and
determine which of them is conflict serializable?
S1: R2(X); R1(X); W1(X); R3(X); W2(X);
S2: R3(X); R2(X); R1(X); W2(X); W1(X);
S3: R2(X); W2(X); R3(X); R1(X); W1(X);
11) Consider three transactions: T1, T2 and T3. Draw the precedence graph for
the following schedule consisting of these three transactions and determine
whether it is serializable. If so, give its serial order(s).
T1 T2 T3
read(Y)
read(Z)
read(X)
write(X)
write(Y)
write(Z)
read(Z)
read(Y)
write(Y)
read(Y)
write(Y)
read(X)
write(X)
SECTION-C
QUESTIONS AT THE LEVEL OF GATE
T1 T2 T3 T4
Reads(X)
Writes(X)
Commit
Writes(X)
Commit
Writes(Y)
Reads(Z)
Commit
Reads(X)
Reads(Y)
Commit
T1 T2 T3
R(D3)
R(D2)
W(D2)
R(D2)
R(D3)
R(D1)
W(D1)
W(D2)
W(D3)
R(D1)
R(D2)
W(D2)
W(D1)
Unit - V
Concurrency Control
Concurrency Control
1. Concurrent Execution of Transactions
o Transaction-processing systems usually allow multiple transactions to run concurrently.
Allowing multiple transactions to update data concurrently causes several
complications. However, there are two good reasons for allowing concurrency:
o Improved throughput and resource utilization. A transaction consists of many
steps. Some involve I/O activity; others involve CPU activity. The CPU I/O
activities can be done in parallel. While a read or write on behalf of one transaction
is in progress on one disk, another transaction can be running in the CPU, while
another disk may be executing a read or write on behalf of a third transaction. All of
this increases the throughput of the system—that is, the number of transactions
executed in a given amount of time. Correspondingly, the processor and disk
utilization also increase.
o Reduced waiting time. There may be a mix of transactions running on a system,
some short and some long. If transactions run serially, a short transaction may have
to wait for a preceding long transaction to complete, which can lead to
unpredictable delays in running a transaction. Concurrent execution reduces the
unpredictable delays in running transactions. Moreover, it also reduces the average
response time.
2. Anomalies Due to Concurrent Executions
If all the transactions in DBMS systems are doing read operation on the Database then
no problem will arise. When the read and write operations are done simultaneously,
then there is a possibility of some type of anomalies. These are classified into three
categories.
o Write–Read Conflicts (WR Conflicts)
o Read–Write Conflicts (RW Conflicts)
o Write–Write Conflicts (WW Conflicts)
This happens when the transaction T2 read the data item A that has been modified
by another transaction T1, which has not yet committed. Such a read is called a dirty
read.
As an example, consider the following set of transactions (T1 & T2) and the
schedule for executing T1 & T2.
T1: Transfers $100 from account A to account B
T2: Increments the balances of account A and account B by 10%
T1 T2
Read(A)
Write(A) Dirty read
Read(A)
Write(A)
Read(B)
Write(B)
Commit
Read(B)
Write(B)
Commit
If the two transactions are allowed to execute as per the schedule shown above, then the
outcome of this execution will be different from the normal execution like if the two
instructions are executed one after another. This type of anomalies leaves the database in
an inconsistency state.
Read(A)
A has been
Read(A) modified
Write(A)
Commit
Read(A)
Gets different
Write(A)
value of A
Commit
RW conflict
Again, the execution of transactions T1 & T2 using the above schedule leads to database
inconsistency.
As an example, consider the following set of transactions (T1 & T2) and the
schedule for executing T1 & T2.
T1: Sets the salaries of X and Y to $1000
T2: Sets the salaries of X and Y to $2000
T1 T2
Write(X)
Write(Y)
Blind write
Write(Y)
Write(X)
Commit
Commit
WW conflict
Again, the execution of transactions T1 & T2 using the above schedule leads to database
inconsistency.
3. Lock-Based Protocols
One way to ensure serializability is to require that data items be accessed in a mutually
exclusive manner; that is, while one transaction is accessing a data item no other
transaction can modify that data item. A DBMS typically uses a locking protocol to
achieve this.
Locks
There are various modes in which a data item may be locked.
1. Shared Lock: If a transaction Ti has obtained a shared-mode lock (denoted by S)
on item Q, then Ti can read, but cannot write, Q.
2. Exclusive Lock: If a transaction Ti has obtained an exclusive-mode lock (denoted
by X) on item Q, then Ti can both read and write Q.
Following figure shows compatibility of locks.
From the figure it is clear that shared lock is compatible with shared lock, but not with
exclusive lock. At any time, several shared-mode locks can be held simultaneously (by
different transactions) on a particular data item. A subsequent exclusive-mode lock
request has to wait until the currently held shared-mode locks are released.
The Two-Phase Locking Protocol (2PL)
It ensures serializability.
This protocol requires that each transaction issue lock and unlock requests in two
phases:
1. Growing phase. A transaction may obtain locks, but may not release any lock.
2. Shrinking phase. A transaction may release locks, but may not obtain any new
locks.
Initially, a transaction is in the growing phase. The transaction acquires locks as
needed. Once the transaction releases a lock, it enters the shrinking phase, and it can
issue no more lock requests.
T1 T2
Lock-X(A)
Read(A)
Write(A)
Lock-X(B)
Unlock(A)
Lock-X(A)
Read(A)
Write(A)
Read(B)
Write(B)
Unlock(B)
Lock-X(B)
Unlock(A)
Read(B)
Write(B)
Unlock(B)
Schedule – 1
As an example, consider the following set of transactions (T1 & T2)
T1: Transfers $100 from account A to account B
T2: Increments the balances of account A and account B by 10%
T1 & T2 can be executed using schedule – 1 under Two-phase locking protocol.
Advantages
It ensures serializability
It is a simple and straightforward protocol.
Disadvantages
state where neither of these transactions can ever proceed with its normal execution.
Unlock(B)
4. Timestamp-Based Protocols
Another method for determining the serializability order is a timestamp-ordering
scheme.
Timestamps
With each transaction Ti in the system, we associate a unique fixed timestamp, denoted
by TS(Ti). This timestamp is assigned by the database system before the transaction Ti
starts execution.
Usually, the value of the system clock is used as the timestamp; that is, a transaction’s
timestamp is equal to the value of the system clock when the transaction enters the
system.
The timestamps of the transactions determine the serializability order. Thus, if TS(Ti) <
TS(Tj ), then the system must ensure that the produced schedule is equivalent to a serial
schedule in which transaction Ti appears before transaction Tj .
To implement this scheme, we associate with each data item Q two timestamp values:
a) W-timestamp(Q) denotes the largest timestamp of any transaction that
executed write(Q) successfully
b) R-timestamp(Q) denotes the largest timestamp of any transaction that
executed read(Q) successfully.
These timestamps are updated whenever a new read(Q) or write(Q) instruction is
executed.
The Timestamp-Ordering Protocol
The timestamp-ordering protocol ensures that any conflicting read and write operations
are executed in timestamp order. This protocol operates as follows:
1. Suppose that transaction Ti issues read(Q).
a. If TS(Ti) < W-timestamp(Q), then Ti needs to read a value of Q that was
already overwritten. Hence, the read operation is rejected, and Ti is
rolled back.
b. If TS(Ti) ≥ W-timestamp(Q), then the read operation is executed, and R-
timestamp(Q) is set to the maximum of R-timestamp(Q) and TS(Ti).
Since T16 starts before T17, we shall assume that TS(T16) < TS(T17). The read(Q)
operation of T16 succeeds, as does the write(Q) operation of T17.When T16 attempts its
write(Q) operation, we find that TS(T16) < W-timestamp(Q). Thus, the write(Q)
by T16 is rejected and transaction T16 must be rolled back.
Although the rollback of T16 is required by the timestamp-ordering protocol, it is
unnecessary. Since T17 has already written Q, the value that T16 is attempting to write is
one that will never need to be read. Any transaction Ti with TS(Ti) < TS(T 17) that
attempts a read(Q) will be rolled back, since TS(Ti) < W-timestamp(Q). Any
transaction Tj with TS(Tj ) > TS(T17) must read the value of Q written by T17, rather
than the value written by T16.
This observation leads to a modified version of the timestamp-ordering protocol in
which obsolete write operations can be ignored under certain circumstances.
The modification to the timestamp-ordering protocol is called Thomas’ write rule and is
given as;
Suppose that transaction Ti issues write(Q)
1. If TS(Ti) < R-timestamp(Q), then the value of Q that Ti is producing was
previously needed. Hence, the system rejects the write operation and rolls Ti
back.
2. If TS(Ti) < W-timestamp(Q), then Ti is attempting to write an obsolete value of
Q. Hence, this write operation can be ignored.
3. Otherwise, the system executes the write operation and sets W-timestamp(Q) to
TS(Ti).
The difference between these rules and the timestamp-ordering protocol lies in the
second rule. The timestamp-ordering protocol requires that Ti be rolled back if Ti issues
write(Q) and TS(Ti) < W-timestamp(Q). However, here, in Thomas’ Write Rule, we
ignore the obsolete write.
Thomas’ write rule makes use of view serializability and increases concurrency.
6. Deadlock Handling
A system is in a deadlock state if there exists a set of transactions such that every
transaction in the set is waiting for another transaction in the set.
For example there exists a set of waiting transactions {T0, T1, . . ., Tn} such that T0 is
waiting for a data item that T1 holds, and T1 is waiting for a data item that T2 holds,
and . . ., and Tn−1 is waiting for a data item that Tn holds, and Tn is waiting for a data
item that T0 holds. None of the transactions can make progress in such a situation.
There are two principal methods for dealing with the deadlock problem.
1. deadlock prevention
2. deadlock detection and deadlock recovery scheme.
Deadlock Prevention
Two different deadlock prevention schemes using timestamps have been proposed:
For example, suppose that transactions T22, T23, and T24 have timestamps 5, 10,
and 15, respectively. If T22 requests a data item held by T23, then T22 will wait. If
T24 requests a data item held by T23, then T24 will be rolled back.
Example, with transactions T22, T23, and T24, if T22 requests a data item held by
T23, then the data item will be preempted from T23, and T23 will be rolled back. If
T24 requests a data item held by T23, then T24 will wait.
The major problem with both of these schemes is that unnecessary rollbacks may
occur.
Deadlock Detection and Recovery
An algorithm that examines the state of the system is invoked periodically to determine
whether a deadlock has occurred. If one has, then the system must attempt to recover
from the deadlock. This uses a directed graph called a wait-for graph for Deadlock
Detection.
This graph consists of a pair G = (V, E), where V is a set of vertices and E is a set of
edges.
The set of vertices represents the transactions in the system and there is an edge form
Ti to Tj if Ti waits for Tj.
A deadlock exists in the system if and only if the wait-for graph contains a cycle.
Suppose now that transaction T28 is requesting an item held by T27. The edge T28 →
T27 is added to the wait-for graph, resulting in the new system state in Figure 4. This
time, the graph contains the cycle
T26 → T28 →T27 →T26 implying that transactions T26, T27, and T28 are all
deadlocked.
When a detection algorithm determines that a deadlock exists, the system must recover
from the deadlock. The most common solution for deadlock recovery is to roll back one
or more transactions to break the deadlock. Three actions need to be taken:
1. Selection of a victim: Given a set of deadlocked transactions, we must determine
which transaction (or transactions) to roll back to break the deadlock. We should
roll back those transactions that will incur the minimum cost. Factors that determine
the cost of a rollback, including
a. How long the transaction has computed, and how much longer the
transaction will compute before it completes its designated task.
b. How many data items that the transaction has used.
c. How many more data items the transaction needs for it to complete.
factors, it may happen that the same transaction is always picked as a victim. As a
result, this transaction never completes its designated task, thus there is starvation.
We must ensure that transaction can be picked as a victim only a (small) finite
number of times. The most common solution is to include the number of rollbacks
UNIT-V
Assignment-Cum-Tutorial Questions
SECTION-A
Objective Questions
11. Test whether the following schedule observes i) 2PL ii) Strict 2pl iii)
Rigorous 2PL [ ]
Lock- S(A)
R(A)
Lock –X(B)
Unlock (A)
R(B)
W(B)
Commit
Unlock (B)
A) Only I B) I & II C) I, II, & III D) None
12. Test whether the following schedules observes i) 2PL ii) Strict 2pl iii)
Rigorous 2PL [ ]
Lock- S(A)
R(A)
Lock –X(B)
Write(B)
Unlock(A)
Unlock(B)
A) Only I B) I & II C) I, II, & III D) None
SECTION-B
Descriptive Questions
1. Why concurrency control is needed? Explain the problems that would
arise when concurrency control is not provided by the database system.
2. Identify the anomalies due to concurrent execution of transactions.
(Dirty Read, Unrepeatable Read, Blind Write)
3. What is a lock? List the types of lock.
4. Define 2-Phase Locking. Differentiate 2PL, Strict 2PL and Rigorous 2PL.
5. Discuss in detail about Time Stamp Based Protocol and Thomas Write
Rule.
6. What is deadlock? Illustrate different deadlock handling techniques.
7. Outline the actions to be taken to recover from a deadlock.
8. Draw the waits-for graph for the following schedule and test whether
this schedule leads to a deadlock?
SECTION-C
GATE Questions
1) Which of the following concurrency control protocols ensure both
conflict serialzability and freedom from deadlock? [GATE 2010]
I) 2-phase locking
II) Time-stamp ordering [ ]
A) I only B) II only C) Both I and II D) Neither I nor II
UNIT VI
1. Failure Classification
There are various types of failure that may occur in a system, each of
which needs to be dealt with in a different manner. Broadly failures are
classified into the following types.
o Transaction failure. There are two types of errors that may cause a
transaction to fail:
1. Logical error. The transaction can no longer continue with its
normal execution because of some internal condition, such as
bad input, data not found, overflow, or resource limit exceeded.
2. System error. The system has entered an undesirable state
(deadlock), so the transaction cannot continue with its normal
execution. The transaction, however, can be re executed at a later
time.
o System crash. There is a hardware malfunction, or a bug in the
database software or the operating system, that causes the loss of
the content of volatile storage, and brings transaction processing to a
halt. The content of nonvolatile storage remains intact, and is not
corrupted.
o The assumption that hardware errors and bugs in the software
bring the system to a halt, but do not corrupt the nonvolatile
storage contents, is known as the fail-stop assumption.
o Disk failure. A disk block loses its content as a result of either a
head crash or failure during a data transfer operation. Copies of the
data on other disks, or archival backups on tertiary media, such as
tapes, are used to recover from the failure.
Storage Types
o Volatile storage. Information stored in volatile storage does not
usually survive system crashes. Examples volatile storage: main
memory and cache memory. Access to volatile storage is extremely
fast.
o Nonvolatile storage. Information residing in nonvolatile storage
survives system crashes. Example nonvolatile storage is disk and
magnetic tapes. Disks are used for online storage, whereas tapes are
used for archival storage. Nonvolatile storage is slower than volatile
storage. In database systems, disks are used for most nonvolatile
storage. Other nonvolatile media are normally used only for backup
data.
o Stable storage. Information residing in stable storage is never lost.
2. Different Types of Recovery Techniques
2.1. Log-Based Recovery
The most widely used structure for recording database modifications is
the log. The log is a sequence of log records, recording all the update
activities in the database. There are several types of log records.
We denote various types of log records as:
1. <Ti start>. Transaction Ti has started (start log record).
2. <Ti, Xj, V1, V2>. Transaction Ti has performed a write on data
item Xj. Xj had value V1 before the write, and will have value V2
after the write (update log record).
3. <Ti commit>. Transaction Ti has committed (commit log record).
4. <Ti abort>. Transaction Ti has aborted (abort log record).
2.1.1. Deferred Database Modification
In this, the modifications done by the transaction are not recorded in
the database but deferred (postponed) until the transaction commits.
However, these modifications are recorded in the log file.
Database
Transaction(T1) Database After Log
Before
Start A=50, B=100 A=50, B=100 <T1, start>
Read(A) 50 50 --
Database
Transaction(T1) Database After Log
Before
Start A=50, B=100 A=50, B=100 <T1, start>
Read(A) 50 50 --
Read(A) 50 50 --
Database
Transaction(T1) Database After Log
Before
Start A=50, B=100 A=50, B=100 <T1, start>
Read(A) 50 50 --
Both redo and undo operations are idempotent; that is, executing it
several times must be equivalent to executing it once.
2.1.3.Check-pointing
When a system failure occurs, we must use the log to determine those
transactions that need to be redone and those that need to be undone.
In principle, we need to search the entire log to determine this
information.
There are two major difficulties with this approach:
1. The search process is time consuming.
2. Most of the transactions that, according to our algorithm, need to be
redone have already written their updates into the database.
Although redoing them will cause no harm, it will nevertheless cause
recovery to take longer.
To reduce these types of overhead, the system periodically performs
checkpoints.
Updating the database at fixed intervals of time is called as check-
pointing.
As an example, consider the following figure.
When the transaction starts, both page tables are identical. The
shadow page table is never changed over the duration of the
transaction. The current page table may be changed when a
transaction performs a write operation.
All modifications done by the transaction are applied to the current
page table only.
Suppose that the transaction Tj performs a write(X) operation, it
modifies the current page table so that the ith entry points to the
modified page.
The above figure shows the shadow and current page tables of some
transaction Tj. It also shows that transaction Tj has modified the data
item present in 4th page table.
UNIT VI
Assignment-Cum-Tutorial Questions
SECTION-A
Objective Questions
1. Which of the following is under failure classification? [ ]
i. Transaction failure
ii. System crash
iii. Disk Failure
iv. Storage failure
A) i and ii B) i , ii and iii
C) i, ii, iii and iv D) ii and iii
2. The most widely used structure for recording database modifications is
called ______.
3. Identify crash recovery techniques from the following. [ ]
A) Log-Based B) Check-pointing
C) Shadow- Paging D) All of the above
4. An update log record contains which of the following [ ]
A) Transaction identifier B) Data item identifier
C) Old value and new value D) All of the above
5. What is the effect of the UNDO operation corresponding to a log record
where Ti is the transaction, and V1 and V2 are the old and new values
respectively of a data location X? [ ]
A) No change to X C) Writes the value V1 to X
B) Writes the value V2 to X D) Sets X to 0
6. Consider the log of transactions below. [ ]
< T0 start >
< T0, S, 100, 120 >
< T0, H, 1, 3 >
Identify the correct actions, which are part of the Undo(T0)
A) H is restored to 3 C) S is set to 120
SECTION-B
Descriptive Questions
1. Explain the concept of failure classification.
2. Distinguish between different Storage Mechanisms
3. Explain different types of Recovery Techniques.
4. Distinguish between immediate and deferred database modification
(update).
5. Illustrate check pointing with an example.
6. Summarize the importance of shadow paging.
7. Consider the following state of transactions:
A) The undo list at the start of the undo phase contains T2, T4