620 likes | 1.47k Views
Update Anomalies. CS157B By : Anh Ngo. Data Redundancy. The duplication of information within a table Example: Duplicated information: Information: Branch [B1] located at [6 Lanark Square]. Update Anomalies.
E N D
Update Anomalies CS157B By: Anh Ngo
Data Redundancy • The duplication of information within a table • Example: • Duplicated information: • Information: Branch [B1] located at [6 Lanark Square]
Update Anomalies • A situation, usually caused by redundancy in the schema, in which an update to one value affects another value. • The problems exist in an un-normalized database • Data updating procedures such as insertion, deletion, and modification might result in • Insertion Anomalies • Deletion Anomalies • Modification Anomalies
Insertion Anomalies • A situation, usually cased by redundancy in the schema, in which the insertion of a row in a table creates an inconsistency with other rows
Insertion Anomalies Example • Primary key = ‘StaffID’ • Situation: • Cooperation decides to build a new branch [B5] at [115 Nola Drive] • [B5] currently has no staff member • Action: • Insert into table values (null, null, null, null, null, B5, 115 Nola Drive) • Problems: • Primary key: ‘StaffID’ of this new row = null (not allow)
Deletion Anomalies • A situation, usually caused by redundancy in the schema, in which the deletion of one row of a tables results in the deletion of an unintended information
Deletion Anomalies Example • Primary key = ‘StaffID’ • Situation: • Cooperation decides to fire staff [Juha] • Action: • Delete from table where Name = ‘Juha’ • Problems: • Since [Juha] was the last staff of branch [B3] • Deleting [Juha] cause deletion of branch [B3] (data lost)
Modification Anomalies • A situation, usually caused by redundancy in the schema, in which the modification of a row creates an inconsistency with another row
Modification Anomalies Example • Primary key = ‘StaffID’ • Situation: • Cooperation moves staff [Alex] and branch [B1] to [10 Erie] • Action: • Update table set Br_Address = ‘10 Erie’ Where BranchID = ‘B1’ and Name = ‘Alex’; • Problems: • [Paul] doesn’t know [B1] moves to [10 Erie] (inconsistency)
Decompositions • Decompose a single entity into many smaller entities • Definition: • Let R be a relation schema • A set of relation schemas {R1, R2, …, Rn} is the decomposition of R • R = R1 U R2 U … U Rn • Each Ri is a subset or R • Goal: • Eliminate redundancy and data anomalies by decomposing a relation into several smaller relations with higher normal form
Lossly Decomposition • Instances of the decomposed relations are unable to reconstruct the corresponding instance of the original relation – information loss
A decomposition of a relation is called a lossless decomposition of that relation if the natural join of the decomposition produces exactly the original relation Lossless Decomposition
Insertion Anomalies • Primary key = ‘StaffID’ • Situation: • Cooperation decides to build a new branch [B5] at [115 Nola Drive] • [B5] currently has no staff member • Action: • Insert into table values (null, null, null, null, null, B5, 115 Nola Drive) • Problems: • Primary key: ‘StaffID’ of this new row = null (not allow)
Insertion Anomalies Solution • Primary key = ‘BranchID’ • Situation: • Cooperation decides to build a new branch [B5] at [115 Nola Drive] • [B5] currently has no staff member • Action: • Insert into Branch values (B5, 115 Nola Drive)
Deletion Anomalies • Primary key = ‘StaffID’ • Situation: • Cooperation decides to fire staff [Juha] • Action: • Delete from table where Name = ‘Juha’ • Problems: • Since [Juha] was the last staff of branch [B3] • Deleting [Juha] cause deletion of branch [B3] (data lost)
Deletion Anomalies Solution • Primary key = ‘StaffID’ • Situation: • Cooperation decides to fire staff [Juha] • Action: • Delete from Staff where Name = ‘Juha’
Modification Anomalies • Primary key = ‘StaffID’ • Situation: • Cooperation moves staff [Alex] and branch [B1] to [10 Erie] • Action: • Update table set Br_Address = ‘10 Erie’ Where BranchID = ‘B1’ and Name = ‘Alex’; • Problems: • [Paul] doesn’t know [B1] moves to [10 Erie] (inconsistency)
Modification Anomalies Solution • Primary key = ‘BranchID’ • Situation: • Situation: • Cooperation moves staff [Alex] and branch [B1] to [10 Erie] • Action: • Update Brach set Br_Address = ‘10 Erie’ Where BranchID = ‘B1’
THE END THE END