Download as pdf or txt
Download as pdf or txt
You are on page 1of 25

3-2A (CTT-Sem-5) Database Design & Normalization

PART-1

3
UNIT
Database
Design & Normalization
Functional Dependencies.

Questions-Answers
Questions
Long Answer Type and Medium Answer Type

its role in
Que 3.1. What is functional dependency ? Explain
inferen ce rules for functional
database design. Describe the
CONTENTS dependencies.
Answer
Part-1 : Functional Dependencies.. 3-2A to 3-7A Functional dependeney :
constraint between two sets of attributes
Part-2 : Normnal Forms, ***** .3-7A to 3-11A 1 Afunctional dependency isa
from the database.
First, Second, Third Normnal denoted by X ’ Y, between two sets of
Form, BCNF 2. A functional dependency is of Rspecifies a constraint on the
attributes X andY that are subsets
relation r.
Part-3 : Inclusion Dependence, .3-11A to 3-13A possible tuples that can form a
which bave
Lossless Join Decomposition 3 The constraint for any two tuples t, and to, inr
t, [X]=t, [X1;
Part-4 : Normalization using FD, .3-13A to 3-18A Also, must have
MVD and JDs, 4, (Y| =t, [Yl;
Alternative Approaches to component of a tuple in r depends
Database Design 4. This means that the values of the Y components, or alternatively,
on, or are determined by the value of theX
tuple uniquely (or functionally)
the values of the X component of a
determine the value of the Ycomponent.
Role of functional dependency : designer to express facts
1. Functional dependency allows the database enterprise
that the designer is modeling with the
about the enterprise
databases.
2 It allows the designers to express
constraints, which cannot be expressed
with super keys.
Inference rules for functional dependencies :
Bcathena ’p holds.
1. Reflexivity rule: Ifa is a set of attributes and
attributes then
2 Augmentation rule : If a B holds and y is a set of
Ya ’ yB holds.
holds.
3. Transitivity rule : If a’B holds and B->y holds, then a -> y
Complementation rule : If a-’ß hold, then a -’R-(aUB))
4
holds.
3-1 A (CSTT-Sem-5)
Database Management System 3-3A (CSTT-Sem-5) 34A (CSIT-Sem-5) Database Design &Normalization

5 Multivalued augmentation rule:a ’B hold and ycR and 8cy These two can be combined toget
then ya 188 holds. A’ BC
& Multivaluedtransitivity rule :If a-+p holds, then ß- yholds. Now, the revised set F becomes :
then a-’-y-B holds.
7. Replication rule :lfa -’+B hlds and yc Band there is a8such that A ’ BC
8cRand 8nB=¢ and 8-’ y, thena’yholds.
8 Union rule : ifa ’B holds and a ’ yholds, then a > By holds. B’C

9. Decomposition rule :Ifa ’Bholds, then a’ß holds, and a ’y AB ’C


holds.
removing AB
10. Pseudotransitivity rule : If a ’ B holds and yß ’ 8 holds, then There is an extraneous attribute in AB ’ Cbecause even after
because B ’ Cis
ya8holds. ’Cfrom the set F, we get the same closures. This is
already a part of F.
Que 3.2. What is functional dependency ? Explain trivial and Now, the revised set F becomes :
non-trivial functional dependency. Define canonical cover. Compute
canonical cover for the following : A’ BC
R= (A,B, C) F = (A ’ BC, B ’C,A’B, AB’ C)
B’C
Answer
Funetional dependency : Refer Q. 3.1, Page 3-2A, Unit-3. A’Bis logically implied by
Cis an extraneous attribute in A’ BC, also
Trivial functional dependency: The dependency of an attribute on a A’ Band B’ C(by transitivity)
of attributes is known as set
trivial functional dependency if the set of attributes
includes that attribute. F={
A’Bis trivial functional dependency ifB is a subset of A. A ’B
B’C
Non-trivial functional dependency : If a functional dependency X -’ Y
holds true where Yis not a subset of Xthen this
trivial functional dependency. dependency is called non
After this step, F does not change anymore.
For example : Hence, the required canonical cover is,
Let a relation R (A, B, C) F= (A’ B, B -> C)
The following functional dependencies are non-trivial : partial
A’B(B is not a subset of A) Que 3.3. Explain full functional depen den cy and
A’C(C is not a subset of A) functional dependenecy.
The following dependencies are trivial :
Answer
A, B) ’B (B is a subset of A, B)]
Full functional dependency:
Canonical cover :A canonical cover of aset of functional dependencies Fis dependencyX’ Y, Yis fully
a simplified set of functional dependencies that has 1 Given a relation scheme R and functional Z, where Z is a proper subset
original set P.
the same closure as the functionally dependent on X, ifthere is no
of Ysuch that Z Y.
Numerical :
The dependency X ’ Y is left reduced, there being no extraneous
There are two functional dependencies with the same set of attributes in the L.H.S of the dependeney.R (ABCDEH) with the FDs.
attributes schema
A’ BC For example : In the relational CD ->AH, ABH ’ BD, DH’ BC).
F= (A BC, CD ’E, E > C,
A
’B
16A(CSTT-Sem-5) Database Design &Normalizatin
Detabse Mnsgment Sytem
ABCalet reduced and | BD is fully
-5A(CSTT-Sem IplyA’D ByPseudotransitivity Rile)
A’CD by Union Rule)
The degendency
dependenten A
However the functinnal
functionaly
dependencies ABH-’ BC is not left reduced which is FD ofset
G.

becaue the sttribute B being etraneousin this


dependeney. Hence, Fand Gare equivalent
for set of
Partial funetional dependency : Que3.5. Write the algorithm to find minimal cover F
1 Gvenarelation schetma Rwith the funetional l dependencies Pdefined
functional depen dencies E.
n the attributes of RandKas acandidatekeys ifX is a proper subset t
Kand ifX -A then Ais said to be partially dependent on K. Answer
For eample :
Algorithm :
L Set F:=E.
Name Course Grade Phane no. Roll no.Course-deptt dependency I-’ LA,AAJin Fby the n
2 Replace each functional X’A, I ’AIA,
functional dependencies
dependencyI+Ain F
3 For each functional
is an element ofI
for each attribute B that
A|| is equivalent to F
Fig 33.1 ifIF- I’A]|u[X- B)
) ’A in F.
i n Pig 33.1, [Name +Coursel is acandidate key, So Name and Course then replace X ’ Awith X-(B) in F
are prime attributes, Grade is fully functionally dependent on the functional dependency I ’A
4 For each remaining
candidate keys and Phone no., Course-deptt. and roll no. are partially toF,
functional dependent on the candidate key. if (F-X’A|] is equivalent
F
E Given R(A. B. C, D)and F= (AB ’ C, B’D). Then key of this relation then remove X’A from
is AB andDispartialy dependent on the key. Suppose a relation R(A, B, C) has
Que 3.6. Define minimal cover. B). Convert
AC ’
Que 34. Define partial functional dependen cy. Consider the A ’C, AB ’B, AB ’C,
FD set F= (A ’B, B ’ C, AKTU 2018-19, Marks
07
following two steps of function al dependen cies F= (A ’C, AC ’D, minimal cover.
B’ AD, E ’ H) and G = A ’ CD, E’ AH). Check whether or not this FD set into

they are equivalent. AKTU 2018-19, Marks07 Answer Fisa minimal set of
cover of aset of FDs
Answer Minimal cover :A minimal is equivalent to F.
functional dependenciesFthat
Partial fun ctional dependency : Refer Q3.3, Page 34A,
Numerical : Unit-3. Numerical :
Given : RA, B, C)
From F, Non-redundant cover for F:
E’AD
on right hand side
E’A(By Decomposition Rule) Step 1:Only one attribute
F=A’ B
E’D B’C
Also given that
A’C
2’H AB ’ B
So, E->AH (By Union Rule) AB ’ C
which is a FD of set G. AC ’ B
Again A’C and AC-’D
Database Management System

Step 2: No extraneousattribute on left hand


