Download presentation

Presentation is loading. Please wait.

Published bySarahi Rumrill Modified about 1 year ago

1
Team Dosen UMN Normalization Connolly Book Chapter 14-15

2
Team Dosen UMN Normalization What is Normalization? – Normalization is a technique for producing a set of relations with desirable properties, given the data requirements of an enterprise. The purpose of Normalization is to make a suitable set of relations to support data requirements of an enterprise. What is suitable set of relations? – Minimum redundancy – Attributes in a relation must have functional dependency – Minimum number of attribute

3
Team Dosen UMN Redundancy Redundancy in database happens when we copy the primary keys from a parent/strong entity to child/weak entity. If we copy more than the primary key, redundancy will make problems called update anomalies. Update anomalies consist of – Insertion anomalies. – Deletion anomalies. – and modification anomalies.

4
Team Dosen UMN Insertion Anomalies StudentsProdi Two types of insertion anomalies: Insert a relation must include the detail of other information Example: To insert Students data, we need the detail of Prodi Null is not allowable when inserting a relation Example: To insert Prodi, we need to insert Student Data first as Student Data is not null NIMNameAddressProdiKaprodi 001AldoEmerald C1 SerpongTIJacky 002BernardCrystal B1 SerpongSIWayan 003CameronAqua Marine T1 SerpongTIJacky 004DemiIllago R1 SerpongSIWayan 005EmmaCrystal B2 SerpongSIWayan ProdiKaprodi TIJacky SIWayan Prodi

5
Team Dosen UMN Deletion Anomalies StudentsProdi When we delete a tuple of a relation, the other information is also lost. Example: When we delete student=003, information about Prodi is also lost. NIMNameAddressProdiKaprodi 001AldoEmerald C1 SerpongTIJacky 002BernardCrystal B1 SerpongSIWayan 003CameronAqua Marine T1 SerpongTIJacky 004DemiIllago R1 SerpongSIWayan 005EmmaCrystal B2 SerpongSIWayan

6
Team Dosen UMN Modification Anomalies StudentsProdi When we try to update a value of an attribute, we need to update all tuples at the same attribute. Otherwise, the relation becomes inconsistency Example when we need to change the Kaprodi from Wayan to become Made, we need to change all Kaprodi=Wayan NIMNameAddressProdiKaprodi 001AldoEmerald C1 SerpongTIJacky 002BernardCrystal B1 SerpongSIWayan 003CameronAqua Marine T1 SerpongTIJacky 004DemiIllago R1 SerpongSIWayan 005EmmaCrystal B2 SerpongSIWayan

7
Team Dosen UMN Functional Dependencies Functional Dependency describes the relationship between attributes in relation. If A and B are attributes of a relation R, B is functionally dependent on A (denoted A B) if each value of A is associated with exactly one value of B. We can say A functionally determines B. Functional Dependencies can also include a set of attributes. If A,B,C, and D are attributes of a relation R, (C,D) is functionally dependent on (A,B), denoted (A,B) (C,D) if each value of (A,B) is associated with exactly one value of (C,D)

8
Team Dosen UMN Determinant and not determinant Determinant refers to the attribute, or group of attributes, on the left hand side of the arrow of a functional dependencies. If A B, the A is the Determinant. From determinant to another attribute, the relationship must be 1:1 since it must be associated wit exactly one value of that attribute. Example we can determine Name, Address, City from its NIM. NIM is the determinant. Relationship from NIM to Name is one to one. NIM Name. City does not functionally determine NIM as the relationship from City to NIM is one to many (Tangerang has more than one NIMs). City NIM x NIMNameAddressCity 001AldoEmerald C1 SerpongTangerang 002BernardCrystal B1Jakarta 003CameronAqua Marine T1 SerpongTangerang 004DemiIllago R1 SerpongTangerang 005EmmaCrystal B2 SerpongTangerang

9
Team Dosen UMN Type of Functional Dependency There are two types of functional dependency, which are full functional dependency and partial dependency. Full functional dependency indicates that if A,B, and C are attributes of a relation, C is fully functionally dependent on (A,B) if C functionally dependent on (A,B) but not on A and not on B. (A,B) C but A C and B C. Partial dependency indicates that if A,B, and C are attributes of a relation, C is partial dependent on combination of A and B, denoted (A,B), if C functionally dependent on (A,B) and C also functionally dependent on any A or B. (A,B) C but A C or B C. If A is a single attribute and A C then C full functional dependency on A because we can’t break down A into other attributes. xx

