0
Upcoming SlideShare
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Standard text messaging rates apply

# D I T211 Chapter 6

2,257

Published on

Published in: Technology
1 Comment
1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
Views
Total Views
2,257
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
0
1
Likes
1
Embeds 0
No embeds

No notes for slide

### Transcript

• 1. CHAPTER 6 NORMALIZATION
• 2. NORMALIZATION
• 6.1 RELATIONAL DATA MODEL
• 6.1.1 What is relation?
• 6.1.2 A Notation of Relation
• 6.1.3 Problems in Relational Data Model
• 6.2 Normalization
• 6.2.1 Definition of Normalization
• 6.2.2 Purpose of Normalization
• 6.2.3 Level of Normalization
• 6.2.4 Steps in Normalization
• 3. OBJECTIVE
• Define relation and discuss its notation and relational schema.
• Recognize problems in designing relational data model.
• Define normalization and the relative level of normalization.
• Identify the steps in normalization.
• To normalize an un-normalized data model
• 4. RELATIONAL DATA MODEL
• Relation – A two dimensional table with columns and rows.
Table 6.1: Relational Table
• 5. NOTATION OF RELATION
• Relation Schema- list of attributes and their corresponding domains.
• Format:
Relation_Name (Primary_key, Non_Key_Attribute)
• 6. Relation Schema?
• 7.
• 8. Table 6-6 The BOOK Table ccccccc ccccccc No 80.00 Graphic M-G1 Graphic Design P08 44444 44444 No 88.00 Multimedia M-G1 Adobe Illustrator 10 P07 33333 33333 No 40.00 Pengetahuan Am F-B1 Pengajian Malaysia P06 22222 22222 No 69.00 Database T-H1 Database Processing P05 11111 11111 No 59.00 Database T-H1 Microsoft Access 2000 Complete P04 zzzzz zzzzz No 100.00 Database P-H1 Concepts of Database Management System P03 yyyyy yyyyy No 80.00 Database M-G1 Teach Yourself Microsoft Access 2000 Visually P02 xxxxx xxxxx Yes 76.00 Database M-G1 Access 2000 Processing P01 Book_Cover Book_ Sample Price Type Publisher_Code Book_Title Book_ Code
• 9. PROBLEM in RELATIONAL DATA MODEL
• There are 2 problem:
• 1. Anomalies
• 2. Information Redundancy
• 10. ANOMALIES
• Errors or inconsistencies when user update a table that contains redundant data.
• 3 types of anomalies:
• (i) Modification Anomalies
• (ii) Insert Anomalies
• (iii) Delete Anomalies
• 11. MODIFICATION ANOMALIES Table 6-7 STUDENT_COURSE Table Diploma in Computer Graphic and Design. DIPCGR Jalan Puchong Syed Ahmad Rizal B. Syed Abdul Razak S0035 Computer Power 200 (Graphic and Multimedia) CGMP200 Tmn. Melawati Aidil Akmar Hj. Ayob S0159 Computer power 100 (IT) CITP100 Tmn. Koperasi Polis Nurazean Bt. Md. Sobri S0157 Computer Power 200 (Graphic and Multimedia) CGMP200 Bandar Baru Bangi Amjadi Abd. Mubin S0149 Associate Diploma in Interactive Multimedia ASDIM Jln. Kg. Gajah Hamizah Mohamed Redzwan S0144 Course_Name Course_ Code Address Student_Name Student_ID
• 12. MODIFICATION ANOMALIES
• Problem?
• Changing the data of a record may causing changing the data of a few records.
• Solution?
• Separate STUDENT_COURSE table into TWO tables.
• 13.
• 14. INSERT ANOMALIES
• 15. INSERT ANOMALIES
• Problem?
• Confusing error in adding new record with null primary key may happen.
• Solution?
• Separate STUDENT_COURSE table into TWO tables.
• 16.
• 17. DELETE ANOMALIES
• 18. DELETE ANOMALIES
• Problem?
• Deletion of one record can cause the table provide insufficient information.
• Solution?
• Separate STUDENT_COURSE table into TWO tables.
• 19.
• 20. INFORMATION REDUNDANCIES
• Duplication because of storing the same data multiple times.
• 21.
• Problem?
• In the STUDENT_SUBJECT table there is redundant information. It shows that the details of subject ADM101 (Internet Publishing) are repeated for every member of Student_ID enrolled for that subject.
• Solution?
• Separate the STUDENT_SUBJECT table into THREE Tables.
INFORMATION REDUNDANCIES
• 22. INFORMATION REDUNDANCIES The STUDENT_SUBJECT Table The SUBJECT Table The STUDENT Table Jalan Puchong Syed Ahmad Rizal B. Syed Abdul Razak S0035 Tmn. Melawati Aidil Akmar Hj. Ayob S0159 Tmn. Koperasi Polis Norazean Bt Md Sobri S0157 Bandar Baru Bangi Amjadi Abd Mubin S0149 Jln. Kg. Gajah Hamizah Mohamed Redzwan S0144 Address Student_Name Student_ID ADM101 S0035 ADM301 S0159 ADM101 S0157 ADM101 S0149 ACT410 S0144 Subject _code Student_ID 4 Project ADM301 4 Internet Publishing ADM101 4 Computerized Accounting ACT410 Credit_hour Subject_name Subject_code
• 23. NORMALIZATION
• Definition - Process for assigning attributes into several tables to reduce data redudancy and help eliminate/remove data anomalies.
• Purpose –
• (i) To eliminate redundant data and data anomalies
• (ii) To ensure the correctness in data dependencies
• 24. NORMALIZATION
• Unnormalized Form (UNF) – table contains one or more repeating group.
• EX 1: Relation Schema? NF?
• 25. Relational Schema: STUDENT ( Stud_ID , Stud_Name, Address, Course_Code) Table 6‑20 The STUDENT Table (NF) Relational Schema: SUBJECT ( Subject_Code , Subject_Name, Credit_Hours) Table 6‑21 The SUBJECT Table (NF) Relational Schema: STUDENT_GRADE ( Student_ID , Subject_Code , Grade) Table 6‑22 The STUDENT_GRADE Table (NF) Relational Schema: COURSE ( Course_Code , Course_Name,Coordinator) Table 6‑23 The COURSE Table (NF) ADIM Shah Alam Maslina Yakub S0151 DCGD Shah Alam Amirul Hamdan S0144 DIT Sentul Azlina Ahmad S0001 Course_Code Address Stud_Name Stud_ID 4 Graphic Design Application ART210 4 Internet Publishing QDM101 4 Business Organization BUS210 2 Introduction to graphic Design ART230 4 Promotion Design ART410 4 Graphic Communication ART310 4 Computerized Accounting, ACT410 Credit_Hours Subject_Name Subject_Code A BUS210 S0151 A ART 210 S0151 C ART410 S0151 B BUS210 S0144 B ART230 S0144 A ART310 S0144 C ART210 S0001 B ADM101 S0001 A ACT410 S0001 Grade Subject_Code Student_ID Sahada Associate Diploma in Interactive Multimedia ADIM Ahmad Diploma in Computer Graphic Design DCGD Fazilah Diploma in Information Technology DIT Coordinator Course_Name Course_Code
• 26. NORMALIZATION
• EX 2: UNORMALIZAED FORM (UNF )
• 27. NORMALIZED FORM (NF) Relational Schema: CUSTOMER ( Cust_No , Cust_Name, Address) Table 6‑25 The CUSTOMER Table (NF) Relational Schema: INVOICE ( Cust_No , Item_Code , Qty) Table 6‑26 The INVOICE Table (NF) Relational Schema: ITEM ( Item_Code , Item_desc, Price, Supplier) Table 6‑27 The ITEM Table (NF) Relational Schema: SUPPLIER ( Supplier , Supplier_address) Table 6‑28 The SUPPLIER Table (NF) Ampang Rani A102 Ampang Salmah A101 Sentul Abu A100 Address Cust_Name Cust_No 4 2 2 MS112 CP200 VG400 A102 A102 A102 10 10 5 HD200 KB100 SP360 A101 A101 A101 10 10 5 HD200 KB100 SP360 A101 A101 A101 20 10 2 KB100 CP200 MS112 A100 A100 A100 Qty Item_Code Cust_No XYZ Ent. 200 VGA Card VG400 XYZ Ent. 650 CPU CP200 XYZ Ent. 45 Speaker SP360 XYZ Ent. 15 Mouse MS112 Seagate 100 Hard Disc HD200 XYZ Ent. 25 Keyboard KB100 Supplier Price Item_desc Item_Code Pulau Pinang Seagate Petaling Jaya XYZ Ent. Supplier_address Supplier
• 28. LEVEL OF NORMALIZATION No repeating groups of data in the table No partial functional dependancy No transitive dependancy
• 29. LEVEL OF NORMALIZATION
• First Normal Form (1NF)
• Data stored in a table that does not have any repeating groups.
• Second Normal Form (2NF)
• It is a relation that is in 1NF with every non primary key attribute fully functionally dependent on one primary key.
• The tables at this Normal Form do not have any partial functional dependency , if every non-primary key attributes are fully dependent on one primary key .
• Third Normal Form (3NF)
• It is a relation that has removed transitive dependency .
• A transitive dependency exists when you have the following functional dependency pattern for the relation: A->B, B->C therefore A->C. For a removed transitive dependency, it means that A should relate directly to B and to C, i.e. A->B and A->C.
• 30. STEPS IN NORMALIZATION
• Identify repeating group in UNF table.
• Create separate table for repeating group.
• Identify Functional Dependant relationship using technique what attributes depend on which Primary Key (PK).
• <PRIMARY KEY> <DEPENDANT
• ATTRIBUTE>
• Identify Transitive Dependency. A condition in which attributes are dependant on another attribute that is not a primary key.
• Remove the Transitive Dependancies
• 31. FUNCTIONAL DEPENDENCIES(FD)
• Definition: A functional dependency occurs when one attribute in a relation uniquely determines another attribute. This can be written (A -> B) means &quot;B is functionally dependent on A.“
StudentName can be uniquely determined from StudentID. The reverse statement is not true because more than one student can have the same name but different StudentID. (StudentName->StudentID) STUDENT( StudentID ,StudentName ) StudentName is functionally dependant on StudentID or (StudentID->StudentName). WHY?
• 32. TRANSITIVE DEPENDENCIES
• Definition : A transitive dependency exists when you have the following functional dependency pattern for the relation: A->B, B->C therefore A->C. For a removed transitive dependency, it means that A should relate directly to B and to C, i.e. A->B and A->C.
• Relation (Emp, Dept, Division)
• Employee is assigned to one dept and each dept is assigned to one division.
• FD Emp->Dept, Dept->Division
• :. Emp->Division is Transitive.
• 33. NORMALIZATION
• 1 STEP : REMOVE REPEATING GROUP
Repetitive group : Attributes that contains more than one value in each and every line. Sahada Rahman Associate Diploma in Interactive Multimedia Shah Alam C A A 4 4 4 ART410 ART 210 BUS210 Promotion Design Graphic Design Application Business Organisation Mazlina Yakub S0151 Ahmad Razak Diploma in Computer Graphic Design Shah Alam A B B 4 2 4 ART310 ART230 BUS210 Graphic Communication Introduction to graphic Design Business Organization Amirul Hamdan S0144 Fazilah Musa Diploma in Information Technology Sentul A B C 4 4 4 ACT410 ADM101 ART210 Computerised Accounting Internet Publishing Graphic Design Application Azlina Ahmad S0001 Coord inator Course Add. Grade Credit Hours Subject Code Subject Name Student Name Student ID
• 34. Relational Schema: STUDENT ( Student_ID , Student_Name , Subject_Code, Grade, Address, Course, Coordinator) Relational Schema: SUBJECT ( Subject_Code , Subject_Name, Credit_Hour) STUDENT SUBJECT Sahada Rahman Associate Diploma in Interactive Multimedia Shah Alam A BUS210 Mazlina Yakub S0151 Sahada Rahman Associate Diploma in Interactive Multimedia Shah Alam A ART 210 Mazlina Yakub S0151 Sahada Rahman Associate Diploma in Interactive Multimedia Shah Alam C ART410 Mazlina Yakub S0151 Ahmad Razak Diploma in Computer Graphic Design Shah Alam B BUS210 Amirul Hamdan S0144 Ahmad Razak Diploma in Computer Graphic Design Shah Alam B ART230 Amirul Hamdan S0144 Ahmad Razak Diploma in Computer Graphic Design Shah Alam A ART310 Amirul Hamdan S0144 Fazilah Musa Diploma in Information Technology Sentul C ART210 Azlina Ahmad S0001 Fazilah Musa Diploma in Information Technology Sentul B ADM101 Azlina Ahmad S0001 Fazilah Musa Diploma in Information Technology Sentul A ACT410 Azlina Ahmad S0001 Coordinator Course Address Grade Subject_Code Student_Name Student ID 4 Promotion Design ART410 4 Business Organization. BUS210 2 Introduction to graphic Design ART230 4 Graphic Communication ART310 4 Graphic Design Application ART210 4 Internet Publishing QDM101 4 Computerised Accounting ACT410 Credit_Hour Subject_Name Subject_Code
• 35. NORMALIZATION
• 2 STEP : Remove Partial Functional Dependencies
• Identify all possible Functional Dependencies.
• Create tables for the above dependencies.