Normalization

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Normalization as PDF for free.

More details

  • Words: 869
  • Pages: 4
Eliminate Repeating Groups In the original member list, each member name is followed by any databases that the member has experience with. Some might know many, and others might not know any. To answer the question, "Who knows DB2?" we need to perform an awkward scan of the list looking for references to DB2. This is inefficient and an extremely untidy way to store information. Moving the known databases into a seperate table helps a lot. Separating the repeating groups of databases from the member information results in first normal form. The MemberID in the database table matches the primary key in the member table, providing a foreign key for relating the two tables with a join operation. Now we can answer the question by looking in the database table for "DB2" and getting the list of members.

2. Eliminate Redundant Data In the Database Table, the primary key is made up of the MemberID and the DatabaseID. This makes sense for other attributes like "Where Learned" and "Skill Level" attributes, since they will be different for every member/database combination. But the database name depends only on the DatabaseID. The same database name will appear redundantly every time its associated ID appears in the Database Table. Suppose you want to reclassify a database - give it a different DatabaseID. The change has to be made for every member that lists that database! If you miss some, you'll have several members with the same database under different IDs. This is an update anomaly. Or suppose the last member listing a particular database leaves the group. His records will be removed from the system, and the database will not be stored anywhere! This is a delete anomaly. To avoid these problems, we need second normal form.

To achieve this, separate the attributes depending on both parts of the key from those depending only on the DatabaseID. This results in two tables: "Database" which gives the name for each DatabaseID, and "MemberDatabase" which lists the databases for each member. Now we can reclassify a database in a single operation: look up the DatabaseID in the "Database" table and change its name. The result will instantly be available throughout the application.

3. Eliminate Columns Not Dependent On Key The Member table satisfies first normal form - it contains no repeating groups. It satisfies second normal form - since it doesn't have a multivalued key. But the key is MemberID, and the company name and location describe only a company, not a member. To achieve third normal form, they must be moved into a separate table. Since they describe a company, CompanyCode becomes the key of the new "Company" table. The motivation for this is the same for second normal form: we want to avoid update and delete anomalies. For example, suppose no members from the IBM were currently stored in the database. With the previous design, there would be no record of its existence, even though 20 past members were from IBM!

BCNF A relation R is in Boyce-Codd normal form (BCNF) if and only if every determinant is a candidate key The definition of BCNF addresses certain (rather unlikely) situations which 3NF does not handle. The characteristics of a relation which distinguish 3NF from BCNF are given below. Since it is so unlikely that a relation would have these characteristics, in practical real-life design it is usually the case that relations in 3NF are also in BCNF. Thus many authors make a "fuzzy" distinction between 3NF and BCNF when it comes to giving advice on "how far" to normalize a design. Since relations in 3NF but not in BCNF are slightly unusual, it is a bit more difficult to come up with meaningful examples. To be precise, the definition of 3NF does not deal with a relation that:

1. has multiple candidate keys, where 2. those candidate keys are composite, and 3. the candidate keys overlap (i.e., have at least one common attribute) Example: An example of a relation in 3NF but not in BCNF (and exhibiting the three properties listed) was given above in the discussion of 3NF. The following relation is in BCNF (and also in 3NF): SUPPLIERS (supplier_no, supplier_name, city, zip) We assume that each supplier has a unique supplier_name, so that supplier_no and supplier_name are both candidate keys.

Functional Dependencies:

supplier_no → city supplier_no → zip supplier_no → supplier_name supplier_name → city supplier_name → zip supplier_name → supplier_no

Comments: The relation is in BCNF since both determinants (supplier_no and supplier_name) are unique (i.e., are candidate keys). The relation is also in 3NF since even though the non-primary-key column supplier_name determines the non-key columns city and zip, supplier_name is a candidate key. Transitive dependencies involving a second (or third, fourth, etc.) candidate key in addition to the primary key do not violate 3NF. Note that even relations in BCNF can have anomalies.

Anomalies: INSERT: We cannot record the city for a supplier_no without also knowing the supplier_name DELETE: If we delete the row for a given supplier_name, we lose the information that the supplier_no is associated with a given city. UPDATE: Since supplier_name is a candidate key (unique), there are none.

Decomposition: SUPPLIER_INFO (supplier_no, city, zip) SUPPLIER_NAME (supplier_no, supplier_name)

Related Documents

Normalization
November 2019 16
Normalization
June 2020 12
Normalization
November 2019 34
Normalization
November 2019 26
Normalization
November 2019 18
Normalization
November 2019 17