10
Team Dosen UMN Example of Functional Dependencies NIMNameAddressCityProdiKaprodi 001AldoEmerald C1 SerpongTangerangTIJacky 002BernardCrystal B1JakartaSIWayan 006CameronStudent DormitoryTangerangTIJacky 007JohnStudent DormitoryTangerangSIWayan 008JohnCrystal B2 SerpongTangerangSIWayan Combination of NIM and Name determines the Prodi. Thus, Prodi functionally dependent on (NIM,Name) noted (NIM,Name) Prodi. However, NIM also determines Prodi. Thus, NIM Prodi. In conclusion, Prodi has partial dependency on (NIM, Name). Prodi has a full functional dependency on combination of Name and Address as Not any of Name or Address determines Prodi but (Name,Address) Prodi. Prodi has full functional dependency on NIM.

11
Team Dosen UMN Transitive Dependency Transitive dependency is a condition where A, B, and C are attributes of a relation R such that A B and B C, then C is transitive dependency on A via B or A C. NIMNameAddressCityProdiKaprodi 001AldoEmerald C1 SerpongTangerangTIJacky 002BernardCrystal B1JakartaSIWayan 003CameronAqua Marine T1 SerpongTangerangTIJacky 004DemiIllago R1 SerpongTangerangSIWayan 005EmmaCrystal B2 SerpongTangerangSIWayan Example NIM Prodi and Prodi Kaprodi then NIM Kaprodi.

12
Team Dosen UMN Identifying Primary Key Using Functional Dependencies The main purpose of functional dependencies is to specify a set candidate key. From those candidate keys, we can identify one primary key. NIMNameAddressCityProdiKaprodi 001AldoEmerald C1 SerpongTangerangTIJacky 002BernardCrystal B1JakartaSIWayan 003Cameron Aqua Marine T1 SerpongTangerangTIJacky 004DemiIllago R1 SerpongTangerangSIWayan 005EmmaCrystal B2 SerpongTangerangSIWayan Four functional dependencies: – NIM Name, Address, City, Prodi and Kaprodi – Prodi Kaprodi – Kaprodi Prodi – (Name, Addres, City) NIM All attributes that are not part of primary key if functionally dependent on the key. As all attributes functionally dependent on NIM, then NIM is the primary key. NIM is chosen rather than (Name, Addres, City) as it more atomic. Prodi and Kaprodi are not candidate keys as their relationship to other attributes are 1:* StudentProdi

13
Team Dosen UMN Relationship between the normal forms

14
Team Dosen UMN Un-normalized Form (UNF) Definition: a table that contains one or more repeating groups. Repeating group refers to an attribute or a set of attribute in a table which occurs with multiple values for a single occurrences of nominated key attributes for that table. Key attribute is attribute(s) that uniquely identify each row within the un-normalized table. NIMNameAddressCityProdiKaprodiCourseCodeCourseNameLectureridLecturerName 001AldoEmerald C1 SerpongTangerangTIJackyTI403Database SystemL001Aryl TI405Oracle SQLL002Mayya TI407CiscoL003Tarrie 002BernardCrystal B1JakartaSIWayanTI403Database SystemL001Aryl SI401Data AnalysistL004Anank TI407CiscoL003Tarrie 003Cameron Aqua Marine T1 SerpongTangerangTIJackyTI403Database SystemL001Aryl TI405Oracle SQLL002Mayya TI407CiscoL003Tarrie 004DemiIllago R1 SerpongTangerangSIWayanTI403Database SystemL001Aryl SI401Data AnalysistL004Anank TI407CiscoL003Tarrie 005EmmaCrystal B2 SerpongTangerangSIWayanTI403Database SystemL001Aryl TI405Oracle SQLL002Mayya TI407CiscoL003Tarrie What is the key attribute for above table? What are the repeating groups?

15
Team Dosen UMN First Normal Form (1NF) Definition: a relation in which intersection of each row and column contains one and only one value. Transforming from UNF to 1NF: – Identify and remove repeating groups within a table – There are two common approach in removing repeating groups from un-normalized table: 1.By entering appropriate data in the empty columns of rows containing the repeating data (Flattening the table). 2.By placing the repeating data, along with a copy of original key attributes in a separate relation.

