Docsity

Database Normalization: Reducing Redundancy in Relational Databases, Slides of Database Management Systems (DBMS)

Partial preview of the text

Download Database Normalization: Reducing Redundancy in Relational Databases and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

Database Normalization

 Database normalization relates to the level of redundancy in a relational database’s structure.

 The key idea is to reduce the chance of having multiple different version of the same data.

 Well-normalized databases have a schema that reflects the true dependencies between tracked quantities.

 Any increase in normalization generally involves splitting existing tables into multiple ones, which must be re-joined each time a query is issued.

Database Normalization

First Normal Form ( 1NF )

TABLE 1 Person / Favorite Color Bob / blue Jane / green TABLE 2 Person / Foods Not Eaten Bob / okra Bob / brussel sprouts Jane / peas

“What is your favorite color?” “What food will you not eat?”

Second normal Form ( 2NF )

  • 2NF prescribes full functional dependency on the primary key.
  • It most commonly applies to tables that have composite primary keys, where two or more attributes comprise the primary key.
  • It requires that there are no non-trivial functional dependencies of a non-key attribute on a part (subset) of a candidate key. A table is said to be in the 2NF if and only if it is in the 1NF and every non-key attribute is irreducibly dependent on the primary key

SUPPLIER_NAME (PRIMARY KEY)

SUPPLIER_ADDRESS

2NF Example (Con’t)

  • In order to find if a table is in 2NF, ask whether any of the non-key attributes of the table could be derived from a subset of the composite key, rather than the whole composite key.
  • If the answer is yes, it's not in 2NF.
  • This is solved sometimes by using a correlation file, such as the supplier table above.

Third normal form

  • 3NF requires that there are no non-trivial functional dependencies of non-key attributes on something other than a superset of a candidate key.
  • A table is in 3NF if none of the non-primary key attributes is a fact about any other non- primary key attribute.
  • In summary, all non-key attributes are mutually independent.

Example

Problems? 1.Not very efficient with storage 2.This design does not protect data integrity 3.This table does not scale well

First Normal Form

Defining Relationships

  • One to One
  • One to Many
  • Many to Many

Second Normal Form

Third Normal Form

  • This new table violate Second Normal Form as the street and city will be verically redundant.
  • Province will need to be in its own table which the city table will refer to as a foreign key.
  • A table is said to be in the BCNF if and only if it is in the 3NF and every non-trivial, left-irreducible functional dependency has a candidate key as its determinant.
  • In more informal terms, a table is in BCNF if it is in 3NF and the only determinants are the candidate keys.

Fourth normal form (4NF)

  • 4NF requires that there are no non-trivial

multi-valued dependencies of attribute sets

on something else than a superset of a

candidate key (called a superkey).

  • A table is said to be in 4NF if and only if it is in

the BCNF and multi-valued dependencies are

functional dependencies.