Presentation is loading. Please wait.

Presentation is loading. Please wait.

Database Management COP4540, SCS, FIU Relation Normalization (Chapter 14)

Similar presentations


Presentation on theme: "Database Management COP4540, SCS, FIU Relation Normalization (Chapter 14)"— Presentation transcript:

1 Database Management COP4540, SCS, FIU Relation Normalization (Chapter 14)

2 Database Management COP4540, SCS, FIU Modification Anomalies What are modification anomalies? –Errors or inconsistencies that may result when a user attempts to update a relation. Types of anomalies. –Insertion anomalies. An independent piece of information cannot be recorded into a relation unless an irrelevant information must be inserted together at the same time –Update anomalies. The update of a piece of information must occur at multiple locations, not required by the referential integrity rule. –Deletion anomalies The deletion of a piece of information unintentionally removes other information.

3 Database Management COP4540, SCS, FIU Normal Forms Normal forms are classes of relations and the techniques for preventing anomalies. Normal forms are classified by the type of modification anomalies that have been removed. Types of normal forms: –First Normal Form (1NF). –Second Normal Form (2NF). –Third Normal Form (3NF). –Boyce-Codd Normal Form (BCNF). –Fourth Normal Form (4NF). –Fifth Normal Form (5NF). –Domain/Key Normal Form (DK/NF).

4 Database Management COP4540, SCS, FIU First Normal Form (1NF) A relation R is in 1NF if and only if all attribute domains contain atomic values only. Any table meets the definition of a relation is said to be in first Normal form, i.e. a relation in relational schema is always in 1NF.

5 Database Management COP4540, SCS, FIU Second Normal Form (2NF) A relation is in 2NF if and only if it is in 1NF without partial dependencies. Partial dependency –A dependency in which one or more non-key attributes are functionally dependent on part (but not all) of the key. Two extreme cases –The primary key consists of only one attribute. –No non-key attributes exist in the relation.

6 Database Management COP4540, SCS, FIU Third Normal Form A relation R is in 3NF if: whenever A 1 A 2 … A n  B is a nontrivial dependency, either {A 1, …,A n } is a superkey, or B is a member of some key. A relation is in 3NF if: –it is in 2NF without transitive dependencies. –Transitive dependency A functional dependency between two (or more) non-key attributes.

7 Database Management COP4540, SCS, FIU Example SALES(Cust_ID, Name, Salesperson, Region) FDs: Cust_ID  Cust_ID Name Salesperson Region Salesperson  Region

8 Database Management COP4540, SCS, FIU Example SALES1(Cust_ID, Name, Salesperson) SPERSON(Selesperson, Region)

9 Database Management COP4540, SCS, FIU Another Example SHIPMENT(Snum, Origin, Destination Distance) FDs: Snum  Snum Origin Destination Distance Origin Destination  Distance SHIPMENT(Snum, Origin, Destination) DISTANCE(Origin Destination Distance)

10 Database Management COP4540, SCS, FIU Relation Normalization Question FDs: SID CID  Grade SID  Name Major CID  Text Major  Dept 1. What can be the primary key for above relation? 2. Decompose the above relation into 2NF then 3NF relations.

11 Database Management COP4540, SCS, FIU Boyce-Codd Normal Form A relation R is in BCNF if and only if: whenever nontrivial dependency A 1 A 2 … A n  B 1 B 2 … B m holds for R, it must be the case that {A1, A2, …, An} is a superkey for R. BCNF is one of the most important normal forms. –Relations in BCNF have no anomaly in regards to functional dependencies.

12 Database Management COP4540, SCS, FIU 1. Each students may major in several subjects. 2. For each major, a given student has only one adviser. 3. Each major has several advisors. 4. Each advisor advises only one major. 5. Each advisor advises several students in one major. StuId Major  Fname; Fname  Major

13 Database Management COP4540, SCS, FIU Decomposition into BCNF 1. Set D = {R}; 2. While there is a relation Q in D that is not in BCNF do begin choose a relation Q in D that is not in BCNF; find a FD X  Y in Q that violates BCNF; Expand right side to include X + ; replace Q in D by two relations (Q-X + )  X and X + ; end;

14 Database Management COP4540, SCS, FIU Tables1NF2NF3NFBCNF Remove non-atomic attributes Remove partial dependencies Remove transitive dependencies Remove remaining anomalies resulting from functional dependencies


Download ppt "Database Management COP4540, SCS, FIU Relation Normalization (Chapter 14)"

Similar presentations


Ads by Google