Normal Forms 1NF – A table that qualifies as a relation is in 1NF. (Back)(Back) 2NF – A relation is in 2NF if all of its nonkey attributes are dependent on all of the primary key. 3NF – A relation is in 3NF if it is in 2NF and has no determinants except the primary key. Boyce-Codd Normal Form (BCNF) – A relation is in BCNF if every determinant is a candidate key. “I swear to construct my tables so that all nonkey columns are dependent on the key, the whole key and nothing but the key, so help me Codd.”
Normalization Normalization is a process of evaluating and converting a relation to reduce modification anomalies الاشياء الشاذه Essentially, normalization detects and eliminates data redundancy
Normal Forms Any table of data is in 1NF if it meets the definition of a relation A relation is in 2NF if all its non-key attributes are dependent on all of the key (no partial dependencies) –If a relation has a single attribute key, it is automatically in 2NF A relation is in 3NF if it is in 2NF and has no transitive dependencies A relation is in BCNF if every determinant is a candidate key A relation is in fourth normal form if it is in BCNF and has no multi-valued dependencies
First Normal Form (1NF) To be in First Normal Form (1NF) a relation must have only single-valued attributes -- neither repeating groups nor arrays are permitted
First Normal Form “any table of data that meets the definition of a relation” Note : A Student can only have One Activity if SID is the Key
Second Normal Form (2NF) To be in Second Normal Form (2NF) the relation must be in 1NF and each non-key attribute must be dependent on the whole key (not a subset of the key) No Partial Dependencies
Combination Key with Partial Dependence Key : SID, Activity SID, Activity Fee; Activity Fee
Second Normal Form “ when all of a relation’s nonkey attributes are dependent on all of the key” (Note 2 Themes), or No Partial Dependencies 100Golf 175Swimming 200Golf Golf65
Second Normal Form Conversion to 1NF involves removing repeating groups from potential relations Examples : any table consisting of atomic values Conversion of 2NF involves removing partial dependencies from 1NF relations Example on next slide
ASSIGN PERSON_ID* PROJECT_BUDGET PROJECT* TIME_SPENT S7532P17 S7540P23 S7932P14 S7927P31 S8040P25 Functional Dependencies in ASSIGN PERSON_ID + PROJECT TIME_SPENT PROJECT PROJECT_BUDGET To convert to 2NF, factor out the partial dependence of PROJECT_BUDGET on PROJECT into a separate relation
PROJECTS PROJECT* PROJECT_BUDGET P132 P240 P327 P417 ASSIGNMENTS PERSON_ID* PROJECT*TIME_SPENT S75P17 S75P23 S79P14 S79P311 S80P25
Note that the PROJECTS and ASSIGNMENTS Relations are in 2NF, and have captured the basic ideal of DKNF with each relation modeling a basic fact about the database. Demonstrate the Join of PROJECTS and ASSIGNMENTS