0% found this document useful (0 votes)
23 views

Unit 3

Uploaded by

wolf1904
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Unit 3

Uploaded by

wolf1904
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 162

Anubhav Sharma A.P.

(CSE)

DATABASE MANAGEMENT
SYSTEM
UNIT 3

- ANUBHAV SHARMA
Asst. Professor
CSE Department
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)

▶ Normalization is a database design technique


which organizes tables in a manner that
reduces redundancy and dependency of data.

▶ It divides larger tables to smaller tables and


links them using relationships.
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)

▶ During modification if any of the row missed


out if any of the data would not get updated
▶ It will lead to inconsistent data hence data

redundancy also leads to inconsistency in


data, as a result of updation anomaly.
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)

▶ Functional dependency
▶ Fully functional dependency

▶ Partial dependency

▶ Transitive dependency

▶ Multi-valued dependency

▶ Trivial functional dependency

▶ Non-Trivial functional dependency


Anubhav Sharma A.P.(CSE)

▶ Lossydecomposition
▶ Non-Lossy decomposition(Lossless)
Anubhav Sharma A.P.(CSE)

▶ In simple words Normalization is a systematic way of


ensuring that a database structure is suitable for general-
purpose querying and free of certain undesirable
characteristics—insertion, update, and deletion anomalies—
that could lead to a loss of data integrity.
▶ the goal of data normalization is to reduce data redundancy,
an important consideration for application developers
because it is incredibly difficult to stores objects in a
relational database that maintains the same information in
several places.
Anubhav Sharma A.P.(CSE)

▶ Database normalization is the process of


restructuring a relational database in
accordance with a series of so-called
normal forms in order to reduce data
redundancy and improve data integrity.
Anubhav Sharma A.P.(CSE)

▶ Normalizationis conceptually cleaner and


easier to maintain and change as your needs
change.
Anubhav Sharma A.P.(CSE)

Functional
Dependency
A functional dependency A->B in a relation holds if two tuples
having same value of attribute A also have same value for
attribute B.
For Example, in relation STUDENT shown in table 1:

STUD_NO->STUD_NAME, STUD_NO->STUD_PHONE hold


STUD_NAME->STUD_STATE do not hold
Anubhav Sharma A.P.(CSE)

How to find functional dependencies for a


relation?
Consider the STUDENT relation given in Table 1.

 We know that STUD_NO is unique for each student. So


STUD_NO->STUD_NAME, STUD_NO->STUD_PHONE,
STUD_NO->STUD_STATE, STUD_NO->STUD_COUNTRY and
STUD_NO -> STUD_AGE all will be true.

 Similarly, STUD_STATE->STUD_COUNTRY will be true as if


two records have same STUD_STATE, they will have same
STUD_COUNTRY as well.

 For relation STUDENT_COURSE, COURSE_NO-


>COURSE_NAME will be true as two records with same
COURSE_NO will have same COURSE_NAME.
Anubhav Sharma A.P.(CSE)

Functional Dependency Set

Functional Dependency set or FD set of a relation is the set of


all FDs present in the relation. For Example, FD set for relation
STUDENT shown in table 1 is:

{ STUD_NO->STUD_NAME, STUD_NO->STUD_PHONE,
STUD_NO->STUD_STATE, STUD_NO->STUD_COUNTRY,
STUD_NO -> STUD_AGE, STUD_STATE->STUD_COUNTRY }

Attribute Closure: Attribute closure of an attribute set can be


defined as set of attributes which can be functionally
determined from it.
Anubhav Sharma A.P.(CSE)

How to find attribute closure of an attribute


set?
To find attribute closure of an attribute set:

•Add elements of attribute set to the result set.


•Recursively add elements to the result set which can be functionally
determined from the elements of the result set.

Using FD set of table 1, attribute closure can be determined as:

(STUD_NO)+ = {STUD_NO, STUD_NAME, STUD_PHONE,


STUD_STATE, STUD_COUNTRY, STUD_AGE}

(STUD_STATE)+ = {STUD_STATE, STUD_COUNTRY}


Anubhav Sharma A.P.(CSE)
Armstrong’s axioms/properties of functional dependencies:

1.Reflexivity: If Y is a subset of X, then X→Y holds by reflexivity rule


Example, {roll_no, name} → name is valid.

2.Augmentation: If X → Y is a valid dependency, then XZ → YZ is also


valid by the augmentation rule.
Example, {roll_no, name} → dept_building is valid,
hence {roll_no, name, dept_name} → {dept_building, dept_name} is
also valid.

3.Transitivity: If X → Y and Y → Z are both valid dependencies, then


X→Z is also valid by the Transitivity rule.
Example, roll_no → dept_name & dept_name → dept_building, then
roll_no → dept_building is also valid.
Anubhav Sharma A.P.(CSE)

Types of Functional dependencies in


DBMS
1.Trivial functional dependency

2.Non-Trivial functional dependency

3.Multivalued functional dependency

4.Transitive functional dependency

5.Fully functional dependency

6.Partial functional dependency


Anubhav Sharma A.P.(CSE)

1. Trivial Functional Dependency


In Trivial Functional Dependency, a dependent is always a subset
of the determinant. i.e. If X → Y and Y is the subset of X, then it is
called trivial functional dependency
roll_no name age

42 abc 17

43 pqr 18

44 xyz 18

Here, {roll_no, name} → name is a trivial functional dependency,


since the dependent name is a subset of determinant set {roll_no,
name}.
Anubhav Sharma A.P.(CSE)

2. Non-trivial Functional Dependency

In Non-trivial functional dependency, the dependent is strictly not


a subset of the determinant. i.e. If X → Y and Y is not a subset of X,
then it is called Non-trivial functional dependency.

Here, roll_no → name is a non-trivial functional dependency, since


the dependent name is not a subset
of determinant roll_no. Similarly, {roll_no, name} → age is also a
non-trivial functional dependency, since age is not a subset of
{roll_no, name}
Anubhav Sharma A.P.(CSE)

3. Multivalued Functional Dependency

In Multivalued functional dependency, entities of the dependent


set are not dependent on each other.

i.e. If a → {b, c} and there exists no functional


dependency between b and c, then it is called a multivalued
functional dependency.

Here, roll_no → {name, age} is a multivalued functional


dependency, since the dependents name & age are not
dependent on each other(i.e. name → age or age → name doesn’t
exist !)
Anubhav Sharma A.P.(CSE)

4. Transitive Functional Dependency


In transitive functional dependency, dependent is indirectly
dependent on determinant. i.e. If a → b & b → c, then according to
axiom of transitivity, a → c. This is a transitive functional
dependency.

For example , enrol_no → dept and dept → building_no. Hence,


according to the axiom of transitivity, enrol_no → building_no is a
valid functional dependency.
Anubhav Sharma A.P.(CSE)

5. Fully Functional Dependency


In full functional dependency an attribute or a set of attributes
uniquely determines another attribute or set of attributes. If a
relation R has attributes X, Y, Z with the dependencies X->Y and X-
>Z which states that those dependencies are fully functional.

6. Partial Functional Dependency


In partial functional dependency a non key attribute depends on a
part of the composite key, rather than the whole key. If a relation R
has attributes X, Y, Z where X and Y are the composite key and Z is
non key attribute. Then X->Z is a partial functional dependency in
RBDMS.
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)

▶ ALL other attributes depends upon student_id


or subject_id except total_marks,total_marks
depends upon exam_name which is not a part
of primary key.
▶ When there is an attribute in a table which

depends on some non-prime attribute and


not on prime attribute ,which is termed as
Transitive dependency.
▶ AS total_marks depends upon exam_name

which is a non-prime attribute.


Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)

▶ How to make the table satisfy BCNF?


Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)

▶ Not used practically.


▶ A relation is in 5 NF if it is in 4NF and not having

any join dependency and joining is lossless.


▶ Join dependency exists if we decompose a

relation R into R1, R2--- Rn and later on if we try


to join R1, R2---Rn back in any order, we will not
be able to get the exact R relation.
▶ Lossless means there should be no loss of tuples
and there should be no extra tuples also.
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)
Anubhav Sharma A.P.(CSE)

End of Unit 3

You might also like