side. Since 3-7A(CSTT-Sem-5 3-8A (CSIT-Sem-5) Database Design &Normalization

For example :The relation LIVED-IN given in Table 3.7.1 is not in


AR->B.AR>C,AC>Bare extraneous attribute. Hence, remove all INEbecause the domain values of the attribute ADDRESS are not
we get
these atomic.
A’B Table 3.7.1. LIVED-IN
BC
A’C Name Address
Step 3: By rule of transitivity, we can
remove. Hence, we get the CITY Year-moved-in Year-left
cOver
minimal
Ashok Kolkata 2007 2015
A’C Delhi 2011 2015
A’B Year-left
CITY Year-moved-in
B’C
Mumbai 2000 2004
Ajay 2005 2009
Chennai
PART-2
by replacing the non-simple
Normal Forms, First, Second, Third Normal Form, BCNE Relation not in 1NF and can be normalized
normalized form of LIVED-IN is
domain with simple domains. The

Questions-Answers given in Table 3.7.2. Table 3.7.2. LIVED-IN


Year-moved-in Year-left
Long Answer Type and Medium Answer Type Questions Name City
2007 2010
Ashok Kolkata
2011 2015
Que 3.7. Define normal forms. List the definitions of first, Ashok Delhi
second Mumbai
2000 2004
and third normal forms. Explain BCNF with a Ajay
suitable example. 2005 2009
Chennai
AKTU2015-16, Marks 10 Ajay
OR (2NF):
Explain INF, 2NF, 3NF and BCNF with suitable Second Normal Form
2. and every non-key
example. 2NF if and only ifit is in INF
Arelation R is in dependent on the primary key.
|AKTU2016-17, Marks 7.5 attribute is fully
attribute of R is fully
if every non-prime
Answer b A relation R is in 2NF each relation key.
functionally dependent on date,
1 Normal forms are simply stages of database design, (flight#, Type_of_aireraft,
relation flightdependencies in 2NF,
applying more strict rules to the types with each stage For example : The given is not
of information which can be functional
stored in a table. source, destination) with
2 Normal form is a method to normalize the flight#’ Type_of aireraft
Normal forms are based on the functionalrelations database.
in destination
3 flight# date ’ source depends only on flight#.
attributes of a relation. dependencies among the flight# date is key but Type_of_aireraft
Here data, source,
Different normal forms are : relation flight (flight#, Type_of_aircraft,
relation :
To convert break the relation into
two
L Pirst destination) into 2NF
Normal Form (1NF) : flight1 (light#, Type_of_aireraft)
A
relations Ris in 1NF if all domains are i.e., all elements source, destination)
are atomic.
simple flight2 (light#, date,
Database Management System 3-9A (CSSTT-Sem-5) 3-10A (CSTT-Sem-5)
Database Design & Normalization
Normal Form (3NF):
ThirdArelation
= ABCDEF B’F
3 Ris in 3NF ifand only if, for all time, each tuple of R = ABCDEFGH F’ GH
consists of a primary key value that identifies some entity in the
= ABCDEFGHIJ
database. So, AB is key of R.
Arelation schema Ris in 3NF with respect to a set Fof functional
dependencies, if for all functional dependencies in F of the form In the given relation, R has a composite primary key LA,B].
a->B, where a c Rand BcR, atleast one of t the following holds : The non-prime attribute are [C, D, E, F,G, H.L. N.
Lo this case, FDs are AB ’ C,A ’ DE, B ’Fwhich is only part of the
a->ßis a trivial funetional dependency. primary key. Therefore, this table does not satisfy 2NF.
a is asuper key for R. To bring this table to 2NF, we break the table into three relation as
m Each attribute Ain ß -a is contained in candidate kev for D R,(A,B, C),R,(A, D, E,I, )and R,(B, F,G, H).
For example: Let us consider a relation R(B, E, ,G, H) with primary Que 3.9. Write the difference between BCNF and 3NE.
key BRGH and functional dependency are B -F, F’ GH. AKTU2017-18, Marks 10
The relation R has transitive property as B’ F, F ’ GH then
B->GH. So R is not in 3NF. To convert relation R in 3NF break the
relation Rinto two relation as R(B, E, F), R,(F, G, ). Answer
Boyce-Codd Normal Form (BCNF): S. No. BCNF 3NF
should be no
A relation R is in BCNF if and only if every determinant is a 1 In BCNF, for any FDs for a In 3NF, there dependency that is no
candidate key. relation R, A ’B, A should be a transitive attribute should L.
b Arelation schema Ris in BCNF with respect to a set Foffunctional super key of relation. non prime
transitively dependent on the
dependencies if for allfunctional dependencies in F of the form candidate key.
a’B. where a c Rand BcR, at least one of the following holds :
thanIt is less strong than BCNE.
i a’ßis a trivial functional dependency (ie., B c a) 2. It is comparatively stronger
a is a super key for schema R. 3NF.
Adatabase design is in BCNFif each member ofthe set of relation In 3NF, the functional
BCNF, the functional dependencies
3. In
already in are already in
schemas that constitute the design is in BCNF. dependencies are INF and 2NF.
INF, 2NF and 3NF.
For example : Let consider a relation R(A, B, C, D, E) with AC as Redundancy is high.
primary key and functional dependencies in the relation R is given as 4 Redundancy is low.
A’B, C’ DE. In 3NF, there is preservation
of
may not all functionaldependencies.
5 In BCNF, there may or
To convert relation Rinto BCNF break the relation in three relation be preservation of all.
R{A, B), R(C, D, E), R{A, C). |It is comparatively
easier to
6 Itis difficult to achieve.
Que 38. Consider the universal relational schema R (A, B, C, D, achieve.
Lossless decomposition can be
E, F, G, H, I,) and a set of following functional Lossless decomposition is hard achieved by 3NF.
F=(AB’C,A -’ DE, B’F,F GH, D J) dependencies. 7
to achieve in BCNE.
determine the keys forR? Decompose Rinto 2nd normal form.
|AKTU 2016-17, Marks 7.5 BCNF is stricter than 3NF.
Que 3.l0. Prove that
Answer OR
stronger than 3NF.
AB)* = ABC Prove that BCNF is
AB ’ C
= ABCDE
A’ DE
Database Management System 3-11 A(CSTT-Sem-5) -12 A (CSTT-Sem-5)
Database Design & Normalization

Answer ORe 3.12. Explain inclusion dependencies.


Arelation, R, is in 3NF ifffor every dependency X’A satisfiedd by Rat
1
least one of thefollowing conditions: Answer
ofX)
a XA is trivial (.e., Ais subset 1.
An inclusion dependencyR. X<S.Y between two set of attributes Xof
relation schema R, and Yof relation schema S specifies the constraint
b. Xisa superkey for R, or
that, at any specific time whenr is a relation state ofR and s a relation
A is a key attribute for R. state of S, we must have
BCNF does not permit the third of these options. TyrlR)) c As(S)
BCNF identifies some of the anomalies that are not addressed by 3NF The set of attributes on which the inclusion dependency is specified Xof
2.
3. Arelation in BCNF is also in 3NF but vice-versa is not true. Rand Y of Smust have the same number of attributes. Also domains for
Hence, BCNF is more strict / stronger than 3NE. each pair of corresponding attributes should be compatible.
3. Inclusion dependencies are defined in order to formalize two types of
interrelational constraints :
Que 3.11. Write the difference between 3NF and BCNE. Find the
a. The foreign key (or referential integrity) constraint cannot be
normal form of relation R(A, B, C, D, E) having FD set specified as a functional or multivalued dependency because it
F= (A ’ B, BC ’ E, ED ’ A). |AKTU 2018-19, Marks 07 relates attributes across relations.
b. The constraint between two relations that represent a class/subclass
Answer relationship also has no formal definition in terms of the functional,
Difference : Refer Q. 3.9, Page 3-10A, Unit-3. multivalued, and join dependencies.
Numerical : 4 For example, ifX =A,,A,,.. -,A,] and Y= (B,, B,y,B,), one possible
Given: RA, B, C, D, E) and correspondence is to have dom(A,) compatible withdom(B) for 1 sisn.
F=A ’ B
In this case, we say that A, corresponds to B,.
BC ’ E Que 3.13. Describe lossless decomposition.
ED’A OR
lossless
ACD)* = ACDB A’ B Define functional dependency. What do you mean byfunctional
= ABCDE decomposition ? Explain with suitable example how lossless.
dependencies can be used to show that decompositions are
". BC ’ E
= ABCDE : ED ’A |AKTU 2015-16, Marks 10|
So, ACDis a key of R.
Relation R is in 1NF as all domains are simple i.e., all elements are
atomic. Answer
Functional dependency : Refer Q. 3.1, Page 3-2A, Unit-3.
..R) of arelation R is
PART-3 Lossless decomposition : A decomposition (R,, R,, of R,, Ry, ..., R,
Inclusion Dependence, Lossless Join Decomposition. called a lossless decomposition for Rif the natural join
produces exactly the relation R.
decompositions are lossless using
Following are the condition to show that
Questions-Answers FD set :
1 Union of attributes of R, and R, must be
equal to attribute of R. Each
Long Answer Type and Medium or in R,
Answer Type Questions attribute of Rmust be either in R,
Att(R,) Att(R,) =Att(R)
be NULL.
2. Intersection of attributes of R, and R, must not
Database Management System 3-13 A(CSTT-Sem-5)
3-14A (CSTT-Sem-5)
Att(R,)n AttR,) = Database Design &Normalization
Common attribute must be akey for at least one relation ((R, or R) OR
3.
Write a short note on normalization with
AttR)n Att(R) ’ AttR,) or AttR,) n AttR,) ’ AttR,) advantages.
For example : AKTU2017-18, Marks 05
Consider a relation R(A, B, C, D) with FD set A ’ BC and A ’D is
Answer
decomposed into R, (A, B, C) and R,A, D) which isalossless;join decomposition
as: 1 Normalization is the process of reducing data redundancy in a relational
database.
1. First condition holds true as :
Normalization is a refinement process that the database designer
Att(R,) u Att(R,) =(A, B, C) u (A, D) =(A, B, C, D) =Att(R). undertakes. After identifying the data objects of theproposed database,
2. Second condition holds true as: their relationships define the tables required and columns within each
AttR,)n AttR,) =(A, B, C)n(A, D) =¢ table.
3. Third condition holds true as : 3 The fundamental principle of normalization is, "The same data should
not be stored in multiple places." No information is lost in the process;
Att(R)n Att(R,) =Ais akey of R, (A, B, C) because A’ BC. however, the number of tables generally increases as the rules are
applied.
Que 3.14. Consider the relation rX, Y, Z, W, Q) the set F = (X>Z.
Y’Z,Z>W, WQ->Z, zQ’X) and the decomposition ofr into relations Types of normalization : Refer Q. 3.7, Page 3-7A, Unit-3.
R,(X, W), R,X, Y), R,(Y, Q), R(Z, W, Q) and R,X, ). Check whether Advantages :
the decompositions are lossy or lossless. 1. It helps to remove the redundancy from the relation.
Answer 2 It helps in easy manipulation of data.
3 It helps to provide more information to the user.
To check the decomposition is lossless following condition should hold.
4. It eliminates modification anomalies.
1. RUR,uR,URuR,= (X, W)u X, Y)u(Y,Q)UZ, W,Q)UX,Q)=
CX,Y, Z, W,) =R Que 3.16. What is MVD and join dependency ? Deseribe.
2. (R,nR)n(R,nR)n R,= (X, W)nX, Y) n Y,Q) OR
nZ, W, Q) n(X,Q) = XnQnX,Q) Write a short note on MVD or JD. AKTU 2017-18, Marks 05
= XnQ= OR
Since, condition 2violates the condition of lossless join decomposition. Hence
decomposition is lossy. Deseribe the multivalued dependeney. AKTU 2019-20, Marks 3.5
Answer
PART-4
Multivalued Dependency (MVD) :
Normaliaation using FD, MVID and JDs, Alternative MVD occurs when two or more independent multival ued facts about
Approaches to Database Design. the same attribute occur within the same relation.
2 MVD is denoted by X-’ ’Y specified on relation schema R, where X
and Y are both subsets of R.
Questions-Answers 3 Both Xand Yspecifies the following constraint on any relation state r
Long Answer Type and Medium Answer Type Qquestions of R: If two tuplest, and t, exist in r such that t,(X) = t,X), then two
tuples t, and t, should also exist in r with the following properties,
where we use Z to denote (R - (XU)
Que 3.15. What is normalization ? Explain. ,() =t,0 =t,) =t,X)
1,) =t,() and t, (Z) =t,(2)
3-16A (CSSTT-Sem-5)
Database Management System
3-15 A (CSTT-Sem-5) Database Design & Normalization
Dor example : A Faculty has
,=t,0 and t,(2) = t,(2) multiple courses to teach and he is
Loading several committees. This relation is in BCNF,
called atrivial MVD if bree attributes since all the
An MVDXYin Ris
for decompositionconcatenated together constitutes its key. The rule
4
X is a subset of Yor is to decompose the offending
the multi-determinant attribute or attributes astable into two, with
part of the kev of
b. XUY= R
non-trivial MVD both. In this case to put the relation in 4NF, two separate
An MVID that satisfies neither (a) nor (b) is calleda formed as follows : relations are
For example : Relation with MVD FACULTY_ COURSE (FACULTY, COURSE)
Committee
FACULTY_COMMITTEE (FACULTY, COMMITTEE)
Faculty Subject
Faculty Course Faculty Committee
John DBMS Placement
Placement
John Subject John Placement
John Networking John Networking John Scholarship
John MIS Placement John MIS
John DBMS Scholarship
John Networking Scholarship Fifth Normal Form (5NF):
John MIS Scholarship 1 A relation is in 5NF, if it is 4NF and cannot be further decomposed.
Join Dependency (JD) : 2. In 5NF, we use the concept ofjoin dependency which is a generalized
L A Join Dependency (JD), denoted by (R,, R,..., R,) specified on relation form of multivalued dependency.
scheme R, specifies a constraints on the states r of R. 3 A relation schema R is in 5NF or Project Join Normal Form (PJNF)
2 Theconstraint states that every legal staterofR should have a lossless with respect to a set Foffunctional, multivalued and join dependencies
join decomposition into R,, Ro, ., R,. That is, for every such r, we have if, for every non-trivial join dependency JD (R, Re, ..R,) in F (that is
(Ipr), Izr), ., Ip.r)) =r implied by F), every R, is a superkey of R.
3 Ajoin dependency JD (R,, R, .., R,), specified on relation schema R, is For example :
a trivial JD if one of the relation schemas R, in JD (R, R ..., R) is Company Product Supplier
equal to R.
Godrej Soap Mr. X
4 Such a dependency is called trivial because it has the lossless join
property for any relation state r of R and hence does not specify any Godrej Shampoo Mr. X
constraint on R.
Godrej Shampo0 Mr. Y
Que 3.17. Explain the fourth and fifth normal with suitable Godrej Shampoo Mr. Z
example. H.Lever Soap Mr. X

