Download presentation
Presentation is loading. Please wait.
1
Database Normalization
2
7 Normal Forms Unnormalized data Normalized data 1NF 2NF 3NF BCNF 4NF
5NF (PJNF) DKNF Normalized data
3
Steps in normalization
Remove Table with repeating groups Repeating Groups 1st Normal Form Partial Dependencies 2nd Normal Form Transitive Dependencies 3rd Normal Form Determinant / Candidate Keys Boyce-Codd Normal Form Multivalued Dependencies 4th Normal Form Removing Remaining anomalies 5th Normal Form (Project Join NF) Removing Remaining anomalies Domain Key Normal Form
4
Boyce-Codd Normal Form
Determinant: “A determinant is a simple or composite attribute that functionally determines one or more other attributes”. A relation is in BCNF if and only if “Every determinant is a candidate key”. Y = f(X) or X = f(Y) Y = mX + C Determinant is X or Y Dependent is X or Y
5
Boyce-Codd Normal Form
Process All the determinants are identified. If the determinants are candidate keys, the relation is in BCNF.
6
BCNF Consider DEPARTMENT relation with following attributes: DNO DNAME
Example with more than one candidate keys Consider DEPARTMENT relation with following attributes: DNO DNAME EMPS MGR_NO MGR_NAME 1 ACCT 10 100 ALI 2 ADMN 15 200 HASAN 3 FINANCE 20 300 KHAN 4 PROD 25 400 RAZA This relation has three determinants: DNO, DNAME and MGR_NO. Each of the determinants is thus a candidate key. So, the relation is in BCNF.
7
BCNF Consider SAM relation with following attributes: STID MAJOR
Example 2 Consider SAM relation with following attributes: STID MAJOR ADVISOR 1 Database Asad S/w Engineering Faisal 2 Comp. Communication Imran 3 Zahid 4 In this relation, no single attribute is a candidate key. That is, no single attribute is a determinant for the remaining two attributes.
8
BCNF This relation is not in BCNF because:
Example 2 This relation is not in BCNF because: Although ADVISOR is a determinant, it is not a candidate key. Although STID is a determinant, it is not a candidate key. The combination (STID, ADVISOR) is a candidate key for this relation. To convert into BCNF, divide this relation into two relations. The attribute that is a determinant but not a candidate key, must be placed in a separate relation and must be the key of that relation.
9
BCNF Relations in BCNF STID MAJOR ADVISOR MAJOR ADVISOR 1 Database
Asad S/w Engineering Faisal 2 Comp. Communication Imran 3 Database Zahid 4 Database Asad
10
BCNF STID MAJOR ADVISOR STID ADVISOR ADVISOR MAJOR Relations in BCNF 1
Database Asad S/w Engineering Faisal 2 Comp. Communication Imran 3 Zahid 4 STID ADVISOR 1 Asad Faisal 2 Imran 3 Zahid 4 ADVISOR MAJOR Asad Database Faisal S/w Engineering Imran Comp. Communication Zahid
11
4th Normal Form Let R be a relation with A, B and C as the attributes.
Multivalued Dependencies Let R be a relation with A, B and C as the attributes. There is a multivalued dependency of attribute B on attribute A if and only if the set of B values associated with a given A value is independent of the set of C values. Easy A type of dependency that exists when there are at least three attributes (Let A, B and C be the attributes) in a relation, and for each value of A there is a well defined set of values for B and a well defined set of values for C, but the set of values of B is independent of set of values of C.
12
4th Normal Form Example Emp_no Salary Child_Name 1 10000 Ali Akram 2
20000 Babar Elahi Here Child_Name is dependent on Emp_no and is independent of Salary. Emp_no determines salary because there is only one value of salary for each Emp_no. Salary depends on Emp_no. Emp_no multidetermines Child_Name, because there can be several values of Child_name for each Emp_no. Emp_no Child_Name Emp_no Salary
13
4th Normal Form Example COURSE INSTRUCTOR TEXTBOOK Table COURSE
DBMS Ali Akram Babar XYZ ABC C++ Sajid PQR JKL Table COURSE INSTRUCTOR TEXTBOOK DBMS Ali XYZ Akram Babar ABC C++ Sajid PQR JKL Relation
14
4NF A relation is in 4th Normal Form if It is in BCNF and
It contains no multivalued dependencies.
15
4NF Process Relation is in BCNF.
Divide the relation containing m/v dependencies into new relations. Each of these relations contains attributes that have a multivalued relationship in the original relation.
16
4th Normal Form Example Emp_no Child_Name Salary 1 Ali 10000 Akram 2
Babar 20000 Elahi Emp_no Child_Name 1 Ali Akram 2 Babar Elahi Emp_no Salary 1 10000 2 20000
17
4th Normal Form Example COURSE INSTRUCTOR TEXTBOOK COURSE INSTRUCTOR
DBMS Ali XYZ Akram Babar ABC C++ Majid PQR JKL COURSE INSTRUCTOR DBMS Ali Akram Babar C++ Majid COURSE TEXTBOOK DBMS XYZ ABC C++ PQR JKL
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.