Professional Documents
Culture Documents
Relational Database Design: Dbms:Databasemanagement System
Relational Database Design: Dbms:Databasemanagement System
DBMS:DatabaseManagement System
Design Design
DBMS (3130703)
Prof. Krishna
Suchak
• Functional Dependency
• Closure of FD
Department of CE/IT
• Closure of Attribute
• Extraneous Attributes
• Canonical Cover Unit no : 4
• Finding a Candidate Key Relational Database
Design
• Decomposition DBMS (3130703)
• Database Anomalies
• Normal Forms / Normalization
Student
RollNo Name SPI BL
201 Joe 8 1
202 Sam 6 3
It is denoted by M → N
For e.g. we can find the result if we have only Enrollment Number. Thus,
{Enrollment} → Result is a partial dependency.
Types of Functional Dependencies
3. Transitive Functional Dependency
In a relation, if attribute A → B and B → C, then C is transitively depends on
A.
1. Reflexivity 5. Self-determination
If B is a subset of A A→A
then A → B
Closure Set : 6. Decomposition
Armstrong’s 2. Augmentation
If A → B
If A → BC
then A → B
Axioms then AC → BC and A → C
(Inference
3. Transitivity 7. Union
Rules) If A → B and B → C If A → B and A → C
then A → C then A → BC
Attributes 1. Add the attributes contained in the attribute set for which
closure is being calculated to the result set.
A+ = { A }
={A,B,C} ( Using A → BC )
Closure Set
Attributes ={A,B,C,D,E} ( Using BC → DE )
={A,B,C,D,E,F} ( Using D → F )
= { A , B , C , D , E , F , G } ( Using CF → G )
Thus,
A+ = { A , B , C , D , E , F , G }
Consider a relation R (A,B,C,D,E,F,G) with following functional
dependencies: A → BC, BC → DE, D → F, CF → G. Find {B,C}+
Closure of attribute {B,C} -
{ B , C } += { B , C }
={B,C,D,E} ( Using BC → DE )
Closure Set
Attributes ={B,C,D,E,F} ( Using D → F )
= { B , C , D , E , F , G } ( Using CF → G )
Thus,
{ B , C }+ = { B , C , D , E , F , G }
Consider a relation R (A,B,C,D,E,F,G) with following functional
dependencies: A → BC, BC → DE, D → F, CF → G. Find D+
Closure of attribute D -
{ D}+= { D}
Find closure of A.
Find closure of CD
Find Closure of B
Find Closure of BC
Closure Set Find closure of E
Attributes
ANSWER: A+ = ABCDE
CD+ = ABCDE
B+ = BD
BC+ = ABCDE
E+ = ABCDE
Let us consider a relation R with schema R = (A, B, C) and set of
functional dependencies F = { AB → C, A → C }.
It is denoted by Fc.
A → DE A B C D E F G H
AB → C A B C D E F G H
B→F A B C D E F G H F → GH A B C D E F G H
Finding a Find out all the attributes which do not have incoming edge(arrow).
Candidate
Key A B C D E F G H From this, A and B are the attributes with no
incoming edge.
Now, check whether A & B together can identify all other attributes of
R. For this, find (AB)+ i.e. Find Closure of AB
(AB)+ = {A,B,C,D,E,F,G,H} = R
Thus, AB finds the complete Relation R and hence, AB is a candidate
key.
Consider a relation R (A,B,C,D,E) with following functional dependencies:
BC → ADE, D → B. Find Candidate Key
BC → ADE A B C D E D→B A B C D E
Find out all the attributes which do not have incoming edge(arrow).
A B C D E
(AC)+ = {A,C} ≠ R
(BC)+ = {A,B,C,D,E} = R
Finding a
(CD)+ = {A,B,C,D,E} = R
Candidate
Key (CE)+ = {C,E} ≠ R
(CAE)+ = {C,A,E} ≠ R
Lossy
Decomposition AcNo Bal Bal Branch
001 50000 Not Same 50000 Rajkot
002 50000 50000 Baroda
Lossless
Decomposition AcNo Bal AcNo Branch
001 50000 Same 001 Rajkot
002 50000 002 Baroda
As E_No is Primary Key, it will not allow to enter NULL for it.
Ultimately, A user will not be able to insert a new record for only
department details.
Delete anomaly occurs when deleting certain attribute
values may result in loss of other attribute values.
E_No Ename Address D_No Dname Dmgr_Id
1 Sagar Rajkot 1 Sales 1
3 Aakash Surat 2 Accounts 2
Consider Employee relation with E_No as a primary key and is referring D_No of
Department table, where D_No is also a Primary Key
Delete Assume that there is only one employee who works in Accounts
Anomaly department and a user wish to delete that record (A Row with
E_No = 2).
Update Consider Employee relation with E_No as a primary key and is referring D_No of
Department table, where D_No is also a Primary Key
Anomaly Assume that the manager of the Sales department is changed.
Hence, we need to update Dmgr_Id of all the employees working
in Sales department.
Since a teacher can teach more than one subjects, the table can
have multiple rows for a same teacher.
Here, Candidate Keys are: {teacher_id,subject} and non-prime
attributes are: {teacher_age}
A table is in 1NF as all attributes has single values.
A table is not in 2NF as teacher_age is fully dependent on
teacher_id and teacher_id is a proper subset of Candidate Key.
This rule gets violated: No non-prime attribute is dependent on
the proper subset of any candidate key of table.
The solution for this would be splitting it into more than one
table such that it satisfy both the conditions.
Here, {state, city, district} are Non-Prime attributes and are functionally
dependent on Super Key {id}. Hence it violates rule of 3NF
The solution for this would be splitting it into more than
one table such that transitive dependency is removed
Employee_Details
id name zip
1001 John 282005
1002 Ajeet 222008
1006 Lora 282007
Employee_Address
zip state city district
282005 UP Agra Dayal Bagh
222008 TN Chennai M-City
282007 TN Chennai Urrapakkam
292008 UK Pauri Bhagwan
222999 MP Gwalior Ratan
A relation is said to be in BCNF if It is in 3NF and every
determinant should be primary key.
BCNF is based on the concept of a determinant.
In the above relation, one student may get more than one
assignments with different faculties.
Normal Forms Id
1
Subject
DBMS
Project
P1
(4NF) 1 ETC P1
1 DBMS P2
1 ETC P2
Normal Forms
(4NF) Id Address Id Subject Id Project
1 Amin Marg 1 DBMS 1 P1
1 Amin Marg 1 ETC 1 P1
1 Amin Marg 1 DBMS 1 P2
1 Amin Marg 1 ETC 1 P2
A relation is in 5NF if it is in 4NF and not contains any join
dependency and joining should be lossless.
5NF is satisfied when all the tables are broken into as many
tables as possible in order to avoid redundancy.
5NF is also known as Project-join normal form (PJ/NF).
SUBJECT LECTURER SEMESTER
Computer Anshika Semester 1
Normal Forms
Math Joe
Semester 1 Chemistry
Math Akash
(5NF) Semester 2 Math Chemistry Praveen
R3
SEMSTER LECTURER
Semester 1 Anshika
Semester 1 Joe
Semester 1 Joe
Semester 2 Akash
Semester 1 Praveen
A database is never normalized to 5th NF.