Answer H.Lever Soap Mr. Y


Fourth Normal Form (4NF) : Mr. Y
H.Lever Shampoo
1 A table is in 4NF, if it is in BCNF and it contains multivalued dependency.
The table is in 4NF as there is no multivalued
dependencies. lose information, which can be
2 A relation schema R is in 4NF, with respect to a set of dependencies r lf we decompose the table then we will
(that includes FD and multivalued dependencies) if, for every non as follows :
trivial multivalued dependency X-’Yin F+, Xis superkey for K. Suppose the table is decomposed into two parts as :
3-18A (CSIT-Sem-5)
Database Design & Normalization
Database Management System
3-17A(CSIT-Sem-5)
4
Coch attribute in R must appear in at least one relation schema R in the
Company Produet Company Supplier docomposition so that no attributes are lost; formally, we have
Supplier
Company Produet Company
Mr. X
ÜR =R
i-1
Soap
Godrej
Godrej rThis iscalled the attribute preservation condition of decomposition.
Godrej Mr. X
Godrej Shampo0
Mr. Z Numerical :
Soap Godrej
HLever
Mr. X A BC DE
Shampoo H.Lever
H.Lever
H.Lever Mr. Y R,= (A, B, C) R a
Ry = (B, C, D)
Rg = (C, D, E) Ry Dg2
have lost the information
The redundancy has been eliminated but wedecomposed in three parts R,nRyn Ry =C R,bg1 a
Now suppose that the original table to be
Dg2
which
Company_Produet, Company_Supplier and Product Supplier, After applying first two functional dependencies first row contain all "a"
is as follows :
Product_Supplier symbols. Hence it is lossless join.
SUPPLIER
PRODUCT Que 3.19.What are the alternate approaches to database design ?
Mr. X OR
Soap
Mr. Y Describe dangling tuples.
Soap
Shampoo Mr. X Answer

Shampoo Mr. Y An alternate approach to database design is dangling tuples:


Shampoo Mr. Z 1. Tuples that "disappear" in computing ajoin are known as dangling tuples.
a Let r,(R,), r,(R,), ..,. r,(R,) be a set of relations.
So, it is clear that ifa table is in 4NF and cannot be further decomposed, b A tuple t of relation R, is a dangling tuple if t is not in the relation:
it is said to be in 5NF.

