Database normalization is the process of organizing the attributes of the database to reduce or eliminate data redundancy (having the same data but at different places) .
Problems because of data redundancy
Data redundancy unnecessarily increases the size of the database as the same data is repeated in many places. Inconsistency problems also arise during insert, delete and update operations.
Functional Dependency
Functional Dependency is a constraint between two sets of attributes in a relation from a database. A functional dependency is denoted by arrow (→). If an attributed A functionally determines B, then it is written as A → B.
For example, employee_id → name means employee_id functionally determines the name of the employee. As another example in a time table database, {student_id, time} → {lecture_room}, student ID and time determine the lecture room where the student should be.
What does functionally dependent mean?
A function dependency A → B means for all instances of a particular value of A, there is the same value of B.
For example in the below table A → B is true, but B → A is not true as there are different values of A for B = 3.
Trivial Functional Dependency
X → Y is trivial only when Y is subset of X.
Examples
ABC → AB
ABC → A
ABC → ABC
Non Trivial Functional Dependencies
X → Y is a non trivial functional dependencies when Y is not a subset of X.
X → Y is called completely non-trivial when X intersect Y is NULL.
Examples:
Id → Name,
Name → DOB
Semi Non Trivial Functional Dependencies
X → Y is called semi non-trivial when X intersect Y is not NULL.
Examples:
AB → BC,
AD → DC
Normalization is the process of minimizing redundancy from a relation or set of relations. Redundancy in relation may cause insertion, deletion and updation anomalies. So, it helps to minimize the redundancy in relations. Normal forms are used to eliminate or reduce redundancy in database tables.
1. First Normal Form
If a relation contain composite or multi-valued attribute, it violates first normal form or a relation is in first normal form if it does not contain any composite or multi-valued attribute.
A relation is in first normal form if every attribute in that relation is singled valued attribute.
2. Second Normal Form
To be in second normal form, a relation must be in first normal form and relation must not contain any partial dependency. A relation is in 2NF if it has No Partial Dependency, i.e., no non-prime attribute (attributes which are not part of any candidate key) is dependent on any proper subset of any candidate key of the table.
Partial Dependency: If the proper subset of candidate key determines non-prime attribute, it is called partial dependency.
3. Third Normal Form
A relation is in third normal form, if there is no transitive dependency for non-prime attributes as well as it is in second normal form.
A relation is in 3NF if at least one of the following condition holds in every non-trivial function dependency X → Y
Transitive dependency: If A → B and B → C are two FDs then A → C is called transitive dependency.
4. Boyce-Codd Normal Form (BCNF)
A relation R is in BCNF if R is in Third Normal Form and for every FD, LHS is super key. A relation is in BCNF iff in every non-trivial functional dependency X → Y, X is a super key.
Key Points
Exercise 1: Find the highest normal form in R (A, B, C, D, E) under following functional dependencies.
ABC --> D
CD --> AE
Important Points for solving above type of question.
Candidate keys in the given relation are {ABC, BCD}
BCNF: ABC → D is in BCNF. Let us check CD → AE, CD is not a super key so this dependency is not in BCNF. So, R is not in BCNF.
3NF: ABC → D we don’t need to check for this dependency as it already satisfied BCNF. Let us consider CD → AE. Since E is not a prime attribute, so the relation is not in 3NF.
2NF: In 2NF, we need to check for partial dependency. CD which is a proper subset of a candidate key and it determine E, which is non-prime attribute. So, given relation is also not in 2 NF. So, the highest normal form is 1 NF.
62 videos|66 docs|35 tests
|
1. What is database normalization? |
2. Why is database normalization important? |
3. What are the main normal forms in database normalization? |
4. How does database normalization improve data integrity? |
5. What are the potential drawbacks of excessive normalization? |
|
Explore Courses for Computer Science Engineering (CSE) exam
|