Presentation is loading. Please wait.

Presentation is loading. Please wait.

ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah.

Similar presentations


Presentation on theme: "ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah."— Presentation transcript:

1 ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah | | | | A | ext:2561 | | CHAPTER 5 Normalization Of Database Tables (Part I: Concept & Process)

2 Chapter 5: Normalization Of Database Tables 5.0 Normalization Of Database Tables 5.1 Database Tables And Normalization 5.2 The Need For Normalization 5.3 The Normalization Process 5.4 Normalization And Database Design 5.5 Denormalization

3 Chapter 5: Normalization Of Database Tables 5.1 Database Tables And Normalization 3

4 4 In Chapter 4, ER Modeling, we have adopted a top-down approach to database design that begins by identifying the entities and relationship Normalization is a bottom-up approach to database design that begins by examining the relationships between attributes

5 Chapter 5: Normalization Of Database Tables 5.1 Database Tables And Normalization 5 Conceptual Model Entity Attribute Entity Attribute Top-downBottom-up { Normalization } { ER Modeling }

6 Chapter 5: Normalization Of Database Tables 5.1 Database Tables And Normalization 6 employeeNOnamepositionsalarybranchNO S21JohanManager3000B005 S37AnaAssistant1200B003 S14DaudSupervisor1800B003 S9MaryAssistant900B007 S5SitiManager2400B003 S41JaniAssistant900B005 branchNOcity B005Kepong B007Nilai B003PTP EMPLOYEE EMPLOYEE(employeeNO,name,position,salary,branchNO*) BRANCH BRANCH(branchNO,city) EMPLOYEE name salary city branchNO has M 1 BRANCH position employeeNO branchNO*

7 Chapter 5: Normalization Of Database Tables 5.2 The Need For Normalization 7 Normalization is typically used with ER Modeling There are two common situations in which database designers use normalization: i.Designing a new database When designing a new database structure based on the business requirements of the end users, the database designer will construct a data model using technique such as Crows Foot notation ERDs After the initial design is complete, the designer can used normalization to analyze the relationships that exist among the attributes within each entity, to determine if the structure can be improved through normalization

8 Chapter 5: Normalization Of Database Tables 5.2 The Need For Normalization 8 Normalization is typically used with ER Modeling There are two common situations in which database designers use normalization: ii.Modifying existing data structures Sometimes database designer are asked to modify existing data structures that can be in form of flat files, spreadsheet, or older database structures Normalization process can be used to analyze the relationship among the attributes or fields in the data structures, to improve the existing data structure in order to create an appropriate database design

9 Chapter 5: Normalization Of Database Tables 5.2 The Need For Normalization 9

10 Chapter 5: Normalization Of Database Tables 5.3 The Normalization Process 10

11 Chapter 5: Normalization Of Database Tables 5.3 The Normalization Process 11 The most commonly used normal forms: First Normal Form(1NF) Second Normal Form(2NF) Third Normal Form(3NF) 2NF is better than 1NF; 3NF is better than 2NF Highest normalization is not always desirable; joint vs redundancy For most business database design purposes, 3NF is as high as we need to go in normalization process

12 Chapter 5: Normalization Of Database Tables 5.3 The Normalization Process 12

13 Chapter 5: Normalization Of Database Tables 5.3 The Normalization Process 13 Data Redundancies 0NF/UNF1NF2NF3NF Normalization Denormalization

14 Chapter 5: Normalization Of Database Tables 5.3 The Normalization Process 14 Relationship between normalization form Denormalization Normalization Figure 1: Diagrammatic illustration of the relationship between the normal forms

15 Chapter 5: Normalization Of Database Tables 5.3 The Normalization Process 15 UsersUsers requirements specification Forms/reports that are used or generated by the enterprise Sources describing the enterprise such as data dictionary and corporate data model Unnormalized Form (UNF) First Normal Form (1NF) Second Normal Form (2NF) Third Normal Form (3NF) Transfer attributes into table format Remove repeating group Remove partial dependencies Remove transitive dependencies Data Sources

16 Chapter 5: Normalization Of Database Tables 5.3 The Normalization Process 2NF 3NF UNF 1)Repeat Group 2)PK is not defined 1NF 1)Remove Repeat Group 2)Defined PK composite PK consist of attributes Test for partial dependency If (exist) (1 Table) Test for transitive dependency If (exist) (1 or 2 Tables) (2 or 3 Tables) (more then 1 table) (3 or 4 Tables) (a b …. TD) 1 (a ……. TD) 2 (b ….… TD) 3 (a, b x, y) (a c, d) (b z) (c d) Normalization Process Relation/table Format -Have repeating group -PK not defined -No repeating group -PK defined -Test partial dependency -No repeating group -PK defined -No partial dependency -Test transitive dependency -No repeating group -PK defined -No partial dependency -No transitive dependency

17 Chapter 5: Normalization Of Database Tables 5.3 The Normalization Process 17

18 Chapter 5: Normalization Of Database Tables 5.3 The Normalization Process 18 Characteristic Of Functional Dependencies For the discussion on functional dependency, assume that a relational schema has attributes ( A,B,C,….Z ) and that the database is describe by a single universal relation called R=(A,B,C,…,Z). This assumption means that every attribute in the database has a unique name Functional dependencies: Describe the relationship between attributes in a relation. For example, if A and B are attributes of relation R, B is functionally dependent on A (denoted A B ), if each value of A is associated with exactly one value of B. ( A and B may each consist of one or more attributes.)

19 Chapter 5: Normalization Of Database Tables 5.3 The Normalization Process 19 Characteristic Of Functional Dependencies Consider a relation with attributes A and B, where attribute B is functionally dependent on attribute A To describe the relationship between attributes A and B is to say that A functionally determines B A B B is functionally dependent on A R(A,B) A B