Que 3.l8. What is meant by the attribute preservation condition 2 The relation r, , a ... r, is called a universal relation since it
involves all the attributes in the "universe" defined byR, uR, U... UR
on decomposition ? Given relation R(A, B,C,D,E) with the functional
dependencies F= (AB->CD, A’E, C’D), the decomposition of R into 3 Ifdangling tuples are allowed in the database, instead of decomposing a
R,(A, B, CO, R,(B, C, D), R,(C, D, E) check whether the relation is lossy universal relation, we may prefer to synthesize a collection of normal
or lossless. form schemas from a given set of attributes.
Answer
VERY IMPORTANT QUESTIONS
Attribute preservation condition on decomposition:
1 The relational database design algorithms start from a single universal Following questions are very important. These questions
relation schema R=(A, A,, .., A,] that includes all the attributes of the may be asked in your SESSIONALS as
tvell as
database. UNIVERSITY EXAMINATION.
2 We implicitly make the universal relation assumption, which states that
every attribute name is unique.
trivial and non
3. Using the functional dependencies, the algorithms decompose the Q.1. What is functional dependency ? Explain
canonical cover.
universal relation schema Rinto a set of relation schemas D = (R, Ky trivial functional dependency. Define
R) that will become the relational database schema; D is called a Ans: Refer Q. 3.2.
decomposition of R.
Database Management System

Q.2. Define normal forms. Explain 1NF,


3-19 A(CSTT-Sem-5)
suitable example. 2NE, 3NF
Ans Refer Q. 3.7.
and BCNE
with
Q.3. Explain fourth and fifth normal form.
Ans Refer Q. 3.17.
Q.4. Prove that BCNF is stricter than 3NE
ANK Refer Q. 3.10.

9.5. Write a short note on MVD and JD.


4UNIT
Transaction Processing
Ans Refer Q. 3.16.

Q.6. What do you mean by lossless


Concept
suitable example how
to show that decomposition ?
functional dependenciesExplain with
Refer Q. 3.13. decompositions
Ans
are lossless. can be used
CONTENTS
Part-1: Transaction System, . 4-2A to 4-6A
Testing of Serializability,
Serializability of Schedules
Part-2 : Conflict and View Serializable 4-6A to 4-15A
Schedule, Recoverability,
Recovery from Transaction
Failures
Part-3 : Log Based Recovery, 4-15A to 4-20A
Checkpoints
Part-4: Deadlock Hand ling 4-20A to 4-23A

Part-5: Distributed Database 4-23A to 4-30A


Distributed Data Storage
Part-6 : 4-30A to 4-33A
Concurrent Control,
Directory System

4-1A (CSIT-Sem-5)
44A(CSTT-Sem-5)
Transaction Processing Concept
3 Atomicity is handled by transactiOn management component Database Management System 4-5A (CSIT-Sem-5)

Ensuring the durability :


Ensuring durability is the responsibility of a
1
recovery management component. component called the Partially
committed Committed

2 The durability property guarantees that, once a transaction


successfully, allthe updates that it carried out on the database
even ifthere is a system failure after the transaction
completes
persist,
Active

completes execution. Failed Aborted


Que 4.4. List the ACID properties. Explain the usefulness of each
Fig. 4.5.1.
property.

Answer
2. Partially committed : A transaction is said to be entered in the
partial state when final statement gets executed. But it is still possible
ACID properties of transaction: Refer Q. 4.2, Page 4 2A, Unit-4 that it may have to be aborted, since its actual operation is still resided
Usefulness of ACID properties : in main memory in which the power failure brings failure of its
execution.
Atomicity : Atomicity is useful to ensure that if for any reason an error 3 Failed : A transaction enters a failed state after the system determines
occurs and the transaction is unable to complete all of its steps, then the that the transaction can no longer proceeds with its normal execution.
SVstem is returned to the state it was in before the transaction was started.
4. Aborted :A transaction enters this state after the transaction has
Consistency: The consistency property is useful to ensure that a complete been rolledback and the database has been restored to its state, prior
execution of transaction from beginning to end is done without interference to the start of the transaction.
of other transactions.
5. Committed : Atransactionenter this state after successful completion.
Isolation :Isolation property is useful to ensure that a transaction should ACID properties with example : Refer Q. 4.2, Page 4-2A, Unit-4.
appear isolated from other transactions, even tho ugh mnany transactions
Que 4.6. How can you implement atomicity in transactions ?
are executing concurrently.
Durability: Durability is useful to ensure that the changes applied to the Answer
database by a committed transaction must persist in the database.
Implementation of atomicity in transaction can be done in two ways :
Que 4.5. 1 Completeness :
Explain transaction state in brief.
Allof the operations encapsulated within adatabase transaction
OR
What is transaction ? Draw a state diagram ofa transaction showin5 represent an atomic unit of work.
its states. Explain ACID properties of a transaction with suitable b. According to atomicity either all of transaction will run to
completion (Commit) or none of them.
examples. |AKTU 2015-16. Marks 10 C. There will not be any partial transaction in left over state
from
OR incomplete execution of one or more operationsina transaction.
Draw a transaction state diagram and describe the states a d. If the user decides to cancel
everything (Rollback), all of the
transaction goes through during execution. changes made by the tran saction will be undone and the state
would be as ifthe transaction never began by using undo operation.
Answer e. For every change made by
data to be used to rollbackoperations
in the database, it logs undo
Transaction : Refer Q. 4.1, Page 4-2A, Unit-4.
State diagram of the effects of operations.
1 Active :
transaction : the final
2. Mutual exclusion/Mocking :
The
transaction is said to be in the active state till a. Only one transaction will be
statement is executed. exclusive lock on the particularallowed to progress
data item.
by taking an
46A(CSTT-Sem-5) Transaction Processing Concept Database Management System 4-7A (CSTT-Sem-5)

The lock will not be released until the transaction ends (either
3. However, if I, andI, refer to the same data item Q. then the order ofthe
through rollback, commit or abort). two steps matter.
C. Any other concurrent transaction interested in updating the same Following are four possible cases :
row will have to wait. 4
Swapping possible
Que 4.7. What is serializability ? Why serializability is required ?
Write short note on serializability of schedule. Read (Q) Read () Yes

Read (Q) Write (Q) No


Answer
Write (Q) Read (Q) No
Serializability : Serializability is a property of a transaction schedule which
is used to keep the data in the data item in consistent state. It is the classical Write (Q) No
Write (Q)
concurrency scheme.
5. I, and I, conflict ifthere are operations by different transactions on the
Serializability is required : operation.
same data item, and at least one of these instructions is a write
1 To control concurrent execution of transaction.
2 To ensure that the database state remains consistent.
For example :
Schedule S
Serializability of schedule : T
1 In DBMS, the basic
assumption is that each transaction preserves read (A)
database consistency. write (A)
2 Thus, tbe serial execution of a set of read (A)
transaction preserves database
consistency. write (A)
3 Aconcurrent read (B)
schedule is serializable if it is equivalent to a serial write (B)
schedule.
read (B)
write (B)
PART-2
Conflict and View Serializable Schedule, The write (A) instruction of T, conflicts with read (A) instruction of
Recoverability,
Recovery from Tran saction Failures.
T,. However, the write (A) instruction of T, does not conflict with
the read (B) instruction of T, as they access different data items.
Schedule S'

Questions-Answers T T.
Long Answer Type and Medium Answer read (A)
Type Questions write (B)
read (A)
read (B)
Que 48. Discuss conflict serializability with write (A)
example. write (B)
Answer read (B)
1 write (B)
Consider a schedule S, in which there are two
2
I, and I, of
transactions T, and T, respectively consecutive
IfI and I, refer to (i j).
instructions Since the write (A) instruction of T, in Schedule Sdoes not conflict
different
affecting the results of any data items, then swap I, and 1, witho
with the read (B) instruction of T,, we can swap these instructions
instruction in
the schedule. to generate an equivalent schedule.
iü. Both schedules will produce the same final system state.
4-8A (CSIT-Sem-5)
Lsaction Processing Concept Database Management System 4-9A (CSTT-Sem-5)
6. If a schedule S can be transformed into a
schedule S by a
swaps of non-conflicting instructions, we say that Sands series of Schedule Sl and S2 are view equivalent as :
equivalent. are conflict 1 T, reads initial value of data item A in Sl and s2.
7 The concept of conflict
equivalence leads to the concept of confict 2 T, reads value of data item A written by T, in S1 and S2.
serializability and the schedule S is conflict serializable.
3 T, writes final value of data item A in Sl and S2.
Que 4.9. Explain view
serializability with example. Que 4.10. What is schedule ? Define the concept of recoverable,
Answer cascadeless and strict schedules.
1 The schedule S and S are said to
be view
three conditions met : equivalent if following Answer
a For each data item Q, if Schedule : A schedule is a set of transaction with the order of exe cution of
in schedule S, then transaction T; reads the initial value of 0 instruction in the transaction.
the initial value of Q.transaction T, in schedule S, must also read Recoverable schedule :
b For each data item Qif Arecoverable schedule is one in which for each pair of transaction T; andT
transaction T,
S and if that value
produced by a writeexecutes read (Q) in schedule
(Q)operation executed
if T,reads a data item previously written by T, the commit operation of T
appears before the commit operation of T;.
transaction then the read (Q) operation
T,
of transaction T, in
by
schedule S,must also read the value of Q that Sor example : In schedule S, let T, commits immediately after executing
the same write (Q) was produced by read (A) ie., T, co-umits before T, does. Now let T, fails before it commits,
For each data itemn operation
of transaction T
C.
Q, the transaction we must abort I, to ensure transaction atomicity. But as T, has already
final write (Q) operation in (if any) that
performs the committed, it cannot be aborted. In this situation, it is impossible to recover
write (Q)operation in
schedule S must perform the final correctly from the failure of T,.
2 schedule S'.
Conditions (a) and (b) ensure that each Schedule S
values in both schedules and transaction reads the same T
therefore, performs
Condition (c), coupled with condition the same
both schedules result in the (a)and condition (b)computation.
ensure that read (A)
3. The same final system state.
concept of view equivalence leads to the write (A)

4
serializability. concept of view read (A)
We say that schedule S is view
5
serial schedule. serializable, ifit is view equivalent to read (B)
Every conflict serializable Cascadeless schedule :
are view schedule is also view serializable but
Example: serializable schedules that are not conflict serializable. there 1. Acascadeless schedule is one, where for each pair of transaction T,
and T, such that T, reads a data item previously written by T, the
Schedule S1 commit operation to T, appears before the read operation of T,
Schedule S2
2 Even if a schedule is recoverable, to recover correctly from the
T. Ti fajlure of a transaction T, we may have to rollback several transactions.
T Such situations occur if transactions have read data written by T;
read (A)
Write (A) read (A) Strict schedule :
read (B) write (A) 1 Aschedule is called strict if everyvalue written by a transaction Tis
write (B) read (A) not read or changed by other transaction until T either aborts or
commits.
read (A) read (B)
write (A)
write (A) 2 Astrict schedule avoids cascading and recoverability.
read (B) write (B)
write (B) read (B)
write (B)
4-11A (CSTT-Sem-5)
410A (CSTT Sem-5) Transaction Processing Concept Database Management System

How can it be used to to, Example:


Que 4.1L.What isprecedence graph ? T,
schedule ?
the confict seriaizability of a read (Yn;
read (Z);
Answer
read (X);
Precedence graph: write (X;
of set of write (Y);
L Aprecedence graph is a directed graph G =(N, E) that=consists write (Z);
nodes N= (T, T.. T) and set of directed edges E le, e,..., e).
read (Z:
2 There is one node in the graph for each transaction T in the schedule read (Y);
3 Each edge e, in the graph is of the form (T, ’ T), 1 <j sn, 1 <ksn. write (Y;
where T, is the starting node of e, and T, is the ending node ofe,. read (Y):
write (Y;
4 Such an edge is ereated if one of the operations in T, appears in the read (X):
schedule before some conflicting operation in T,
write X);
Algorithm for testing conflict serializability of schedule S : Schedule S
For each transaction T, participating in schedule S, create a node XY
labeled T, in the precedence graph.
b For each case in S where T, executes a read_item() after T
executes a write_item0, ereate an edge (TT)in the precedence Y Y, Z
graph.
T,
C For each case in S where T, executes a write_item(X) after T Fig. 4.11.1. Equivalent serial schedules T, ’T, ’
executes read item(X,ereate an edge (T, ’ T) in the precedence following schedule:
graph. Que 4.12. Test the serializability of the
For each case in S where T; executes a write_item(X) after T r,); r,r); o (); rr); w, )
executes awrite_item(), create an edge (7T ’ T) in the precedence ii. r,a); r,); o,Cr); r, (r); e, ()
graph.
Answer
e.
The schedule S is serializable if and only if the precedence graph The serialization graph is :
has no cycles.
5 The precedence graph is constructed as described in given algorithm.
6 If there is a cycle in the precedence graph, schedule S is not (conflict)
serializable; if there is no cycle, S is serializable.
7 In the precedence graph, and edge from T;, to T, means that transaction
T must come before transaction T; in any serial schedule that is Fig. 412.1.
equivalent to S, because twoconflicting operations appear in the schedule There are two cycles. It is not serializable.
in that order. The serialization graph is :
Ifthere is no cycle in the precedence graph, we can create an equivalent
serial schedule S that is equivalent to S, by ordering the transactions
that participete in Sas follows: Whenever an edge exists in the precedence
graph from T to T, T, must appear before T, in the equivalent seral
schedule S.
Fig. 4122.
4-12 A (CSTT-Sem-5) Transaction Processing Concept Database Management System 4-13 A (CSIT-Sem-5)

