10 Normalization I
10 Normalization I
Normalization - l
1 www.pktutorials.com
Purpose of Normalization:
2 www.pktutorials.com
Characteristic of Suitable Set of Relations:
3 www.pktutorials.com
Benefits of DB with Suitable Relations:
4 www.pktutorials.com
5 www.pktutorials.com
Data Redundancy & Update Anomalies:
6 www.pktutorials.com
Data Redundancy & Update Anomalies:
7 www.pktutorials.com
Data Redundancy & Update Anomalies:
8 www.pktutorials.com
Data Redundancy & Update Anomalies:
▪ Relations that contain redundant information may potentially
suffer from update anomalies
▪ Types of update anomalies include:
▪ Insertion
▪ Insert new staff/branch in StaffBranch relation
▪ Deletion
▪ Delete SA9 from StaffBranch relation
▪ Modification
▪ Update the address for branch number B003
9 www.pktutorials.com
Decomposition:
▪ We can avoid these anomalies by decomposing the original relation into the
Staff and Branch relations
▪ There are two important properties associated with decomposition of a larger
relation into smaller relations:
▪ The lossless-join property ensures that any instance of the original relation
can be identified from corresponding instances in the smaller relations
▪ The dependency preservation property ensures that a constraint on the
original relation can be maintained by simply enforcing some constraint on
each of the smaller relations. In other words, we do not need to perform
joins on the smaller relations to check whether a constraint on the original
relation is violated
10 www.pktutorials.com
Functional Dependencies:
11 www.pktutorials.com
Determinant:
12 www.pktutorials.com
An Example Functional Dependency:
13 www.pktutorials.com
Observations: Example FD
▪ The relationship between staffNo and position is one-to-one (1:1): for each staff
number there is only one position
▪ On the other hand, the relationship between position and staffNo is one-to-many
(1:*): there are several staff numbers associated with a given position
14 www.pktutorials.com
Example: FD for all Time
15 www.pktutorials.com
Full Functional Dependency:
16 www.pktutorials.com
Partial Functional Dependency:
17 www.pktutorials.com
Functional Dependency:
In summary, the functional dependencies that we use in normalization have the following
characteristics:
18 www.pktutorials.com
Transitive Dependency:
19 www.pktutorials.com
Example: Transitive Dependency
▪ Transitive dependency,
branchNo → bAddress exists on staffNo via branchNo
20 www.pktutorials.com
Identifying Functional Dependencies:
21 www.pktutorials.com
Identifying FDs: Staff Branch Relation
22 www.pktutorials.com
Identifying FDs: Using Sample Data
23 www.pktutorials.com
Identifying FDs: Using Sample Data
24 www.pktutorials.com
Identifying FDs: Using Sample Data
25 www.pktutorials.com
Identifying FDs: Using Sample Data
➢ Functional dependencies between attributes A to E in the Sample
relation
1. A→C (fd1)
2. C →A (fd2)
3. B →D (fd3)
4. A, B → E (fd4)
26 www.pktutorials.com
Identifying PKs Using FDs:
27 www.pktutorials.com
Identifying PKs Using FDs:
StaffBranch relation has five functional dependencies
1) The determinants are staffNo, branchNo, bAddress, (branchNo, position), and
(bAddress, position)
2) To identify all candidate key(s), identify the attribute (or group of attributes) that
uniquely identifies each tuple in this relation
3) All attributes that are not part of a candidate key should be functionally
dependent on the key
4) The only candidate key and therefore primary key for StaffBranch relation, is
staffNo, as all other attributes of the relation are functionally dependent on
staffNo
5) Although branchNo, bAddress, (branchNo, position), and (bAddress, position) are
determinants in this relation, they are not candidate keys for the relation
28 www.pktutorials.com
Identifying PKs Using FDs:
Sample relation has four FDs and the determinants in the Sample relation are A,
B, C, and (A, B):
1) However, the only determinant that functionally determines all the other
attributes of the relation is (A, B), hence identified as the primary key for
this relation
2) In particular, A functionally determines C, B functionally determines D, and
(A, B) functionally determines E
3) In other words, the attributes that make up the determinant (A, B) can
determine all the other attributes in the relation either separately as A or B
or together as (A, B)
4) An essential characteristic for a candidate key of a relation is that the
attributes of a determinant either individually or working together must be
able to functionally determine all the other attributes in the relation
29 www.pktutorials.com
THANKS
30 4/30/2024 www.pktutorials.com