180 likes | 294 Views
Normal Forms for Tables. The concept of normal forms: established in the early period of development of DB’s means of detecting and correcting bad table design included in most DB texts as a foundation concept (Bill’s view) superceded by principles of OO design
E N D
The concept of normal forms: • established in the early period of development of DB’s • means of detecting and correcting bad table design • included in most DB texts as a foundation concept • (Bill’s view) superceded by principles of OO design • e.g. don’t design bad objects => no need to correct tables
First normal form: attributes must be atomic ( not sets of values) eg. Employee( name, {dependent} )
First normal form: attributes must be atomic ( not sets of values) eg. Employee( name, {dependent} ) ?why: usually implemented by a string of names: “Bill, Bob, Mary” which does not support easy queries.
First normal form: attributes must be atomic ( not sets of values) eg. Employee( name, {dependent} ) ?why: usually implemented by a string of names: “Bill, Bob, Mary” which does not support easy queries. In OO design: it violates UML aggregation model.
Second & third normal forms based on concept of functional dependency: A -> B means field A acts as a key for field B
Second & third normal forms based on concept of functional dependency: A -> B means field A acts as a key for field B Table: A B C a e f b g w a q f c e f
Second & third normal forms based on concept of functional dependency: A -> B means field A acts as a key for field B Table: A B C a e f b g w a q f c e f ? A -> B ? A,B -> C ? A -> C ? B -> C ? B -> A
Second normal form: no partial dependency A,B -> C,D,E B -> D ? why: can split tables into separate tables; e.g EmpProj: SSN, Pnum, name, hours, Plocation Emp: SSN, name EmpWork: SSN, Pnum, hours Proj: Pnum, Plocation
Second normal form: no partial dependency A,B -> C,D,E B -> D ? why: can split tables into separate tables; e.g EmpProj: SSN, Pnum, name, hours, Plocation Emp: SSN, name EmpWork: SSN, Pnum, hours Proj: Pnum, Plocation OO view: violating E-R modeling
Third normal form: no transitive dependency A -> B, B -> C,D,E ? why: can split tables into separate tables; e.g StudentActivity: SID, Activity, Fee but SID -> Activity, Activity -> Fee to: StudentActivity: SID, Activity Activitiy: Activity, Fee
Third normal form: no transitive dependency A -> B, B -> C,D,E ? why: can split tables into separate tables; e.g StudentActivity: SID, Activity, Fee but SID -> Activity, Activity -> Fee to: StudentActivity: SID, Activity Activitiy: Activity, Fee Object-oriented view: not put 2 entities in same class !!!
other forms: Boyce-Codd Normal form, Fourth Normal form.
Some books show: Domain-key normal form: it is the “universal” good design equivalent to “do good object model” all constraints depend only on the key and the (domain) types of the attributes.
References: Riccardi, (Blue book), Chapter 5. David Kroenke, Database Processing, Prentice Hall, 2004, Chap. , Chap. 4. R. Fagin, “A normal form for relational databases that is based on domains and keys”, Trans. Database Systems, Sept. 1981.