20 Chapter 5: Normalization Of Database Tables 5.3 The Normalization Process 20 Characteristic Of Functional Dependencies When a functional dependency exist, the attribute or group of attributes on the left-handed side of the arrow is called determinant Determinant: Refers to the attribute, or a group of attributes, on the left handed side of the arrow of a functional dependency A B B is functionally dependent on A

21 Chapter 5: Normalization Of Database Tables 5.3 The Normalization Process 21 employeeNOnamepositionsalarybranchNO S21JohanManager3000B005 S37AnaAssistant1200B003 S14DaudSupervisor1800B003 S9MaryAssistant900B007 S5SitiManager2400B003 S41JaniAssistant900B005 branchNOcity B005Kepong B007Nilai B003PTP EMPLOYEE EMPLOYEE(employeeNO,name,position,salary,branchNO*) BRANCH BRANCH(branchNO,city) Characteristic Of Functional Dependencies

22 Chapter 5: Normalization Of Database Tables 5.3 The Normalization Process Unnormalized Form (UNF)/(0NF) A table that contains one or more repeating groups To create an unnormalized table – Transform the data from the information source (e.g. form) into table format with columns and rows

23 Chapter 5: Normalization Of Database Tables 5.3 The Normalization Process 23 Characteristic Of Functional Dependencies Consider the attributes employeeNO and position of the EMPLOYEE relation For a specific employeeNO(S21), we can determine the position of that member of employee as Manager employeeNO functionally determines position S21 Manager employeeNO position employeeNO functionally determines position

24 Chapter 5: Normalization Of Database Tables 5.3 The Normalization Process 24 Characteristic Of Functional Dependencies However the next figure illustrate that the opposite is not true, as position does not functionally determines employeeNO A member of employee holds one position; however, they maybe several members of employee with the same position position employeeNO position does not functionally determine emlpoyeeNO Manager S21 S5

25 Chapter 5: Normalization Of Database Tables 5.3 The Normalization Process 25 Characteristic Of Functional Dependencies Functional dependency can be describe by two types: – Full functional dependency (Partial dependency) Will be used to transform 1NF 2NF – Transitive dependency Will be used to transform 2NF 3NF

26 Chapter 5: Normalization Of Database Tables 5.3 The Normalization Process Characteristic Of Functional Dependencies Functional dependency can be describe by two types: – Full functional dependency (Partial dependency) Full functional dependency indicates that if A and B are attributes of a relation, B is fully functionally dependent on A, if B is functionally dependent on A, but not on any proper subset of A R(A,B,C) A B,C

27 Chapter 5: Normalization Of Database Tables 5.3 The Normalization Process Characteristic Of Functional Dependencies Functional dependency can be describe by two types: – Transitive dependency A, B and C are attributes of a relation such that if A B and B C, then C is transitively dependent on A through B (Provided that A is not functionally dependent on B or C ) R(A,B,C) A B B C

28 Chapter 5: Normalization Of Database Tables 5.3 The Normalization Process First Normal Form (1NF) A relation in which the intersection of each row and column contains one and only one value A relation is in 1NF if every attribute for every tuple have a value and domain for each attribute can not be simplified anymore

29 Chapter 5: Normalization Of Database Tables 5.3 The Normalization Process Second Normal Form (2NF) A relation that is in 1NF and every non-PK attribute is fully functionally depends on the PK Based on the concept of partial dependency (dependencies' based on only a part of composite PK) 2NF applies to relations with composite keys, that is, relations with PK composed of two or more attributes A relation with a single-attribute PK is automatically in at least 2NF

30 Chapter 5: Normalization Of Database Tables 5.3 The Normalization Process Third Normal Form (3NF) A relation that is in 1NF and 2NF and which no non-PK attribute is transitively dependent on the PK Based on the concept of transitive dependency, where; A, B and C are attributes of a relation such that if A B and B C then C is transitively dependent on A through B (Provided that A is not functionally dependent on B or C ) 3NF applies to relations with transitive dependency A relation that have no transitive dependency are already in 3NF

31 Chapter 5: Normalization Of Database Tables 5.3 The Normalization Process

32 1NF To 2NF Identify the primary key for the 1NF relation Identify the functional dependencies in the relation. Draw functional dependencies diagram Write functional dependencies in relational schema If partial dependencies exist on the primary key remove them by placing them in a new relation along with a copy of their determinant

33 Chapter 5: Normalization Of Database Tables 5.3 The Normalization Process 2NF To 3NF Identify the primary key in the 2NF relation Identify functional dependencies in the relation If transitive dependency exist on the PK, remove them by placing them in a new relation along with a copy of their determinant Guidelines: R (A, B, C) with transitive dependencies: A B B C Simplified R to: R1 (A, B*) R2 (B, C)

34 Chapter 5: Normalization Of Database Tables 5.4 Normalization & Database Design Normalization should be part of the design process. Make sure the proposed entities meet the required normal form before the table structures are created Be aware of good design principles and procedures as well as normalization procedures ERD: is created by interactive process, begin by identifying relevant entities, their attributes, and their relationship. ERD provides the big picture/macro view, of an organizations data requirements & operations. Normalization: focuses on the characteristics of specific entities: that is represents macro view of the entities within the ERD Therefore the two techniques are used in an iterative and incremental process

35 Chapter 5: Normalization Of Database Tables 5.5 Denormalization Data Redundancies 0NF/UNF1NF2NF3NF Normalization Denormalization


Download ppt "ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah."

Similar presentations


Ads by Google