DBMS Unit 3 Part 2
DBMS Unit 3 Part 2
DBMS Unit 3 Part 2
• Lossless Decomposition:
• 1)If the information is not lost from the relation that is decomposed,
• then the decomposition will be lossless.
• 2)The lossless decomposition guarantees that the join of relations
• will result in the same relation as it was decomposed.
• 3)The relation is said to be lossless decomposition
• if natural joins of all the decomposition give the original relation.
•
EMPLOYEE_DEPARTMENT table:
•
EMP_ID EMP_NAME EMP_AGE EMP_CITY DEPT_ID DEPT_NAME
• 22 Denim 28 Mumbai 827 Sales
• 33 Alina 25 Delhi 438 Marketing
• 46 Stephan 30 Bangalore 869 Finance
• 52 Katherine 36 Mumbai 575 Production
• 60 Jack 40 Noida 678 Testing
•
Lossless Decomposition:
The above relation is decomposed into two relations EMPLOYEE and DEPARTMENT
•1) EMPLOYEE table:
•
EMP_ID EMP_NAME EMP_AGE EMP_CITY
•22 Denim 28 Mumbai
•33 Alina 25 Delhi
•46 Stephan 30 Bangalore
•52 Katherine 36 Mumbai
•60 Jack 40 Noida
•
2) DEPARTMENT table
•
DEPT_ID EMP_ID DEPT_NAME
•827 22 Sales
•438 33 Marketing
•869 46 Finance
•575 52 Production
•678 60 Testing
•
Lossless Decomposition:
• Now, when these two relations are joined on the common column "EMP_ID", then
the resultant relation will look like:
•
Employee ⋈ Department
•
EMP_ID EMP_NAME EMP_AGE EMP_CITY DEPT_ID DEPT_NAME
• 22 Denim 28 Mumbai 827 Sales
• 33 Alina 25 Delhi 438 Marketing
• 46 Stephan 30 Bangalore 869 Finance
• 52 Katherine 36 Mumbai 575 Production
• 60 Jack 40 Noida 678 Testing
•
Hence, the decomposition is Lossless join decomposition.
•
Dependency Preserving:
•
2)Dependency Preserving:
•
1)It is an important constraint of the database.
• 2)In the dependency preservation, at least one decomposed table must satisfy every dependency.
• 3)If a relation R is decomposed into relation R1 and R2
• then the dependencies of R either must be a part of R1 or R2
• or must be derivable from the combination of functional dependencies of R1 and R2.
• 4)For example, suppose there is a relation R (A, B, C, D)
• with functional dependency set (A->BC)
• The relational R is decomposed into into R1(ABC) and R2(AD)
• which is dependency preserving because FD A->BC is a part of relation R1(ABC).
•
2) R (A, B, C, D,E)
• FD (A->BC)
•
i) R1:ADE R2:ABC
• Ii) R1:ABC R2:AD R3:AE
•
Normalization
14 John 7272826385, UP
9064738238
14 John 7272826385 UP
14 John 9064738238 UP
Example: Consider a table with two columns Employee_Id and Employee_Name.
{Employee_id, Employee_Name} → Employee_Id is a trivial functional depende
ncy as Employee_Id is a subset of {Employee_Id, Employee_Name}.
Also, Employee_Id → Employee_Id and
Employee_Name → Employee_Name are trivial dependencies too
Types of Functional dependency
TEACHER_ID TEACHER_AGE
25 30
47 35
83 38
TEACHER_SUBJECT table:
TEACHER_ID SUBJECT
25 Chemistry
25 Biology
47 English
83 Math
83 Computer
Third Normal Form (3NF)
A relation will be in 3NF if it is in 2NF and if it doesn’t
contain any transitive dependency(non-prime attribute
should not determine non-prime attribute)
3NF is used to reduce the data duplication. It is also used to
achieve the data integrity.
EMPLOYEE_DETAIL table:
EMPLOYEE_ZIP table:
EMPLOYEE table:
EMP_COUNTRY table:
EMP_ID EMP_COUNTRY
264 India
364 UK
STUDENT_COURS STUDENT_HOBBY
E
STU_ID COURSE STU_ID HOBBY
21 Computer 21 Dancing
21 Math 21 Singing
34 Chemistry 34 Dancing
74 Biology 74 Cricket
59 Physics 59 Hockey
Fifth normal form (5NF)
• A relation is in 5NF, if it is in 4NF and doesn’t not contain 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
Computer John Semester 1
Math John Semester 1
Math Akash Semester 2
Chemistry Praveen Semester 1
• In the above table, John takes both Computer and Math class for Semester 1 but he doesn't take
Math class for Semester 2. In this case, combination of all these fields required to identify a valid
data.
• Suppose we add a new Semester as Semester 3 but do not know about the subject and who will be
taking that subject so we leave Lecturer and Subject as NULL. But all three columns together acts
as a primary key, so we can't leave other two columns blank.
Fifth normal form (5NF)
• So to make the above table into 5NF, we can decompose it into
three relations P1, P2 & P3:
P2 SUBJECT LECTURER
P1 SEMESTER SUBJECT
Computer Anshika
Semester 1 Computer
Computer John
Semester 1 Math
Math John
Semester 1 Chemistry
Math Akash
Semester 2 Math
Chemistry Praveen
SEMSTER LECTURER
P3 Semester 1 Anshika
Semester 1 John
Semester 1 John
Semester 2 Akash
Semester 1 Praveen
Thank you