There is no cycle, so it is serialized. We prefer serializable schedule instead of serial schedule because :
The equivalent serial schedule i_: 1. The problem with serial schedule is that it limits concurrency or
r,*), r,a), w,*), ra), w,() interleaving of operations.
2 In a serial schedule, if a transaction waits for an VOoperation to
Que 4.13. Discuss cascadeless schedule and cascading rollback complete, we cannot switch the CPU processor to another transaction,
Why is cascadeless of schedule desirable ? thus wasting valuable CPU processing time.
3. If some transaction T is quite long, the other transactions must wait
Answer for T' to complete all its operations before committing.
Cascadeless schedule : Refer Q. 4.10, Page 4-9A, Unit-4.
Cascading rollback :Cascading rollback is a phenomenon in which a
Que 4.15. What are schedules ? What are differences between
single failure leads to a series of transaction rollback. conflict serializability and view serializability ? Explain with suitable
example what are cascadeless and recoverable schedules ?
For example:
Schedule S
AKTU2015-16, Marks 10

T Answer
Ts
read (A) Schedule : Refer Q. 4.10, Page 4-9A, Unit-4.
read (B) Differen ce between conflict and view serializability :
write A)
read (A S. No. Conflict serializability View serializability
write (A) 1. Easy to achieve. Diffcult to achieve.
read (A) 2
In the exarnple, transaction T, writes a Cheaper to test. Expensive to test.
T. Transaction T, writes a value of Athatvalue ofA that is read by transaction 3 Every conflict serializable is Every view serializable is not
is read by transaction T,. Suppose view serializable. conflict serializahl
that at this point T, fails. T,must be rolled back.
Since T, is
dependent on T.. T, mustdependent
T,must be rolled back, since T, is on T,, 4. Used in most concurrency Not used in cor.: vcontrol
Need for cascadeless be rolled back. control scheme. scheme.
schedules :
Cascadeless schedules are desirable because the failure of a Cascadeless schedule : Refer Q. 4.13, Page 4-12A, Unit-4.
does not lead to the aborting of any other transaction Recoverable schedule : Refer Q. 4.10, Page 4 9A, Unit-4.
cost of less
concurrency. transaction. This comes at the
Que 4.14. Que 4.16. What is schedule ? What are its types ? Explain view
Discuss the rules to be
serializable schedule. Why should we followed
prefer
while preparing a serializable and cascadeless schedule with suitable example of each.
instead of serial schedules ? serializable schedules AKTU2018-19, Marks 07
Answer
The set of rules
schedule are : which mnust be followed for preparing serializable Scheduie : Refer Q. 4.10, Page 4-9A, Unit-4.
Types of schedule are :
1. Take any
concurrent 1 Recoverable schedule
2
Draw the precedence schedule.
graph for concurrent
2 Cascadeless schedule
3 3 Strict schedule
Ifthere is a cycle in precedence graph
4. If there is no
schedule.
then schedule is not View serializable : Refer Q. 4.9, Page 4 8A, Unit-4.
cycle the schedule serializable.
is serializable. Cascadeless schedule : Refer Q. 4.10, Page 4-9A, Unit-4.
5
Prepare serializable schedule using precedence graph.
414A(CSTTSem-5)
Transaction Processing Concent Database Management System
4-15 A (CSTT-Sem-5)

Which of the following schedules serializable.


Que 417. are cycle. Hence, it is conflict
conflicts Since, the graph does not contain
serializable ? For each serializable schedule find the For S3 :
schedule.
Sl:rlt r3trl; ue3ir); wl(c); r2(r)
equivalent T, T,
r3z)
S2:rsirh rr; 3(); rl(r); wlr)
r3z)
S:rlchr2rk r3(y; el(r); r2(2); r2(y); w2(4)
rlz)
w3(x)
AKTU 2018-19, Marks 07
wl(r)
Answer
For Sl : T

