Fourth Normal Form (4NF) Fourth Normal Form (4NF) A relation (table) is said to in 4NF: If it is in BCNF. There must be no multi valued dependency. Multi valued dependency : Suppose a relation R (A B C), If multi valued dependency exists between A and B, then it is denoted by A B, It means for a single value of attribute A, there are multiple values of attribute B and there must be B and C independent to each other. Note: There must be at least three attributes to occur multi valued dependency. Ex: Consider the following table: stu_id stu_mobile stu_course 101 89832 Java 101 98302 Python 102 45698 PHP 102 45698 Python 103 92342 Java 103 98364 Java One Student can have multiple mobiles and One student can enroll on multiple courses. The Candidate key in above table {stu_id, stu_mobile, stu_course} The table stratifies the rule of BCNF [The whole attribute in the table are the part of the candidate key] But the table still have data redundancy due to multi valued dependencies: stu_id stu_mobile [ for stu_id 101 and 103, there are more than one mobile] stu_id stu_course [ for stu_id 101 and 102, there are more than one course ] stu_mobile and stu_course are also independent to each other. Therefore, to satisfy 4NF, it needs to be decompose into R1 (stu_id, stu_mobile) [The multi valued dependent columns are moved into separate table.] R2(stu_id, stu_course) See how data redundancy is removed by decomposing it into 4NF: R1(stu_id, stu_mobile) R (stu_id, stu_mobile, stu_course) stu_id stu_mobile stu_id stu_mobile stu_course 101 89832 101 89832 Java 101 98302 101 98302 Python 102 45698 102 45698 PHP 103 92342 102 45698 Python 103 98364 103 92342 Java 103 98364 Java R2 (stu_id, stu_course) stu_id 101 101 102 102 103 stu_course Java Python PHP Python Java Multi valued dependency exist: o {stu_id stu_mobile, stu_id stu_course o stu_mobile and stu_course are indepdendent Data Redundancy: o For every new course, mobile needs to be repeated. o For every new mobile, course needs to be repeated. 5NF: A relation in the DBMS is in the Fifth Normal Form if it is in the Fourth Normal Form and does not consist of any join dependency. The joining must also be lossless for this. Fifth Normal Form is satisfied when all the tables present in the DBMS are broken down into as many more tables as possible to ensure that there is no redundancy. Fifth Normal Form is also commonly known as PJ/NF or Project Join Normal Form. Example SUBJECT LECTURER SEMESTER DBMS Manish 1 DBMS Anil 1 JAVA GP 1 JAVA NK 2 HTML AK 1 In the table above, John takes lectures for both, math as well as computer in the first semester but does not take math in the second. In such a case, a combination of all fields in the table is needed to identify the data validity.Now assume that we have to add another semester, where we do not know the subject or the lecturer. What do we do then? This is where Fifth Normal Form comes in. We divide the table into smaller tables Table1 Semester Subject 1 DBMS 1 JAVA 1 HTML 2 JAVA Table2 Subject Lecturer DBMS Manish DBMS Anil JAVA GP JAVA NK HTML AK Table3 Semester Lecturer 1 Manish 1 Anil 1 GP 2 NK 1 AK