# Boyce-Codd normal form (BCNF) Kai Zhu CS157B Professor: Dr. Lee.

## Presentation on theme: "Boyce-Codd normal form (BCNF) Kai Zhu CS157B Professor: Dr. Lee."— Presentation transcript:

Boyce-Codd normal form (BCNF) Kai Zhu CS157B Professor: Dr. Lee

Functional dependency Given a relation R, a set of attributes X in R is said to functionally determine another attribute Y, also in R, if and only if each X value is associated with precisely one Y value. (written X → Y)

Normalization Normalization is the process of efficiently organizing data in a database Purpose: 1. Eliminate redundant data 2. Ensure data dependencies make sense

1NF Table faithfully represents a relation and has no repeating groups

non-1NF 1NF

2NF A 1NF table is in 2NF if and only if none of its non-prime attributes are functionally dependent on a subset of a candidate key. (A non-prime attribute is one that does not belong to any candidate key.)

An example of a 1NF table that does not meet 2NF is:

Candidate key: {Employee, Skill} The remaining attribute, Current Work Location, is dependent on only part of the candidate key, namely Employee. Therefore the table is not in 2NF.

3NF A 2NF table is in 3NF if every non-prime attribute of R is non-transitively dependent (i.e. directly dependent) on every key of R.

An example of a 2NF table that fails to meet the requirements of 3NF is: Candidate key: {Tournament, Year}

It is not 3NF because the non-prime attribute Winner Date of Birth is transitively dependent on the candidate key {Tournament, Year} via the non- prime attribute Winner.

Trivial functional dependency A functional dependency FD: X → Y is called trivial if Y is a subset of X.

BCNF Boyce-Codd normal form (or BCNF) is a normal form used in database normalization. A table is in BCNF if and only if for every one of its non-trivial functional dependencies X → Y, X is a superkey—that is, X is either a candidate key or a superset thereof. (Y is not included in X)

Consider the following non-BCNF table: The candidate keys of the table are: {Person, Shop Type} {Person, Nearest Shop}

It is 3NF, WHY? Recall 3NF prohibits transitive functional dependencies of non-prime attributes on candidate keys. In relation “Nearest shop” table, there are no non-prime attributes: that is, all attributes belong to candidate keys. Therefore the table adheres to both 2NF and 3NF.

Why it is not BCNF? The table does not adhere to BCNF because of the dependency Nearest shop → Shop Type, in which the determining attribute (Nearest shop ) is neither a candidate key nor a superset of a candidate key.

What we can do if we need a relation to be BCNF?

Normalizing…

After normalization Candidate keys are {person, shop} and{shop},respectively.

Thank you

Download ppt "Boyce-Codd normal form (BCNF) Kai Zhu CS157B Professor: Dr. Lee."

Similar presentations