T, T,
rlr)
r3()
w3x) Fig. 4.17.3.
wlir)
it is not conflict serializable.
r2) Since, the graph contains cycle. Hence,
PART-3

Log Based Recovery, Chechpoints.

Questions-Answers

Fig. 4.17.1. Type Questions


Since, the graph does not Long Answer Type and Medium Answer
For S2 : contain cycle. Hence, it is conflict serializable.
T T T, Que 4.18. Explain log based recovery.
OR
the features of deferred
r2r)
r3) What is log ? How is it maintained ? Discuss
database modification in
database modification and immediate
rlr) w3x) AKTU 2017-18, Marks 10
brief.
wlz)
Answer
recording all the update
1 The log/system log is a sequence of log records,
activities in the database.
2 Various types of log records are denoted as :
T start>:Transaction T, has started.
b. <T,X, V,, V>: Transaction T, has performed awrite on data item
X, X, had value V, before the write, and will have value V, after the
Pig, 4172. write.
4416A (CSIT-Sem-5)
Transaction Processing Concent Database Management System
4-17A (CSTT-Sem-5)

c. <T,commit> : Transaction T, has committed.


d. <T,abort> : Transaction T has aborted.
Answer copies (known as shadow
3. Whenever a transaction performs a write, it is essential that the paging is a technique in which multiple
maintained on the disk.
record for that write be ereated before the database is modifed log 1 Shadow
data item to be modified are
logical
copies) of the made up offixed-size
Log based recovery : Log based recovery is a method |to ensure considers the database to be
using log when failure occurs. In log based recovery, following two atomicity 2 Shadow paging
pages. with the help of
units of storage called
are used to ensure atomicity andto maintain log: techniques These pages are mapped into physical blocks of storage
1. Deferred database modification: page table (or
directory). the logical blocks.
The deferred database modification technique blocks are of the same size as that of the
ensures transaction The physical which the /th entry in
entries is constructed in the disk as shown in
4
atomicity by recording all database modifications in the log. but table withn
deferring the execution of all write operations of a transaction until 5 A page th database page
on
points to the
the transaction partially commits. page table
Fig.4. 19.1. maintain two page tables.
When a transaction partially commits, the this technique is to
information on the log
associated with the transaction is used in executing 6. The main idea bebhind the most recent
database
the deferred current page the entries points to starts, the current page
Writes. a In When a transaction
pages on the disk. shadow directory).
Features of deferred database copied into a shadow page table (or current
modification: table is the disk and the
1 All logs written onto the table is then saved on shadow page table is
database is updated when a
transaction b The shadow page transaction. The
commits, the
page table is used by the execution of the transaction.
2 It does not require old never modified during
value of data item on the log.
3 It do not need extra VO Current page table
operation before commit time. Shadow page Database Disk pages
4 It can manage with large table
memory space. Page 1 (old)
5 Locks are held till the commit point. 1 2
2 Page 2
Immediate database modification : 2
Page 3(old)
3
The immediate database 3 4
modifications to be outputmodification technique allows database
to the database while the 4
Page 4
5
still in the active state. transaction is 5
5 Page 5
6
Data modification written by 6 Page 6
active 4 7
Features of immediate database transactions. Page 7
1. All modification :
logs written onto the database 8 Page 8
4
8
is updated
every operation.
2. It
immediately after 9 Page 1 (new)
requires both old and new value of data
item on
10 Page 3 (new)
3 It needs extra I/O the log.
4 It can
operation to flush out block-buffer.
11

5
manage with less memory space.
Locks are released after
Que 4.19.
modification.
Describe shadow paging recovery
technique. Fig. 4.19.1. Shadow paging
AKTU2016-17. Marks 05
4-18 A(CSTT-Sem-5)
Transaction Processing Concept 4-19 A (CSTT-Sem-5)
When shadow paging does not require log: Database Management System
It does not require the use of log in an environment where
only one Steps for log based recovery :
is active at a time.
transaction 1 The log file is kept on a
stable storage media.
execution, it writes a
Que 4.20. What do you mean by the system and starts
important types of checkpointing methods. checkpointing ? Explain 2 When a transaction enters
log about it
<T,, start>
follows
Answer an item X, it write log as
3 When the transaction modifies
Checkpointing : <T, X, V, V>
1. Itis a process of saving a snapshot of the the value of X, from V, to V,.
application's state, so that it
can restart from that point in case of failure. It reads as T, has changed
finishes, it logs
2. Checkpoint is a point of time at 4 When the transaction
which a record is written onto the <T,, commit>
database from the buffers.
3. Checkpointing shortens the For example :
Types of checkpointing recovery process. <T, start>
1. techniques
:
<To, A, 0, 10>
Consistent checkpointing :
a.
Consistent checkpointing creates a consistent imageof the <Ty, commit>
at checkpoint. database <T,, start>
b. During recovery, only those <T,, B, 0, 10>
last checkpoint are undone ortransactions which take place after <T, start>
C.
The transactions that take place redone.
<T,, C, 0, 10>
checkpoint are already committed and before the last consistent
need not be processed <T, C, 10, 20>
d The
actions taken for check pointing are: again.
i.
<checkpoint (T,, T,)>
All changes in
disk. main-memory buffers are written onto tne <T, start>
ii. <T, A, 10, 20>
i. The
A"checkpoint" record is written in the transaction log. <T, D,0, 10>
2. Fuzzy transaction: log is written to the disk. <T, commit>
checkpointing
In fuzzy Describe the important types of recovery
techniques.
b transactions
In case of
checkpoi nting, atin thethe log.time of checkpoint, all the active
are written
Que 4.22.
Explain their advantages and disadvantages.
failure, the recovery
C transactions
The that were active manager processes only those
during checkpoint and later. Answer
transactions
written the diskthatandhave been committed before checkpoint are
to There are many different database recovery
techniques to recover a database:
4-15A, Unit-4.
Que 4.21. What is hence need not be Deferred update recovery: Refer Q. 4.18, Page
log file? redone. 1.
Advantages :
of a Write the steps for log based recovery
system with suitable a Recovery is easy.
transaction
example. AKTU2018-19, Marks 07 b Cascading rollback does not occur because no other
Answer sees the work of another until it is
committed.
Log file :Alog file is Disadvantages :
afile
database. that records all the update occur in the a. Concurrency is limited.
activities Immediate update recovery :Refer Q4.18, Page 4-15A,
Unit-4.
2
4-20 A (CSTT-Sem-5)
Transaction Processing Concept Database Management System
4-21 A (CSIT-Sem-5)

Advantages : Deadlock detection :


system
It allows higher concurrency because 2.
indefinitely to obtain a lock,
transactions
continuously to the database rather than waiting
write
until the cnm a. When a transaction waitstransaction is involved in a deadlock or
the
should detect whether
point.
not. deadlock
for dete cting the
Disadvantages :
b Wait-for-graph is one of the methods
a It leads to cascading rollbacks. situation.
the tran saction and
b. It is time consuming and may be problematic. graph is drawn based on
In this method a resource.
C.
their lock on the
cycle, then there is a
has a closed loop or a
PART-4 d. If the graph created
Deadlock Handling. deadlock.
Wait-for-lock (R1 )
T2
Questions-Answers Wait-for-lock (R2)
Long Answer Type and Medium Answer Type Questions Fig. 4.23.1. Wait-for-graph.

3. Recovery from deadlock : transaction


we determine which
Que 4.23. What is a deadl ock ? Describe Selection of a victim : In this deadlock. We should
methods to handle a a.
to break the
(ortransactions) to roll back cost.
deadlock. willincur the minimum
rollback those transactions that the
OR
Rolback: The simplest solution is a "total rollback". Abort
What is deadlock ? How it can be detected and b.
avoided ? transaction and then restart it.
Answer selection of trans actions, for
Starvation : In a system where
Deadlock:
C.
rollback, is based on the cost factor, it may happen that the some
1 A
deadlock is a situation in which two or more transactions are always picked up.
transactions are waiting avoided by following methods :
for locks held by the other Deadlock avoidance: Deadlock can be
2. transaction to release the lock. 4.
can access the database at
Every transaction is waiting for another Serial access : If only one transaction
operations. transaction to finish a time, then we can
avoid deadlock.
Methods to handle a deadlock : that each transaction
b Autocommit transaction : It includes finishes
1
Deadlock immediately as it uses it, then
prevention protocol : This protocol ensures that the system can only lock one resource
will not go into its transaction and releases its lock before requesting any other
used for deadlock deadlock state. There are diferent methodsthat can be
prevention : resource.
request resources in
Pre-declaration
transaction method: This method requires that each
locks all its data
C. Ordered updates : If transactions alwaysascending
the same order (for example, numerically by the index
item before it starts do not enters in
b.
Partial ordering method execution. value of the row being locked) then system
:In this
partial ordering of all method, system 1mpon deadlock state.
can lock a data item data items and I requires that a transaction
only in the order d. By rolling back conflicting transactions.
C. specified by partial order.
Timestamp method : In this method, the data item are locked
using e. By allocating the locks where needed.
timestamp of tran saction.
4-23 A (CSTT-Sem-5)
4-22 A (CSTT-Sem-5) Transaction Processing Concept Database Management System

schemes.
Que 4.24. Discuss about the deadlock prevention Answer

AKTU 2016-17, Marks 10 Deadlock: Refer Q.4.23, Page 4-20A, Unit-4.


deadlock situation can arise if the
OR Necessary condition for deadlock:A ina system :
Discuss about deadlock prevention schemes.
following four conditions hold simultaneously non
resource must be held in a
Mutual exclusion : At least one
|AKTU2019-20, Marks 07 1.
sharable mode; that is, only one process at a time can use the resource.
requests that resource, the requesting process must
If another process been released.
Answer be delayed until the resource has
holding at least one resource and
Deadlock prevention schemes: Hold and wait : A process must be
2.
that are currently being held by
1. Wait-die scheme : waiting to acquire additional resources
other processes.
In this scheme, ifa transaction request to lock a resource (data
item), which is already held with conflicting lock by some other 3. No pre-em ption : Resources
cannot be pre-empted; i.e., a resource can
it, after that process has
transaction, one of the two possibilities may occur : Le relensed only by the process holding
completei tesk.
a If TST)<TST), ie., T, which is requesting a conflicting Circulat set lPo, P, -, P)of waitingP,,processes
must exist
lock, is older than T, T, is allowed to wait until the data item 4
held by P, is waiting for a
is available. such thwaiting for a resource held by P,, and P.
resource held by Po, *., P is waiting for a resource
b. If TS(T) >TS(T), ie., T, is younger than T, so T, dies. T, is is waiting for a resource held by P¡:
restarted later with random delay but with same timestamp. 4-20A, Unit 4.
Deadlock detection and recovery : Refer Q. 4.23, Page
iü. This scheme allows the older transaction to wait but kills the
younger one.
PART-5
2 Wound-wait scheme :
Distributed Database : Distributed Data Storage.
In this scheme, if a transaction request to lock a resource (data
item), which is already held with conflicting lock by some other
transaction, one of the two possibilities may occur : Questions-Answers
If TS(T) <TS(T), ie., T,which is requesting a conflicting
lock, is older than T,, T, forces T to be rolled back, that is T, Long Answer Type and Medium Answer Type Questions
wounds T,T, is restarted later with random delay but with
same timestamp.
b
IrTST) >TS(T), ie, T, is younger than T, T, is forced to
wait until the resource (i.e., data item) is available. Que 4.26. What is distributed databases ? What are the advantages
Thisscheme, allows the younger transaction to wait but when an and disadvantages of distributed databases ?
OR
older transaction request an item held by younger one, the older
transaction forces the younger one to abort and release the item. Explain the advantages of distributed DBMS.
In both cases, transaction., which enters late in the system, 1S
aborted.

