DBMS Unit-3
DBMS Unit-3
DBMS Unit-3
Greater Noida
Unit: 3
The main aim of a DBMS is to supply a way to store up and retrieve database information that
is both convenient and efficient. By data, we mean known facts that can be recorded and that
have embedded meaning. Usually, people use software such as DBASE IV or V, Microsoft
ACCESS, or EXCEL to store data in the form of a database. A datum is a unit of data.
Meaningful data combined to form information. Hence, information is interpreted data - data
provided with semantics. MS. ACCESS is one of the most common examples of database
management software.
Contd..
Contd..
PEO1: Able to apply sound knowledge in the field of information technology to fulfill the
needs of IT industry.
PEO2: Able to design innovative and interdisciplinary systems through latest digital
technologies.
PEO3: Able to inculcate professional ethics, team work and leadership for serving the
society.
PEO4: Able to inculcate lifelong learning in the field of computing for successful career
in organizations and R&D sectors.
PO1 PO1
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO11
0 2
.1
2 2 3 3 3 2 3 2 2 2 2 3
.2
3 3 3 2 2 2 2 2 2 2 2 3
.3
2 3 3 3 3 2 2 2 2 2 2 2
.4
2 3 2 2 2 2 2 2 2 3 2 2
.5
2 3 2 2 2 3 2 2 3 2 2 2
AVG
2.20 2.80 2.60 2.40 2.40 2.20 2.20 2.00 2.20 2.20 2.00 2.40
.1
3 1 3 1
.2
3 1 3 1
.3
3 1 3 1
.4
3 1 3 1
.5
3 1 3 1
AVG
3.00 1.00 3.00 1.00
.1
3 1 3 1
.2
3 1 3 1
.3
3 1 3 1
.4
3 1 3 1
.5
3 1 3 1
AVG
3.00 1.00 3.00 1.00
Book References:
1. Korth, Silbertz, Sudarshan,” Database Concepts”, McGraw Hill
2. Date C J, “An Introduction to Database Systems”, Addision
Wesley
3. Elmasri, Navathe, “ Fundamentals of Database Systems”,
Addision Wesley
4.Bipin C. Desai, “ An Introduction to Database Systems”, Galgotia
Publications
• Recap
In last unit we studied about
• Relational Data Model
– Relational Algebra Query
– Relational Calculus Query
• Structured Query Language
Manu Sharma DBMS
09/24/22 24
Unit-3
Content
Unit-3
•Functional Dependencies
•Normal forms
– 1NF
– 2NF
– 3NF
– BCNF
•Loss less join decompositions
•Multivalued dependencies
•Join dependencies
• Student Table:
StudReg. CourseID StudName Address Course
205 6204 James Los Angeles Economics
205 6247 James Los Angeles Economics
224 6247 TrentBolt New York Mathematics
230 6204 Ritchie Rich Egypt Computer
230 6208 Ritchie Rich Egypt Accounts
There are two students in the above table, 'James' and 'Ritchie Rich', whose
records are repetitive when we enter a new CourseID. Hence it repeats the
studRegistration, StudName and address attributes.
– Insertion anomalies
– Deletion anomalies
– Modification anomalies
1. What do you mean by BCNF ? Why it is used and how it differ from
3 NF ? CO3
Functional dependency
Types of Functional dependency
Emp_id Emp_name
For example:
AS555 Harry
AS811 George
AS999 Kevin
{Emp_id, Emp_name} -> Emp_id is a trivial functional
dependency as Emp_id is a subset of {Emp_id,Emp_name}.
Functional dependency
Types of Functional dependency
Inference rules
There are three other inference rules that follow from IR1,
IR2 and IR3.
They are as follows:
4. IR4 (decomposition, or projective, rule): {X → YZ} |=X →
Y,
X →Z
5. IR5 (union, or additive, rule): {X → Y, X → Z} |=X → YZ.
6 . IR6 (pseudotransitive rule): {X → Y, WY → Z} |=WX → Z.
1. {WY,XZ} |= {WXY}
1. {WY,XZ} |= {WXY}
2. {XY,XW,WYZ} |= {XZ}
3. {XY} |= {XYZ}
4. {XY, Z Y} |= {XZY}
Note:-
Armstrong axioms are complete. As for a given set
F of functional dependencies, all FD implied by F
can be inferred by using rules IR1 through IR3.
Inference rules
Question 1:-
To compute the closure for relation schema R
={A,B,C,G,H,I} and F= {A → B,A → C,CG → H, CG →
I,B → H,C → G).
Find the closure of A under F . Or {A+ =}
Question 2:-
To compute the closure for relation schema R
={A,B,C,D,E} and F= {A → BC,CD → E,B → D, E → A}.
Find the closure of A and CD under F . or {A+ =} and
{ CD + =}
Formally say ,
• Let R is the relation and X is the set of attribute over
R.
• If X+ determines all the attributes of R, then X is said
to be super key, or candidate key of R.
• To find the candidate key first find all the super key of
a relation. (because the candidate key is a minimal
set of super key).
Question 1-
To find the Keys of relation R={A,B,C,D,E} with
FD’s F={A →BC,CD →E,E → A,B → D}.
Question 2-
To find the Keys of relation R={A,B,C,D,E,H} with
FD’s F={A →BC,CD →E,E → C,C → AEH,AH →D,DH →
BC}.
Equivalence set of FD
Minimal cover, Canonical cover of FD
Definition.
A set of functional dependencies F is said to cover
another set of functional dependencies E if every
FD in E is also in F+; that is, if every dependency
in E can be inferred from F; alternatively, we can
say that E is covered by F.
Means,
Two sets of FDs F and E are equivalent if:
- every FD in F can be inferred from E, and
- every FD in E can be inferred from F
• Hence, F and E are equivalent if F + = E +
• F and E are equivalent if F covers E and E covers F
a) P is a subset of Q
b) Q is a subset of P
c) P = Q
d) P ≠ Q
Question 1:-
Let us consider a relation schema R ={A,B,C,D,E} having
two functional dependency(FD) set E and F,
E= {A → B, AB → C, D → AC, D → E} and
F = {A → BC, D → AE}
Check wheteher two set are equivalent or not.
Question 2:-
Let us consider a relation schema R ={A,B,C,D,E,H}
having two functional dependency(FD) set F and G,
F = {A → C, AC → D, E → AD, E → H}
G = {A → CD, E → AH}
Check wheteher two set are equivalent or not.
09/24/22 Manu Sharma DBMS Unit-3 88
Minimal cover, Canonical
cover of FD
Question 1:-
Given a relation schema R = {A,B,C,D,E,F}and a set
of functional dependencies F= {AB → C, C → AB,
B → C, ABC → AC, A→ C, AC → B }
To find the minimal cover for above given FD’s.
Sol.
Step 1: { AB → C, C → A, C → B, B → C, ABC→ A, ABC
→ C, A → C, AC → B }
Step 2: { B → C, C → A, C → B, B → C, A → C, A → B}
Step 3: {C → A, B → C, A → B }
Question 1:-
Given a relation schema R = {A,B,C,D,E,F}and a set
of functional dependencies F= {AB → C, C → A, BC
→ D, ACD → B, BE → C, EC → FA,CF → BD, D → E }
To find the minimal cover for above given FD’s.
Question 2:-
Given a relation schema R = {A,B,C,D,E}and a set of
functional dependencies F= {A → BC, CD → E,B →
D, E → A }
To find the minimal cover for above given FD’s.
Equivalence set of FD
Minimal cover, Canonical cover of FD
Or
I.Minimizing redundancy
II.Eliminates the anomalies(for insuring the integrity
and consistency of the data).
III.Ensuring data dependencies make sense i.e. data
is logically stored (all prime attribute in a relation )
IV.Dependent on the primary key (Normalization
generally involving splitting existing table into
multiple ones).
Normal form
Types of Normalization
1. First Normal Form(1NF)
2. Second Normal Form (2NF)
3. Third Normal Form (3NF)
4. BCNF (Boyce Codd Normal Form)
5. Fourth normal Form (4NF)
6. Fifth Normal form (5NF)
• 14 John 9064738238 UP
• 20 Harry 8574783832
Bihar
• 12 Sam 7390372389
Punjab
• 12 Sam 8589830302
Punjab
09/24/22 Manu Sharma DBMS Unit-3 105
Normalization nested relations
into 1NF(CO3)
1. Let us Consider following relation Schema EMP_PROJ.
FD set:
{STUD_NO -> STUD_NAME, STUD_NO -> STUD_STATE, STUD_STATE -
> STUD_COUNTRY, STUD_NO -> STUD_AGE}
Candidate Key:
{STUD_NO}
For this relation in table 4, STUD_NO -> STUD_STATE and STUD_STATE -
> STUD_COUNTRY are true. So STUD_COUNTRY is transitively
dependent on STUD_NO.
It violates the third normal form. To convert it in third normal form, we will
decompose the relation STUDENT (STUD_NO, STUD_NAME,
STUD_STATE, STUD_COUNTRY_STUD_AGE) as:
STUDENT (STUD_NO, STUD_NAME, STUD_STATE, STUD_AGE)
STATE_COUNTRY (STUD_STATE, STUD_COUNTRY)
problem
Multivalued dependencies (MVDs) express a
condition among tuples of a relation that exists
when the relation is trying to represent more than
one to many or many to many relationship.
09/24/22 Manu Sharma DBMS Unit-3 129
Formal Definition of Multivalued
Dependency(CO3)
A multivalued dependency X →→ Y specified on
relation schema R, where X and Y are both subsets of
R, specifies the following constraint on any relation
state r of R:
If two tuples t1 and t2 exist in r such that t1[X] =
t2[X], then two tuples t3 and t4 should also exist in r
with the following properties,
t1[X] = t2[X] = t3[X] = t4[X]
t1[Y] = t3[Y] and t2[Y] = t4[Y]
t1[Z] = t4[Z] and t3[Z] = t2[Z]
Key:- {s_id,course,hobby}
MVD, s_id →→ course,hobby
To check relation is in 4NF or not.
09/24/22 Manu Sharma DBMS Unit-3 131
Example
As you can see in the above table , student with s_id 1 has
opted for two courses, Science and Maths, and has two
hobbies, Cricket and Hockey.
You must be thinking what problem this can lead to, right?
Problem:- Well the two records for student with s_id 1& 2,
will give rise to two more records, because for one student,
two hobbies exists, hence along with both the courses,
these hobbies should be specified.
ABC Scew
CDE Bolt
ABC Bolt
Lecture 8:-
Decomposition of relation Schema
Properties of decomposition
• For any pincode, there is only one city and state. Also,
for given street, city and state, there is just one
pincode. In normalization terms, empdt1 is a relation
in
a) 1 NF only
b) 2 NF and hence also in 1 NF
c) 3NF and hence also in 2NF and 1NF
d) BCNF and hence also in 3NF, 2NF and 1NF
• http://www.aktuonline.com/papers/btech-cs-5-sem-
data-base-management-system-rcs501-2020.pdf
• http://www.aktuonline.com/papers/btech-cs-5-sem-
database-management-system-KCS501-2018-19.pdf
• http://www.aktuonline.com/papers/btech-cs-5-sem-
database-management-system-ncs-502-2017-18.pdf
• http://www.aktuonline.com/papers/btech-cs-5-sem-
database-management-system-ncs-502-2016-17.pdf