Download presentation
Presentation is loading. Please wait.
1
Class Presentation: Normal Form By Wen Ying Gao CS157A Section 2 October 20, 2005
2
Database Normalization Database normalization relates to the level of redundancy in a relational database’s structure. The key idea is to reduce the chance of having multiple different versions of the same data, like an address, by storing all potentially duplicated data in different tables and linking to them instead of using a copy.
3
First Normal Form The domains of all attributes of a relation schema R are atomic, which is if elements of the domain are considered to be indivisible units. It involves that removal of redundant data from horizontal rows. We need to ensure that there is no duplication of data in a given row, and that every column stores the least amount of information possible.
4
Example: A table for the entity of Book TitleAuthorISBNSubjectPublisherPages Database System Concepts Sudarshan0-07-295886-3DatabaseMcGraw-Hill1142 Database System Concepts Silberschatz0-07-295886-3DatabaseMcGraw-Hill1142 The Ultimate Guide Das0-07-240500-7UnixMcGraw-Hill445 The Ultimate Guide Korth0-07-240500-7UnixMcGraw-Hill445
5
By applying the first normal form, we will have to construct separate tables for the redundant data with extra tables to define the relationship between the tables. Author_IDLast NameFirst Name 1SudarshanMark 2SilberschatzAbraham 3DasSumitabha 4KorthHenry * Here we have the table for author. Subject_IDSubject 1Database 2Unix * Here we have the table for subject. ISBNTitlePagesPublisher 0-07-295886-3Database System Concepts1142McGraw-Hill 0-07-240500-7The Ultimate Guide445McGraw-Hill * Here we have the table for book.
6
Since the tables had separated in order to avoid redundancy, we also need to create new tables to connect each table so that their relationship between each table will remain unchanged. ISBNAuthor_ID 0-07-295886-31 0-07-240500-73 0-07-295886-32 0-07-240500-74 * Here we have the relationship between the book and the author. ISBNSubject_ID 0-07-295886-31 0-07-240500-72 * Here we have the relationship between the book and the subject.
7
Second Normal Form If each attribute A in a relation schema R meets one of the following criteria: It must be in first normal form. It is not partially dependent on a candidate key. Every non-key attribute is fully dependent on each candidate key of the relation. Second Normal Form (or 2NF) deals with redundancy of data in vertical columns.
8
Example of Second Normal Form: Here is a list of attributes in a table that is in First Normal Form: Department Project_Name Employee_Name Emp_Hire_Date Project_Manager Project_Name and Employee_Name are the candidate key for this table. Emp_Hire_Date and Project_Manager are partially depend on the Employee_Name, but not depend on the Project_Name. Therefore, this table will not satisfy the Second Normal Form.
9
In order to satisfy the Second Normal Form, we need to put the Emp_Hire_Date and Project_Manager to other tables. We can put the Emp_Hire_Date to the Employee table and put the Project_Manager to the Project table. So now we have three tables: DepartmentProject Project_NameProject_ID Employee_NameProject_Name Project_Manager Employee Employee_ID Employee_Name Employee_Hire_Date Now, the Department table will only have the candidate key left.
10
Third Normal Form A relation R is in Third Normal Form (3NF) if and only if it is: in Second Normal Form. Every non-key attribute is non-transitively dependent on the primary key. An attribute C is transitively dependent on attribute A if there exists an attribute B such that A B and B C, then A C.
11
Example of Third Normal Form: Here is the Second Normal Form of the table for the invoice table: It violates the Third Normal Form because there will be redundancy for having multiple invoice number for the same customer. In this example, Jones had both invoice 1001 and 1003.
12
To solve the problem, we will have to have another table for the customers. By having Customer table, there will be no transitive relationship between the invoice number and the customer name and address. Also, there will not be redundancy on the customer information.
13
There will be more examples for the First, Second, and Third Normal Forms. The following is the example of a table that change from each of the normal forms.
14
First Normal Form: s# -- supplier identification number (this is the primary key) status -- status code assigned to city -- city name of city where supplier is located p# -- part number of part supplied qty -- quantity of parts supplied to date
15
Second Normal Form: Functional Dependency on First Normal Form: s# —> city, status (this violated the Second Normal Form) city —> status (s#,p#) —>qty
16
Third Normal Form: Functional Dependency of the Second Normal Form: SUPPLIER.s# —> SUPPLIER.status (Transitive dependency) SUPPLIER.s# —> SUPPLIER.city SUPPLIER.city —> SUPPLIER.status
17
Reference: http://www.utexas.edu/its/windows/database/datamodeling/rm/ rm7.html http://en.wikipedia.org/wiki/Database-normalization http://dev.mysql.com/tech-resources/articles/ intro-to-normalization.html http://www.cs.jcu.edu.au/Subjects/cp1500/1998/Lecture_Notes/ normalisation/2nf.html http://defiant.yk.psu.edu/~lxn/IST_210/ normal_form_definitions.html http://www.blueclaw-db.com/database_2nd_normal_form.htm http://www.troubleshooters.com/littstip/1tnom.html
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.