Download presentation
Presentation is loading. Please wait.
1
Boyce-Codd Normal Form
2
"Good" relations So we've established what makes a legal decomposition
That it is lossless But how do we pick the attributes to single out into each relation? How do we avoid redundancy (and anomalies)? By structuring our relations around functional dependencies.
3
Boyce-Codd Normal Form
The Boyce-Codd Normal Form (BCNF) ensures that no redundancy arising from functional dependences are possible. A relation R is in BCNF if and only if: whenever there is a nontrivial FD A1, A2, ..., An → B1, B2, ... Bn for R, it is the case that {A1, A2, ..., An} is a superkey for R. If the left side of each FD is a key (or superkey), then there can't be any redundancy.
4
Example: Is this BCNF? R = {trainer_id, trainer_name, badges, Pokémon_id, Pokémon_species, Pokémon_type} FDs = trainer_id → trainer_name badges Pokémon_id → Pokémon_species Pokémon_species → Pokémon_type Is this in BCNF? No! For the FD (trainer_id → trainer_name badges), trainer_id is not a superkey for R! What is a key for R? {trainer_id, Pokémon_id}
5
Is the relation in BCNF? R = {A, B, C, D} FDs =
1. Yes, the relation is in BCNF 2. No, (A B → C D) is a violation of BCNF 3. No, (A → B) is a violation of BCNF 4. These questions are harder if you use letters instead of intuition.
6
BCNF Decomposition Input: A relation R0 with a set of functional dependencies S0. Output: A decomposition of R0 into a collection of relations, all of which are in BCNF. Method: The following steps can be applied recursively to any relation R and set of FD's S. Initially we set R = R0 and S = S0. Check whether R is in BCNF. If so, nothing more needs to be done. Return {R} as the answer. If there are BCNF violations, let one by X → Y. Make R1 be X+ and R2 be X and the attributes not in R1. Calculate the S+, for each sub-relation (R1 and R2), the set of functional dependencies S1 and S2 are the non-trivial FD's that have all attributes in the respective relation. Recursively decompose R1 and R2 using this algorithm. Return the union of the results of these decompositions.
7
R0 = {trainer_id, trainer_name, badges, Pokémon_id, Pokémon_species, Pokémon_type}
Is this in BCNF? No! For the FD (trainer_id → trainer_name badges), trainer_id is not a superkey for R! {trainer_id}+ = {trainer_id, trainer_name, badges} R1 = {trainer_id, trainer_name, badges}; S1 = {trainer_id → trainer_name badges}; BCNF! R2 = {trainer_id, Pokémon_id, Pokémon_species, Pokémon_type}; S2 = {Pokémon_id → Pokémon_species; Pokémon_species → Pokémon_type}; Not BCNF (Pokémon_species → Pokémon_type; Pokémon_species is not a key)! {Pokémon_species}+ = {Pokémon_species, Pokémon_type} R3 = {Pokémon_species, Pokémon_type}; S3 = {Pokémon_species → Pokémon_type}; BCNF! R4 = {trainer_id, Pokémon_id, Pokémon_species}; S4 = {Pokémon_id → Pokémon_species}; Not BCNF! {Pokémon_id}+ = {Pokémon_id, Pokémon_species} R5 = {Pokémon_id, Pokémon_species}; S5 = {Pokémon_id → Pokémon_species}; BCNF! R6 = {trainer_id, Pokémon_id}; S6 = {}; BCNF!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.