Presentation is loading. Please wait.

Presentation is loading. Please wait.

Normalization Data Design - Mr. Ahmad Al-Ghoul

Similar presentations


Presentation on theme: "Normalization Data Design - Mr. Ahmad Al-Ghoul"— Presentation transcript:

1 Normalization Data Design - Mr. Ahmad Al-Ghoul
In this sequence we will study a normalization example

2 learning Objectives Explain the concept of normalization

3 A Normalization Example
The three steps of data normalization are Remove all repeating groups and identify the primary key Ensure that all nonkey attributes are fully dependent on the primary key Remove any transitive dependencies, attributes which are dependent on other nonkey attributes

4 A Normalization Example
To show the normalization process, consider the familiar situation which might depict several entities in a school advising system: ADVISOR, COURSE, and STUDENT The relationships among the three entities are shown in the ERD below [1]

5 A Normalization Example
In this example we will discuss the normalization rules for these three entities, to show how you can design a validate ERD Note that the relationship between student and course is many to many relationship (M:N) which can not create physically and as we said previously we must solve this problem by dividing this relationship to two one to many (1:M) relationship by adding a new entity called Associative entity the STUDENT table contains fields that relate to the ADVISOR and COURSE entities, so you can decide to begin with the initial design for the STUDENT table.

6 A Normalization Example
Unnormalized student table STUDENT (STUDENT-NUMBER, STUDENT-NAME, TOTAL-CREDITS, GPA, ADVISOR-NUMBER, ADVISOR-NAME, (COURSE-NUMBER, COURSE-DESC, NUM-CREDITS, GRADE)) Repeating groups The STUDENT table is unnormalized because it contains a repeating group that represents the courses each student has taken. [1]

7 A Normalization Example
1NF To convert the STUDENT record to 1NF, you must expand the primary key to include the key of the repeating group STUDENT (STUDENT-NUMBER, STUDENT-NAME, TOTAL-CREDITS, GPA, ADVISOR-NUMBER, ADVISOR-NAME, COURSE-NUMBER, COURSE-DESC, NUM-CREDITS, GRADE)

8 A Normalization Example
Choose data items UNF to 1NF Identify keys Split groups Eliminate repeating groups UNF 1NF level 1 2 STUDENT-NUMBER, STUDENT-NAME, TOTAL-CREDITS, GPA, ADVISOR-NUMBER, ADVISOR-NAME, COURSE-NUMBER, COURSE-DESC, NUM-CREDITS, GRADE STUDENT-NUMBER, STUDENT-NAME, TOTAL-CREDITS, GPA, ADVISOR-NUMBER, ADVISOR-NAME, COURSE-NUMBER, COURSE-DESC, NUM-CREDITS, GRADE

9 A Normalization Example
The STUDENT table in 1NF. Notice that the primary key has been expanded to include STUDENT-NUMBER and COURSE-NUMBER. Also, the repeating group has been eliminated. [1]

10 A Normalization Example
2NF No attribute dependent on a portion of a primary key The student name, total credits, GPA, advisor number, and advisor name all relate only to the student number The course description depends on the course number Grade field depends on the entire primary key

11 A Normalization Example
Does this attribute depend on the whole of the primary key? 1NF to 2NF 2NF 1NF STUDENT-NUMBER STUDENT-NAME TOTAL-CREDITS GPA ADVISOR-NUMBER ADVISOR-NAME COURSE-NUMBER COURSE-DESC NUM-CREDITS GRADE STUDENT-NUMBER, STUDENT-NAME, TOTAL-CREDITS, GPA, ADVISOR-NUMBER, ADVISOR-NAME, COURSE-NUMBER, COURSE-DESC, NUM-CREDITS, GRADE

12 A Normalization Example
You would create a new table for each field and combination of fields in the primary key STUDENT (STUDENT-NUMBER, STUDENT-NAME, TOTAL-CREDITS, GPA, ADVISOR-NUMBER, ADVISOR-NAME) COURSE (COURSE-NUMBER, COURSE-DESC, NUM-CREDITS) GRADE (STUDENT-NUMBER, COURSE-NUMBER, GRADE)

13 A Normalization Example
STUDENT, COURSE, and GRADE tables in 2NF. Notice that all fields are functionally dependent on the entire primary key of their respective tables. [1]

14 A Normalization Example
3NF Remove any transitive dependencies No attribute dependent on a nonkey attribute The COURSE and GREADE are in 3NF STUDENT is not in 3NF, because the ADVISOR-NAME field depends on the ADVISOR-NUMBER field, which is not part of the STUDENT primary key To convert STUDENT to 3NF, you remove the ADVISOR-NAME field from the STUDENT table and place it into a table with ADVISOR-NUMBER as the primary key

15 A Normalization Example
Is this attribute dependent on any other non-key attribute(s)? 2NF 3NF STUDENT-NUMBER STUDENT-NAME TOTAL-CREDITS GPA ADVISOR-NUMBER ADVISOR-NAME COURSE-NUMBER COURSE-DESC NUM-CREDITS GRADE STUDENT-NUMBER STUDENT-NAME TOTAL-CREDITS GPA ADVISOR-NUMBER ADVISOR-NAME COURSE-NUMBER COURSE-DESC NUM-CREDITS GRADE

16 A Normalization Example
3NF Table Names STUDENT-NUMBER STUDENT-NAME TOTAL-CREDITS GPA ADVISOR-NUMBER ADVISOR-NAME COURSE-NUMBER COURSE-DESC NUM-CREDITS GRADE STUDENT ADVISOR COURSE GRADE

17 A Normalization Example
3NF The final 3NF design is STUDENT (STUDENT-NUMBER, STUDENT-NAME, TOTAL-CREDITS, GPA, ADVISOR-NUMBER) ADVISOR (ADVISOR-NUMBER, ADVISOR-NAME) COURSE (COURSE-NUMBER, COURSE-DESC, NUM-CREDITS) GRADE (STUDENT-NUMBER, COURSE-NUMBER, GRADE)

18 A Normalization Example
ADVISOR STUDENT ADVISES RECEIVES is on COURSE SHOWS GRADE Associative entity The ERD for STUDENT, ADVISOR, and COURSE after normalization

19 A Normalization Example
Compare between the ERD before normalization and after After normalization we have four entitles: STUDENT, ADVISOR, COURSE, and GRADE, which is an associative entity You can see that (M:N) relationship between STUDENT and COURSE has been converted into two 1:M relationships One relationship between STUDENT and GRADE and the other relationship between COURSE and GRADE You should know that normal forms beyond 3NF exist, but they rarely are used in business-oriented systems

20 Sequence Summary 1NF 2NF 3NF All key attributes defined
No repeating groups in a table All attributes dependent on a primary key 2NF No attribute dependent on a portion of a primary key Attributes may be functionally dependent on nonkey attributes 3NF Remove any transitive dependencies No attribute dependent on a nonkey attribute

21 Sequence Summary In this Sequence we have
Explained the three steps of data normalization through an example

22 Reference [1] System Analysis and Design, Sixth Edition
Authors: Gary B. Shelly, Thomas J. Cashman and Harry J. Rosenblatt Publisher: SHELLY CASHMAN SEWIES.


Download ppt "Normalization Data Design - Mr. Ahmad Al-Ghoul"

Similar presentations


Ads by Google