Que 4.25. What is deadlock ? What are necessary conditions for


it ? How it can be detected and
recovered ?
AKTU2018-19, Marks 07
4-25 A (CSTT-Sem-5)
4-24 A
(CSIT-Sem-5)
Transaction Processing Concept Database Management System

Disadvantages of DDBMS : environment.


Answer distributed database
Complex software is required for a perform additional
Distributed database : 1.
exchange message and
2. The various sites must coordination among the sites.
calculations to ensure proper need for coordination
is
increased complexity and
Fragments 3 A by-product of the improper updating and other problems of
to
Fragments
of Main
of Main
the additional exposure
database data integrity.
database to their usage, or if
distributed properly accordingrequests
User 1 User 2 4 If the data are not correctly, response to for data can
queries are not formulated
be extremely slow.
atomic commit protocols ?
Fragments Fragments Que 4.27. What are
of Main of Main
database database Answer supporting global
User 3| 1 Atomic commit protocols are the key element in
User 5 distributed transactions.
atomicity of
standard atomic commit protocol.
Two-phase commit protocol (2PC) is the
correctness properties in the complex
2
User 4 Fragments 8 2PC is important to guaranteethe
due
same time it reduces parallelism of
of Main distributed world whilst at
database message overhead and locking during windows
to high disk and
Fig. 4.26.1. vulnerability.
Distributed database. requires processes to agree on a
1 An atomic commitment problem
Adistributed database
together through systemconsists ofcollection of sites, connected
4
common outcome which can be
either commit or abort.
a
communication network. guarantee the following atomic
2 Each site is a database 5. An atomic commit protocol must
sYstem site in its own right and thesites commitment properties :
agreed to work together, so that a User at anv nave reach the samne one.
In the network as if the data site can access anywhere
were all stored at the user's local AC, :Al processes that reach an outcome
site. outcome after it has reached
AC,:A process cannot reverse its
3.
Each side has its own local b
4. Adistributed database.
database fragmented into smaller data sets.
is
One
participant
5
DDBMS can handle both local and C. AC,:The commit outcome can only be reached ifall
Advantages of DDBMS : global transactions. voted Yes.
Yes,
1
DDBMS allows each site to store and d. AC, : If there are no failures and all participants voted
immediate and efficient maintain its own database, causing then the outcome will be commit.
2 It access to data.
allows access to C. AC,: Consider any execution containing only failures that the
users can retain thethe data stored at remote sites, At the same time protocol is designed to tolerate.
3
Ifone site is not control to its own site to access thelocal data. 6 repaired and
At any point in the execution, if all existing failuresallareprocesses
link goes down) theworking due to any reason (for example, communication no new failures occur for sufficiently long, then will
network can possiblysystem will not be down because other sites ofthe eventually reach an outcome.
New sites can be continue
4
6. funetioning.
Ifa user needs to added to the system anytime with no or little efforts. Que 4.28.Explain replication and its types in distributed system.
query can be access the data from multiple sites then the desired
subdivided into sub-gueries in Answer
parallel. 1 Replication isa technique of replicatingdata over a system.
4-26A (CSTT-Sem-5) Transaction Processing Concept Database Management System 4-27 A (CSTT-Sem-5)

2
Replication is a key to the effectiveness of distributed lsystems in that, it Passive replication
provides enhanced performance, high availability and high fault tolerance. Client
8 The replication is the maintenance of copies of dataat multiple computers
4 Replication is a technique for enhancing a service.
5 When data are replicated, the replication transparency is required ie.
cients should not normally have to be aware that multiple copies of data Process Process
Process
exist.
Types of replication :
L Active replication : (State State) State)
1 In active replication each chent request is processed by all the servers. Server Server Server
2 This requires that the process hosted by the servers is deterministic, Fig. 4.28.2.
Le., given the same initial state and arequest sequence, all processes
willproduce the same response sequence and end up in the samne Que 4.29. Explain data fragmentation with types.
final state. |AKTU 2017-18, Marks 1O
Active replication
Client Answer
Fragmentation :
1 It is the decomposition of a relation into fragments.
2 It permits to divide a single query into a set of multiple sub-queries that
Process Process Process can execute parallelon fragments.
3 Fragmentation is done according to the data selection patterns of
applications running on the database.
State State) State)
Fragmentation techniques/types are as follows :
Server Server Server 1 Vertical fragmentation :
Fig. 4.28.1.
3 In order to make all the
a. It divides a relation into fragments which contain a subset of
servers receive the same attributes of a relation along with the primary key attribute of the
operations, an atomic broadcast protocol must be used.sequence
of
relation.
4 An atomic broadcast protocol
guarantees that either all the servers
receive a message or none, plus that they all receive Name Reg. No. Course Dept
the same order. messages in
ii. Passive replication :
1 Fragmentation1 Fragmentation2| Fragmentation3
In passive replication there is only one
processes client requests. server (called primary) un
2.
After processing arequest, the primary server updates the state on
the other (backup) servers and sends back the Fig. 4.29.1. Vertical fragmentation.
client. response to e b The purpose of vertical fragmentation is to partition a relation
3. If the primary
server fails, one of the backup servers takes its into a set of smaller relations to enable user applications to run on
place. only one fragment.
4
Passive
processes.replication may be used even for non-deterministic
4-28 A (CSTT-Sem-5) Transaction Processing Concept Database Management System 4-29 A (CSIT-Sem-5)

