Normalization & FDs
Normalization & FDs
Management
Systems
1
What Is a DBMS?
2
Keys
5
• Foreign Key : -> A foreign key is an attribute that
appears in one table but is the primary key in other
table.
Example: Emp{emp_no, e_name, dept_no, sal }
Dept{dept_no,d_name,loc }
dept_no is a Primary Key in Dept table
dept_no is a Foreign Key in Emp table
6
Normalization
• Normalization is a database design technique. It is a
7
Example: Student Activity table
SID Activity Fee
8
First normal Form : -> A table is in the first normal form
when ever intersection of a row & column contains 1 value. In other
words no attribute value represent a set of values.
Example: LIBRARY
M_code M_nam M_addre M_type M_fees B_code B_name Author I_date R_date
e ss
Anomalies:->
1. Every members details are repeated the number of times equal to the
number of books taken by that member.
2. A book cannot be added within file until any member is issued that book.
3. While modifying the details about a particular member, it is required to
modified the details for all the record of that member.
4. While deleting details about a particular member, details about the
books taken by that member also get deleted.
9
Second normal Form:-> A table is in second normal
form if non key attributes are fully dependent on the whole key.
Step to go in 2NF
1. Find out functional dependency and try to achieve full functional
dependency.
2. Create separate tables for each fully functionally dependent set.
( Primary key )
Example:-
Member M_code M_name M_address M_type
( Primary key )
Member ship
M_type M_fees
( Primary key )
11
Boyce-Codd Normal Form :
Consider the relation ADVISOR
SID MAJOR FNAME
100 MATH CAUCHY
100 PHYSICS JUNG
150 PHYSICS JUNG
200 MATH CAUCHY
300 PHYSICS PERL
1. Deletion anomaly -> suppose student 300 drops out. If we delete student
300 tuple we lose the fact that PERL advise PHYSICS this is deletion
anomalies.
2. If we want to store the fact that KEYNES advises in ENGLISH ? we can’t
insert until a student major is ENGLISH . this is an insertion anomaly.
12
To remove this we use BCNF- A relation is in BCNF if every
determinant is Candidate key.
If relation is in BCNF then there is no anomalies regarding functional
dependence.
STU_ADV ADV_SUB
100 CAUCHY
CAUCHY MATH
100 JUNG
150 JUNG JUNG PHYSICS
200 CAUCHY
PERL PHYSICS
200 PERL
13
Functional Dependencies
Functional Dependencies (FD) generalizes the concept of a
key. It can also be thought of as a constraint between two
sets of attributes. In other words, FD is a constraint that is to
be satisfied by every desirable relation instance. It is a
constraint on the behavior of attributes in a schema.
Functional Dependencies are constraint on the set of legal
relations.
14
Let r be a relations schema and let X and Y be non-empty sets of
attributes in r. We say that for a relation instance R of the schema r has
a Functional Dependency X Y if the following conditions holds for
every pairs of tuples t1 and t2 in R.
15
Inference Rules for FDs
• The following are the inference rules to generate new FDs from a
given set of FDs. For the rules described below, we assume X, Y and Z
are the subset of attributes in the schema r.
1. Reflexive Rule
If X ⊇ Y, then X Y
2. Augmentation
If X Y then XZ YZ
3. Transitive Rule
If X Y and Y Z, then X Z
4. Decomposition
If X YZ then X Y, and X Z
5. Union
If X Y and X Z, then X YZ
16
Thanks
17