16
Team Dosen UMN Transform from UNF to 1NF Flattening the table: NIMNameAddressCityProdiKaprodiCourseCodeCourseNameLectureridLecturerName 001AldoEmerald C1 SerpongTangerangTIJackyTI403Database SystemL001Aryl 001AldoEmerald C1 SerpongTangerangTIJackyTI405Oracle SQLL002Mayya 001AldoEmerald C1 SerpongTangerangTIJackyTI407CiscoL003Tarrie 002BernardCrystal B1JakartaSIWayanTI403Database SystemL001Aryl 002BernardCrystal B1JakartaSIWayanSI401Data AnalysistL004Anank 002BernardCrystal B1JakartaSIWayanTI407CiscoL003Tarrie 003CameronAqua Marine T1 SerpongTangerangTIJackyTI403Database SystemL001Aryl 003CameronAqua Marine T1 SerpongTangerangTIJackyTI405Oracle SQLL002Mayya 003CameronAqua Marine T1 SerpongTangerangTIJackyTI407CiscoL003Tarrie 004DemiIllago R1 SerpongTangerangSIWayanTI403Database SystemL001Aryl 004DemiIllago R1 SerpongTangerangSIWayanSI401Data AnalysistL004Anank 004DemiIllago R1 SerpongTangerangSIWayanTI407CiscoL003Tarrie 005EmmaCrystal B2 SerpongTangerangSIWayanTI403Database SystemL001Aryl 005EmmaCrystal B2 SerpongTangerangTIJackyTI405Oracle SQLL002Mayya 005EmmaCrystal B2 SerpongTangerangSIWayanTI407CiscoL003Tarrie

17
Team Dosen UMN Transform from UNF to 1NF Making separate tables along with the key attribute (NIM): NIMNameAddressCityProdiKaprodi 001AldoEmerald C1 SerpongTangerangTIJacky 002BernardCrystal B1JakartaSIWayan 003CameronAqua Marine T1 SerpongTangerangTIJacky 004DemiIllago R1 SerpongTangerangSIWayan 005EmmaCrystal B2 SerpongTangerangSIWayan NIMCourseCodeCourseNameLectureridLecturerName 001TI403Database SystemL001Aryl 001TI405Oracle SQLL002Mayya 001TI407CiscoL003Tarrie 002TI403Database SystemL001Aryl 002SI401Data AnalysistL004Anank 002TI407CiscoL003Tarrie 003TI403Database SystemL001Aryl 003TI405Oracle SQLL002Mayya 003TI407CiscoL003Tarrie 004TI403Database SystemL001Aryl 004SI401Data AnalysistL004Anank 004TI407CiscoL003Tarrie 005TI403Database SystemL001Aryl 005TI405Oracle SQLL002Mayya 005TI407CiscoL003Tarrie

18
Team Dosen UMN Second Normal Form (2NF) Definition: A relation that is in the first normal form and every non- primary key attribute is fully functionally dependent on the primary key. Transforming 1NF to 2NF: – Identify partial dependent attributes – Remove all partial dependent attributes from the table in a new table along with copy of their determinant

19
Team Dosen UMN Transform from 1NF to 2NF Which attribute(s) is the primary key? Which attributes are partially dependent on the primary key? NIMNameAddressCityProdiKaprodi 001AldoEmerald C1 SerpongTangerangTIJacky 002BernardCrystal B1JakartaSIWayan 003CameronAqua Marine T1 SerpongTangerangTIJacky 004DemiIllago R1 SerpongTangerangSIWayan 005EmmaCrystal B2 SerpongTangerangSIWayan As NIM is a single attribute, all attributes are fully functional dependent on NIM.

