You are on page 1of 16

DATABASE

MANAGEMENT
SYSTEM
(DBMS)

UNIT-III
SYLLABUS: UNIT-III

 Relational Database Design:


Functional Dependency, Different anomalies in designing
a Database, Normalization using functional dependencies,
Decomposition, Boyce-Codd Normal Form, 3NF,
Normalization using multi-valued dependencies, 4NF,
5NF.

 Internals of RDBMS:
Physical data structures, Query optimization: join
algorithm, statistics and cost base optimization.
Transaction processing, Concurrency control and
Recovery Management: transaction model properties, 2
state serializability, lock base protocols, two phase
locking.
FUNCTIONAL DEPENDENCY
 The functional dependency is a relationship that exists
between two attributes.

 One attribute determines the value of another attribute.

 It typically exists between the primary key and non-key


attribute within a table.

 It is denoted as X → Y where,
 Y is functionally dependent on X
 X is called Determinant set (attribute set on the left side of the
arrow) 3
 Y is called the Dependent attribute.
TYPES OF FUNCTIONAL
DEPENDENCY

4
TRIVIAL FUNCTIONAL DEPENDENCY
 A dependent is always a subset of the determinant.

 A functional dependency is called trivial if the attributes on the right side


are the subset of the attributes on the left side of the functional dependency.

 X → Y is called a trivial functional dependency if Y is the subset of X.

 E.g.
 { Employee_Id, Name } → { Name } is a Trivial functional dependency, since
the dependent Name is the subset of determinant { Employee_Id, Name }.
 { Employee_Id } → { Employee_Id }, { Name } → { Name } and { Age } →
{ Age } are also Trivial Dependencies.

5
NON-TRIVIAL DEPENDENCY
 In Non-Trivial functional dependency, dependent is not a subset of the determinant.

 X → Y is called a Non-trivial functional dependency if Y is not a subset of X.

 A functional dependency X → Y where


 X is a set of attributes
 Y is also a set of the attribute but not a subset of X,
 Then it is called Non-trivial functional dependency.

 E.g.
 {Employee_Id} → {Name} is a non-trivial functional dependency because Name(dependent)
is not a subset of Employee_Id(determinant).

 {Employee_Id, Name} → {Age} is also a non-trivial functional dependency.

6
TRANSITIVE DEPENDENCY
 Consider two functional dependencies,
 A → B and B → C
 According to the transitivity axiom, A → C must also exist.

 This is called a transitive functional dependency.

 A dependent is indirectly dependent on determinant in Transitive functional


dependency.

 Consider the table given below:


 {Employee_Id → Department} and {Department → Street Number} holds true.
 According to the axiom of transitivity, { Employee_Id → Street Number } is also a
valid functional dependency.

7
MULTIVALUED DEPENDENCY
 Attributes in the dependent set are not dependent on each
other.
X → { Y, Z }, if there exists is no functional
dependency between Y and Z, then it is called as Multivalued
functional dependency.
 E.g.
 {Employee_Id} → {Name, Age} is a Multivalued functional
dependency
 The dependent attributes Name, Age are not functionally
dependent

8
PROPERTIES OF FUNCTIONAL
DEPENDENCY
 Certain properties related to functional dependency are called RAT rules:

 Reflexivity
 If A is a set of attributes and B is a subset of A, then the functional dependency A→B holds true.
 E.g. {Employee_Id, Name} → Name is valid

 Augmentation
 If a functional dependency A → B holds true, then appending any number of the attribute to both
sides of dependency doesn't affect the dependency. It remains true.
 E.g.
 If X → Y holds true then,
ZX → ZY also holds true.

 If {Employee_Id, Name} → {Name} holds true then,


{Employee_Id, Name, Age} → {Name, Age} also holds true.

 Transitivity
 If two functional dependencies X → Y and Y → Z hold true, then
X → Z also holds true
 E.g. 9
 if {Employee_Id} → {Name} holds true and {Name} → {Department} holds true, then
{Employee_Id} → {Department} also holds true.
INFERENCE RULES
 Using Inference rules, we can derive additional functional dependency
from the initial set.

 The Functional dependency has 6 types of Inference rules:

Reflexive Rule

Augmentation Rule

Transitive Rule
Inference Rules
Union Rule

Decomposition Rule

Pseudo transitive Rule 10


INFERENCE RULES
 Reflexive Rule (IR1)
 if Y is a subset of X, then X determines Y.
 If X ⊇ Y then X → Y
 E.g.
 X = {a, b, c, d, e}
Y = {a, b, c}

 Augmentation Rule (IR2)


 The augmentation is also called as a partial dependency.
 if X determines Y, then XZ determines YZ for any Z.
 If X → Y then XZ → YZ
 Example:
 For R(ABCD), if A → B then AC → BC

 Transitive Rule (IR3)


 In the transitive rule, if X determines Y and Y determine Z, then X must also 11
determine Z.
 If X → Y and Y → Z then X → Z
 Union Rule (IR4)
 if X determines Y and X determines Z, then X must also determine Y and Z.
 If X → Y and X → Z then X → YZ
 Proof:
 X → Y (given)
X → Z (given)
X → XY (using IR2 on 1 by augmentation with X. Where XX = X)
XY → YZ (using IR2 on 2 by augmentation with Y)
X → YZ (using IR3 on 3 and 4)

 Decomposition Rule (IR5)


 Decomposition rule is also known as project rule.
 It is the reverse of union rule.
 if X determines Y and Z, then X determines Y and X determines Z separately.
 If X → YZ then X → Y and X → Z

 Proof:
 X → YZ (given)
YZ → Y (using IR1 Rule)
X → Y (using IR3 on 1 and 2)

 Pseudo transitive Rule (IR6)


 In Pseudo transitive Rule, if X determines Y and YZ determines W, then XZ determines W.
 If X → Y and YZ → W then XZ → W

12
Proof:
 X → Y (given)
 WY → Z (given)
 WX → WY (using IR2 on 1 by augmenting with W)
ANOMALIES IN DATABASE DESIGN
 Anomaly means the inconsistency occurred in the relational table during
the operations performed on the relational table.

 These anomalies can lead to data integrity issues and make it difficult to
retrieve and manipulate data efficiently.

 There can be various reasons for anomalies to occur in the database such
as:
 If there is a lot of redundant data present in our database.
 If a table is constructed in a very poor manner then there is a chance of
database anomaly.
 All the data is stored in a single table.

 These anomalies can be categorized into three types:


 Insertion Anomalies 13
 Deletion Anomalies
 Update Anomalies
ANOMALIES
 Updation / Update Anomaly
 When we update some rows in the table, and if it leads to the
inconsistency of the table then updation anomaly occurs.
 E.g.
 if we want to update the address of Ramesh then we will have to update all
the rows where Ramesh is present.
 If during the update we miss any single row, then there will be two
addresses of Ramesh, which will lead to inconsistent and wrong databases.

 Insertion Anomaly
 If there is a new row inserted in the table and it creates the
inconsistency in the table then it is called the insertion anomaly.
 E.g.
 if we create a new row of a worker, and if it is not allocated to any
department then we cannot insert it in the table 14
 it will create an insertion anomaly.
ANOMALIES
 Deletion Anomaly
 If we delete some rows from the table and if any other information or
data which is required is also deleted from the database, this is called
the deletion anomaly in the database.
 E.g.
 if we want to delete the department number ECT669 then the details of
Rajesh will also be deleted since Rajesh's details are dependent on the row
of ECT669.
 So, there will be deletion anomalies in the table.

15
16

You might also like