Unit 2 Database Design
Unit 2 Database Design
Database Design
• Functional Dependencies
• Inference Rules
• Functional Dependency Closure
• Minimal Cover
• Decomposition Properties
• Need of Normalization
• Normal Forms: 1NF, 2NF, 3NF and BCNF, Multi-valued Dependency,
4NF
Functional Dependencies
• Functional Dependency (FD) is a constraint that determines the relation of one attribute
to another attribute in a Database Management System (DBMS).
• The attributes of a table is said to be dependent on each other when an attribute of a
table uniquely identifies another attribute of the same table.
• For example: Suppose we have a student table with attributes: Stu_Id, Stu_Name, Stu_Age.
Here Stu_Id attribute uniquely identifies the Stu_Name attribute of student table because
if we know the student id we can tell the student name associated with it. This is known as
functional dependency and can be written as Stu_Id->Stu_Name or in words we can say
Stu_Name is functionally dependent on Stu_Id.
• Formally:
If column A of a table uniquely identifies the column B of same table then it can
represented as A->B (Attribute B is functionally dependent on attribute A)
• A->B The left side of FD is known as a determinant, the right side of the production is
known as a dependent.
Functional Dependencies
• Types of Functional Dependencies in DBMS
• There are mainly four types of Functional Dependency in DBMS. Following
are the types of Functional Dependencies in DBMS:
• Multivalued Dependency
• Trivial Functional Dependency
• Non-Trivial Functional Dependency
• Transitive Dependency
Functional Dependencies
• Multivalued Dependency:
• Multivalued dependency occurs in the situation where there are multiple
independent multivalued attributes in a single table.
• A multivalued dependency is a complete constraint between two sets of
attributes in a relation. It requires that certain tuples be present in a
relation. Car_model Maf_year Color
• In this example, maf_year and color are H001 2017 Metallic
independent of each other but dependent on H001 2017 Green
car_model. In this example, these two columns H005 2018 Metallic
are said to be multivalue dependent on H005 2018 Blue
car_model. H010 2015 Metallic
• This dependence can be represented like this: H033 2012 Gray
• car_model -> maf_year
• car_model-> colour
Emp_id Emp_name
Functional Dependencies AS555
AS811
Harry
George
• Trivial Functional Dependency in DBMS
• The Trivial dependency is a set of attributes which are called a trivial if the set of
attributes are included in that attribute.
• So, X -> Y is a trivial functional dependency if Y is a subset of X.
• Consider this table of with two columns Emp_id and Emp_name.
• {Emp_id, Emp_name} -> Emp_id is a trivial functional dependency as Emp_id is a
subset of {Emp_id,Emp_name}.
• Non Trivial Functional Dependency in DBMS
• Functional dependency which also known as a nontrivial
dependency occurs when A->B holds true where B is not a subset Company CEO Age
of A.
Microsoft Satya Nadella 51
• In a relationship, if attribute B is not a subset of attribute A, then it
is considered as a non-trivial dependency. Google Sundar Pichai 46
Apple Tim Cook 57
• (Company} -> {CEO} (if we know the Company, we knows the CEO
name)
• But CEO is not a subset of Company, and hence it’s non-trivial
functional dependency.
Company CEO Age
EMP_DEPT table
• Functional dependencies: EMP_DEPT_MAPPING table
• EMP_ID → EMP_COUNTRY
• EMP_DEPT → {DEPT_TYPE, EMP_DEPT_NO}
• Candidate keys:
• Now, this is in BCNF because left
• For the first table: EMP_ID side part of both the functional
• For the second table: EMP_DEPT dependencies is a key.
• For the third table: {EMP_ID, EMP_DEPT}
Fourth Normal Form(4NF) • You must be thinking what problem
this can lead to, right?
• Well the two records for student
• A table is said to be in the Fourth Normal with s_id 1, will give rise to two
Form when, more records, as shown below,
because for one student, two
1.It is in the Boyce-Codd Normal Form. hobbies exists, hence along with
2.And, it doesn't have Multi-Valued both the courses, these hobbies
should be specified.
Dependency. s_id course hobby
s_id course hobby 1 Science Cricket
1 Science Cricket 1 Maths Hockey
1 Maths Hockey 1 Science Hockey
2 C# Cricket 1 Maths Cricket
2 Php Hockey
• And, in the table above, there is no
relationship between the columns
• As you can see in the table above, course and hobby. They are
student with s_id 1 has opted for two independent of each other.
courses, Science and Maths, and has • So there is multi-value dependency,
two hobbies, Cricket and Hockey. which leads to un-necessary repetition
of data and other anomalies as well.
Fourth Normal Form(4NF)
• To make the above s_id course s_id hobby
relation satify the 4th
normal form, we can 1 Science 1 Cricket
decompose the table 1 Maths 1 Hockey
into 2 tables. 2 C# 2 Cricket
2 Php
2 Hockey