20
Team Dosen UMN Transform from 1NF to 2NF Which attribute(s) is the primary key? Which attributes are partially dependent on the primary key? (NIM, CourseCode) all attributes (Primary Key) CourseCode CourseName (Partially Dependent) Is CourseCode LecturerId? NIMCourseCodeCourseNameLectureridLecturerName 001TI403Database SystemL001Aryl 001TI405Oracle SQLL002Mayya 001TI407CiscoL003Tarrie 002TI403Database SystemL001Aryl 002SI401Data AnalysistL004Anank 002TI407CiscoL003Tarrie 003TI403Database SystemL001Aryl 003TI405Oracle SQLL002Mayya 003TI407CiscoL003Tarrie 004TI403Database SystemL001Aryl 004SI401Data AnalysistL004Anank 004TI407CiscoL003Tarrie 005TI403Database SystemL001Aryl 005TI405Oracle SQLL002Mayya 005TI407CiscoL003Tarrie

21
Team Dosen UMN Transform from 1NF to 2NF CourseCodeCourseName SI401Data Analysist TI403Database System TI405Oracle SQL TI407Cisco NIMCourseCodeLectureridLecturerName 001TI403L001Aryl 001TI405L002Mayya 001TI407L003Tarrie 002SI401L004Anank 002TI403L001Aryl 002TI407L003Tarrie 003TI403L001Aryl 003TI405L002Mayya 003TI407L003Tarrie 004SI401L004Anank 004TI403L001Aryl 004TI407L003Tarrie 005TI403L001Aryl 005TI405L002Mayya 005TI407L003Tarrie

22
Team Dosen UMN Third Normal Form (3NF) Definition: A relation that is in first and second normal form and in which no non-primary-key attribute is transitive dependent on the primary key Transforming from 2NF to 3NF: – Remove all transitive dependencies by placing attributes in new table along with a copy of the determinant.

23
Team Dosen UMN Transforming 2NF to 3NF NIM Prodi but Prodi Kaprodi (Transitive Dependency) NIMNameAddressCityProdiKaprodi 001AldoEmerald C1 SerpongTangerangTIJacky 002BernardCrystal B1JakartaSIWayan 003CameronAqua Marine T1 SerpongTangerangTIJacky 004DemiIllago R1 SerpongTangerangSIWayan 005EmmaCrystal B2 SerpongTangerangSIWayan NIMNameAddressCityProdi 001AldoEmerald C1 SerpongTangerangTI 002BernardCrystal B1JakartaSI 003CameronAqua Marine T1 SerpongTangerangTI 004DemiIllago R1 SerpongTangerangSI 005EmmaCrystal B2 SerpongTangerangSI ProdiKaprodi SIWayan TIJacky

24
Team Dosen UMN Transform from 2NF to 3NF CourseCodeCourseName SI401Data Analysist TI403Database System TI405Oracle SQL TI407Cisco NIMCourseCodeLectureridLecturerName 001TI403L001Aryl 001TI405L002Mayya 001TI407L003Tarrie 002SI401L004Anank 002TI403L001Aryl 002TI407L003Tarrie 003TI403L001Aryl 003TI405L002Mayya 003TI407L003Tarrie 004SI401L004Anank 004TI403L001Aryl 004TI407L003Tarrie 005TI403L001Aryl 005TI405L002Mayya 005TI407L003Tarrie (NIM,CourseCode) LecturerId, but LecturerId LecturerName (Transitive Dependency)

25
Team Dosen UMN Transform from 2NF to 3NF CourseCodeCourseName SI401Data Analysist TI403Database System TI405Oracle SQL TI407Cisco LectureridLecturerName L001Aryl L002Mayya L003Tarrie L004Anank NIMCourseCodeLecturerid 001TI403L TI405L TI407L SI401L TI403L TI407L TI403L TI405L TI407L SI401L TI403L TI407L TI403L TI405L TI407L003

26
Team Dosen UMN Result from UNF to 3NF CourseCodeCourseName SI401Data Analysist TI403Database System TI405Oracle SQL TI407Cisco LectureridLecturerName L001Aryl L002Mayya L003Tarrie L004Anank NIMCourseCodeLecturerid 001TI403L TI405L TI407L SI401L TI403L TI407L TI403L TI405L TI407L SI401L TI403L TI407L TI403L TI405L TI407L003 NIMNameAddressCityProdi 001AldoEmerald C1 SerpongTangerangTI 002BernardCrystal B1JakartaSI 003CameronAqua Marine T1 SerpongTangerangTI 004DemiIllago R1 SerpongTangerangSI 005EmmaCrystal B2 SerpongTangerangSI ProdiKaprodi SIWayan TIJacky

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google