2
Horizontal fragmentation : with a suitable example, what are the differences in replication and
It divides a relation into fragments along its tuples. Each fragment fragmentation transparency ? AKTU 2015-16, Marks 10
is a subset of tuples of a relation. OR
b
It identifies some specific rows based on some criteria and marks it Explain the types of distributed data storage.
as a fragment. OR
Name Reg. No. Course Depth What are distributed database? List advan tage and disadvantage
of data replication and data fragmentation.
Fragmentation 1
AKTU2019-20, Marks 07
Fragmentation2
Fragmentation3 Answer
Fragmentation4 Distributed database : Refer Q. 4.26, Page 4-23A, Unit-4.
Fig. 4.29.2. Horizontal fragmentation. Advantages of data replication :
C Various horizontal fragmentation techniques are : Availability : If one of the sites containing relation r fails, then the
Primary hori~ontal fragmentation : This type of relation r can be found in another site. Thus, the system can continue to
fragmentation is done where the tables in a database are process queries involving 'r', despite the failure of one site.
neither joinednor have dependencies. So, no relationship exists ii. Increased parallelism : Number of transactions can read relation r in
among the tables. parallel. The more replicas of r there are, the greater parallelism is
achieved.
ii. Derived horizontal fragmentation : Derived horizontal
fragmentation is used for parent relation. It is used where Disadvantages of data replication :
tables are interlinked with the help of foreign keys. It ensures i. Increased overhead on update : The system must ensure that all
that the fragments which are joined together are put on the replicas ofarelation r are consistent; otherwise, erroneous computation
same site. may result Thus, whenever r is updated, the update must be propagated
3
Hybrid/mixed fragmentation : to all sites containing replicas. The result is increased overhead.
a.
The mixed/hy iridfragmentation is combination of horizontal and Advantages of data fragmentation :
vertical fragmentations. L Parallelized execution of queries by different sites is possible.
b This type is most complex one, because both types are used in Data management is easy as fragments are smaller compare to the
horizontal and vertical fragmnentation of the DB application. complete database.
C
The original relation is obtained back by join or union operations. Increased availability of data to the users/queries that are local to the
R site in which the data stored.
iv. As the data is available close to the place where it is most frequently
HF HF used, the efficiency of the system in terms of query processing,
R
transaction processing is increased.
VP
V
Data that are not required by local applications are not stored locally. It
VE VF leads to reduced data transfer between sites, and increased security.
VF VF
Disadvantages of data fragmentation :
Rz1 Rg2 The performance of global application that requires data from several
Fig. 4.289.3.
Hybrid/mixed fragmentation. fragments located at different sites may be slower.
Que 4.30. What are Integrity control may be more difficult ifdata and functional dependencies
disadvantages of data distributed database ? List advantages arnd are fragmented and located at different sites.
replieation and data fragmentation. Explain
4-30 A
(CNTT-Sem-5) Transaction Processing Concept Database Management Systenm 4-31A(CSIT-Sem-5)
Differences in replication and fragmentation transpareney:
8 No.Replication transpareney Pragmentation transparency Questions-Answers
It involves placing copies of Itinvolves decomposition ofa table
Long Answer Type and Medium Answer Type Questions
1
each table or each of their in many tables in the system.
fragments on more than one
site in the system.
Que 4.32. What is coneurrency control ? Why it is
needed in
2 The user does not know The user does not know about.
about how many replicas of how relation is divided/ database system.
the relation are present in fragmented in the system. OR
system ?
the system. Explain concurrency control. Why it is needed in database
3 For example, if relation r is For example, if relation r is AKTU2019-20, Marks 07
replicated, a copy of relation fragmented, 'r is divided into a
r is stored in two or more number of fragments. These Answer
sites. In extrene case, a copy fragments contain sufficient 1 Concurrency Control (CC) is a process to ensure that data is updated
is stored in every site in the information to allow correctly and appropriately when multiple transactions are concurrently
system which is calledas full reconstruction of the original executed in DBMS.
replication. relation 'r. more database
2. It is a mechanism for correctness when two or
executed
There are two types of distributed data storage : transactions that access the same data or dataset are
concurrently with time overlap.
L Data fragmentation :Refer Q. 4.29, Page 4-27A, Unit-4. transaction
2 Data rcplication : Refer Q.4.28, Page 4-25A, Unit-4. 3 In general, concurrency control is an essential part of
management.
Que 431. Discuss the types of distributed database. Concurrency control is needed :
1 To ensure consistency in the database.
Answer
2. To prevent following problem:
Distributed databases are classified as: a. Lost update :
1. Homogeneous distributed database : 1 A second transaction writes a second value of a data item
on
In this, all sites have identical database top of a first value written by a first concurrent transaction,
management system and the first value is lost to other transactions running
software.
b All sites are aware of one another, and agree to
concurrently which need, by their precedence, to read the
co-operate in first value.
processing user's requests. The transactions that have read the wrongg value end with
2
Heterogeneous distributed database: incorrect results.
In this, different sites may use
different schemas, and differen b. Dirty read :
database management system software. i Transactions read a value written by a transaction that has
b The sites may not be aware of
one another, and they may provide been later aborted.
only limited facilities for This value disappears from the database upon abort, and should
co-operation in transaction proceSsins
not have been read by any transaction ("dirty read").
PART-6 The reading transactions end with incorrect results.
iii.
Concurrent Control, Directory System. Que 4.33. Explain coneurrency control mechanism performed in
distributed databases ?
432A (CSTT-Sem-5)
Transaction Processing Concept Database Management Systemn 4-33 A (CSTT-Sem-5)
Answer
2 Atransaction can acquire a lock on object Oin some mode M.
Following are concurrency control mechanism in Doing that, it holds the lock in mode Muntil its termination.
database :
Two-phase commit protocol :
distributed 3
4 Besides holding a lock, a transaction can retain a lock in mode M.
Two-phase
designed to allowany participant to abort its part ofcommit protocol is 5 When a subtransaction commits, its parent transaction inherits its
the requirement for atomicity, if one part of a transaction. Due to locks and then retains them. Ifatransaction holds a lock, it has the
then the whole transaction must also be aborted. transaction is aborted right to access the locked object (in the corresponding mode).
However, the same is not true for retained locks,
Following are the two phase used in this protocol: 6

Phase 1 (voting phase): 7. Aretained lock is only a place holder and indicates that transactions
outside the hierarchy of the retainer cannot acquire the lock, but
1 The co-ordinator sends a that descendants potentially can.
canComnmit? request to each of the
participants in the transaction.
8. As soon as a transaction becomes a retainer of a lock, it remains a
2 When a participant receives retainer for the lock until it terminates.
vote (Yes or No) to the canCommit? request it replies with its
co-ordinator. Before voting Yes, it prepares
to commit by saving objects Que 4.33. Explain directory system in detail.
in permanent storage. Ifthe vote is No,
the participant aborts immediately. AKTU 2019-20, Marks 07
Phase 2(eompletion according to outcome of vote):
1 The co-ordinator collects the votes
(including its own). Answer
Ifthere are no failures and all the votes are Yes the
co-ordinator 1 directory is a listing of information about some class ofobjects such
A
decides to commit the transaction and sends a doCommit as persons.
request each of the participants.
to 2 Directories can be used to find information about a specific object,or in
b
Otherwise the co-ordinator decides to abort the the reverse direction to find objects that meet a certain requirement.
and sends doAbort requests to all transaction In the networked world, the directories are present over a computer
2 Participants that voted Yes are participants that voted Yes. 3
network, rather than in a physical (paper) form.
waiting for a doCommit or doAbort which
request from the co-ordinator. When a 4 Adirectory system is implemented as one of more servers,
these messages it acts accordingly and inparticipant receives one of
the case of commnit, makes service multiple clients.
a the
haveCommittedcalls as confirmation to the
co-ordinator. 5 Clients use the application programmer interface defined by
directory system to communicate with the directory servers.
Co-ordinator
Btatus Participant Directory access protocols :
step status step 1. Directory access protocol is a protocol that allows to access directory
prepared to comnit canCommit? information through program.
access control.
(waiting for votes) prepared to 2 Directory access protocols also define a data model and
Yes commit web browsers can store personal bookmarks and other
3. For instance, user can thus access the
(uncertain) browser settings in a directory system. A
doCommit homne and at work,
eommitted
done committed
same settings from multiple locations,
without having to share a file systemn.
such as at
have Committed 4

Pig. 4.2a.2.
1
Moss
coneurreney Communi estion in two phnse comnit protocol.
control
control protocol
Moss
on the eoneurreney protocol for nested transactions is based
concept of upward
inheritance of locks.

You might also like