Presentation is loading. Please wait.

Presentation is loading. Please wait.

1st, 2nd, 3rd Normal Forms Boyce-Codd Normal Form

Similar presentations


Presentation on theme: "1st, 2nd, 3rd Normal Forms Boyce-Codd Normal Form"— Presentation transcript:

1 1st, 2nd, 3rd Normal Forms Boyce-Codd Normal Form

2 Normalization Database normalization is the process of organizing the attributes and tables of a relational database to minimize data redundancy. Normalization involves refactoring a table into smaller (and less redundant) tables but without losing information; defining foreign keys in the old table referencing the primary keys of the new ones. The objective is to isolate data so that additions, deletions, and modifications of an attribute can be made in just one table and then propagated through the rest of the database using the defined foreign keys

3 Boyce and Codd Raymond 'Ray' Boyce was an American computer scientist who was known for his research in relational databases. He is most known for his work co-developing the SQL database language and Boyce-Codd normal form.

4 Boyce and Codd Edgar Frank "Ted" Codd was an English computer scientist who, while working for IBM, invented the relational model for database management, the theoretical basis for relational databases. He made other valuable contributions to computer science, but the relational model, a very influential general theory of data management, remains his most mentioned achievement.

5 Definitions a data domain refers to all the values which a data element may contain An Atomic value cannot be decomposed into smaller pieces by the DBMS A transitive dependency is a functional dependency in which X →Z (X determines Z) indirectly, by virtue of X → Y and Y → Z (where it is not the case that Y → X) A superkey is a set of attributes so that no two distinct tuples (rows) that have the same values for the attributes in this set A candidate key of a relation is a minimal superkey A non-prime attribute of R is an attribute that does not belong to any other candidate key of R

6 1st normal form (Codd) A relation is in first normal form if the domain of each attribute contains only atomic values, and the value of each attribute contains only a single value from that domain ID First Name Last Name Telephone Number 123 Nicole Polizzi 456 Jennifer Farley 789 Michael Sorrentino

7 Not in 1NF (Jennifer has 2 phones)
ID First Name Last Name Telephone Number 123 Nicole Polizzi 456 Jennifer Farley 789 Michael Sorrentino

8 In 1NF ID First Name Last Name Telephone Number 123 Nicole Polizzi
456 Jennifer Farley 789 Michael Sorrentino

9 Also In 1NF (better) ID First Name Last Name 123 Nicole Polizzi 456
Jennifer Farley 789 Michael Sorrentino ID Telephone Number 123 456 789

10 2nd Formal Form (Codd 1971) A table that is in first normal form (1NF)
no non-prime attribute is dependent on any proper subset of any candidate key of the table

11 Not 2nd NF Person Task Home Location Polizzi Gym Seaside Heights
Laundry Farley Sorrentino Middletown Tan

12 In 2NF Person Task Polizzi Gym Laundry Farley Sorrentino Tan Person
Home Location Polizzi Seaside Heights Farley Sorrentino Middletown

13 Not in 2nd NF Candidate Key = <Season,Best Episode>
Main Actor Finale Date Season 1 9 Jennifer Farley 3-Dec-09 Season 2 13 Nicole Polizzi 29-Jul-10 Season 3 6-Jan-11 Season 4 12 Michael Sorrentino 4-Aug-11 Season 5 11 5-Jan-12 Candidate Key = <Season,Best Episode> Not in 2NF because SeasonFinale Date

14 In 2nd NF Season Best Episode Main Actor Season 1 1 Jennifer Farley
3 Nicole Polizzi Season 3 Season 4 2 Michael Sorrentino Season 5 5 Season Finale Date Season 1 3-Dec-09 Season 2 29-Jul-10 Season 3 6-Jan-11 Season 4 4-Aug-11 Season 5 5-Jan-12

15 3nd NF The relation R (table) is in second normal form (2NF)
Every non-prime attribute of R is non-transitively dependent on every superkey  of R.

16 3rd Normal Form This definition states that a table is in 3NF if and only if, for each of its functional dependencies X → A, at least one of the following conditions holds: X contains A (that is, X → A is trivial functional dependency), or X is a superkey, or Every element of A-X, the set difference between A and X, is a prime attribute (i.e., each attribute in A-X is contained in some candidate key

17 Not in 3NF (ActorDOB) 27-Feb-86 Season Best Episode Main Actor
9 Jennifer Farley 27-Feb-86 Season 2 13 Nicole Polizzi 23-Nov-87 Season 3 Season 4 12 Michael Sorrentino 4-Jul-82 Season 5 11

18 In 3NF Season Best Episode Main Actor Season 1 9 Jennifer Farley
13 Nicole Polizzi Season 3 Season 4 12 Michael Sorrentino Season 5 11 Main Actor Actor DOB Jennifer Farley 27-Feb-86 Nicole Polizzi 23-Nov-87 Michael Sorrentino 4-Jul-82

19 Boyce-Codd Normal Form
All redundancy based on functional dependency  has been removed, although other types of redundancy may still exist. A relational schema R is in Boyce–Codd normal form if and only if for every one of its dependencies X → Y, at least one of the following conditions hold X → Y is a trivial functional dependency (Y ⊆ X) X is a super key for schema R

20 In 3NF but not BCNF <student, course>  <teacher> <teacher>  <course> Student Course Teacher Jennifer Farley Operating Systems Clayton Nicole Polizzi Database Byrne Michael Sorrentino Wang

21 In 3NF but not BCNF <student, course>  <teacher> <teacher>  <course> <Student, Instructor> and <Student,Course> <Course, Instructor> and <Student,Course> <Course, Instructor> and <Student,Instructor> Student Course Teacher Jennifer Farley Operating Systems Clayton Nicole Polizzi Database Byrne Michael Sorrentino Wang

22 Boyce-Codd Normal Form
A relation is in Boyce-Codd Normal Form if whenever a functional dependency XA in R then X is a superkey of R (or A is a proper subset of X) Algorithm for getting into BCNF Set D  {R}; while there is a relation schema Q in D that is not in BCNF do choose a relation schema Q in D that is not in BCNF; find a functional dependency X  Y in Q that violates BCNF; replace Q in D by two schemas (Q – Y) and (X  Y)


Download ppt "1st, 2nd, 3rd Normal Forms Boyce-Codd Normal Form"

Similar presentations


Ads by Google