Presentation is loading. Please wait.

Presentation is loading. Please wait.

DATA NORMALISATION Pamela Quick. Data Normalisation 2 Objectives  Data normalisation aims to derive record structures which avoid anomalies in u Insertion.

Similar presentations


Presentation on theme: "DATA NORMALISATION Pamela Quick. Data Normalisation 2 Objectives  Data normalisation aims to derive record structures which avoid anomalies in u Insertion."— Presentation transcript:

1 DATA NORMALISATION Pamela Quick

2 Data Normalisation 2 Objectives  Data normalisation aims to derive record structures which avoid anomalies in u Insertion u Deletion u Modification u Accessing v Data normalisation ensures single valuedness of facts u Facts are represented in fields in keyed records

3 Data Normalisation 3 The Process of Normalisation v Usually three steps (in industry) giving rise to u First Normal Form ( 1NF ) u Second Normal Form ( 2NF ) u Third Normal Form ( 3NF ) v In academia u Boyce -Codd Normal Form (BCNF) u Fourth Normal Form ( 4NF ) v At each step we consider relationships between an entity's attributes u These relationships are known as functional dependencies

4 Data Normalisation 4 Steps in Data Normalisation UNORMALISED ENTITY step1...remove repeating groups 1st NORMAL FORM step2...remove partial dependencies 2nd NORMAL FORM step3...remove indirect dependencies 3rd NORMAL FORM step4...remove multi-dependencies 4th NORMAL FORM step4..every determinate a key BOYCE-CODD NORMAL FORM

5 Data Normalisation 5 Attributes - Identifiers  An entity identifier uniquely determines an occurence on the entity vA Superkey - a combination of attributes that uniquely identify vWhen more than one identifier exists we have Candidate dentifiers (Keys) - minimal superkey vPrimary Key - designated SUPPLIER

6 Data Normalisation 6 Attributes - Repeating Groups vWhen a group of attributes has multiple values then we say there is a repeating group of attributes in the entity  (BRANCH_NAME, BRANCH_ADDRESS) is a repeating group

7 Data Normalisation 7 Functional Dependency vB is functionally dependent on A if a value of A uniquely determines a value of B

8 Data Normalisation 8 Functional Dependency v A -> B B is functionally dependent on A, A determines B u for all A that have the same value, have the same value of B v Functional Dependency is Trivial if satisfied by all tuples u ie A ->A u in general X -> Y is trivial if Y = X or is a subset v FDs are said to HOLD - when every possible attribute combination complies v FDs are said to be SATISFIED - when all stated attribute instances comply

9 Data Normalisation 9 More Examples of Functional Dependency

10 Data Normalisation 10 Example PURCHASE-ORDER(ORDER#, SUPPLIER#, ORDER-DATE DELIVERY-DATE, (PART#, PART-DESCRIPTION, QUANTITY-ORDERED, PRICE), TOTAL-PRICE)

11 Data Normalisation 11 First Normal Form v An entity type is in 1NF if there are no repeating groups of attribute types v Any un-normalised entity type is transformed to 1NF u Remove all repeating attribute groups u Repeating attribute groups become new entity types in their own right u The identifier of the original entity type must be an attribute (but not necessarily an identifier) of the derived entity type.

12 Data Normalisation 12 Example of First Normal Form PURCHASE-ORDER(ORDER#, SUPPLIER#, ORDER-DATE DELIVERY-DATE, (PART#, PART-DESCRIPTION, QUANTITY-ORDERED, PRICE), TOTAL-PRICE) UN-NORMALISED ENTITY TYPE

13 Data Normalisation 13 Example in 1NF PURCHASE-ORDER(ORDER#, SUPPLIER#, ORDER-DATE DELIVERY-DATE, TOTAL-PRICE) PURCHASE-ITEM-1( ORDER#, PART#, PART-DESCRIPTION, QUANTITY-ORDERED, PRICE) [NOTE: PART# ALONE DOES NOTE IDENTIFY PURCHASE-ITEM] ENTITY TYPES IN 1NF

14 Data Normalisation 14 Example STUDENT (Student#, student-name, student-address) ENROLMENT (Student#, Course#, course-title, tutor-name,tutor-staff#

15 Data Normalisation 15 Benefits from 1ST Normal Form v Any 'hidden' entities are identified v Process results in separation of different objects v BUT anomalies may still exist PURCHASE-ITEM-1( ORDER#, PART#, PART- DESCRIPTION,QUANTITY-ORDERED, PRICE) u PART-DESCRIPTION appears on every PURCHASE-ITEM occurence. u This may result in anomalies when updating or deleting records u The problem in the example is that PART-DESCRIPTION is functionally dependent only on PART# (part of the identifier)

16 Data Normalisation 16 Second Normal Form v An enity type is in 2NF if it is in 1NF and each non identifying attribute depends upon the whole identifier v Any enity type in 1NF is transformed to 2NF u Identify functional dependencies u Re-write entity types so that each non-identifying attribute is functionally dependent on the whole of the identifier

17 Data Normalisation 17 Example PURCHASE-ORDER(ORDER#, SUPPLIER#, ORDER-DATE DELIVERY-DATE, TOTAL-PRICE) PURCHASE-ITEM-1( ORDER#, PART#, PART-DESCRIPTION, QUANTITY-ORDERED, PRICE) ENTITY TYPES IN 1NF

18 Data Normalisation 18 Functional Dependencies PURCHASE-ORDER(ORDER#, SUPPLIER#, ORDER-DATE DELIVERY-DATE, TOTAL-PRICE) PURCHASE-ITEM-1( ORDER#, PART#, PART-DESCRIPTION, QUANTITY-ORDERED, PRICE)

19 Data Normalisation 19 In 2nd Normal Form v Decompose PURCHASE-ITEM into two entity types PURCHASE-ITEM (Order#, Part#, Quantity-Ordered, Price) PART (Part#, Part-Description) v Original enity type decomposed into three entity types in 2nd normal form PURCHASE-ORDER (Order#,Supplier#, Order-Date, Delivery-Date, Total-Price) PURCHASE-ITEM (Order#, Part#,Quantity-Ordered, Price) PART (Part#, Part-Description)

20 Data Normalisation 20 Example in 2NF STUDENT (Student#,Student-Name, Student-Adderss) ENROLMENT ( Student#, Course#, Tutor-Name, Tutor-Staff#) COURSE (Course#, Course-Title) ENTITY TYPES IN 2NF

21 Data Normalisation 21 Third normal Form v An enity type is in 3NF if it is in 2NF and all non identifying attributes are independent v Any enity type in 2NF is transformed in 3NF u Determine functional dependencies between non identifying attributes u Decompose enity into new entities

22 Data Normalisation 22 Example STUDENT (Student#,Student-Name, Student-Adderss) ENROLMENT ( Student#, Course#, Tutor-Name, Tutor-Staff#) COURSE (Course#,, Course-Title) ENTITY TYPES IN 2NF

23 Data Normalisation 23 Functional Dependencies STUDENT (Student#,Student-Name, Student-Adderss) ENROLMENT ( Student#, Course#, Tutor-Name, Tutor-Staff#) COURSE (Course#,, Course-Title)

24 Data Normalisation 24 Example in 3NF STUDENT (Student#,Student-Name, Student-Adderss) ENROLMENT ( Student#, Course#, Tutor-Staff#) COURSE (Course#,, Course-Title) TUTOR (Tutor-Staff#, Tutor-Name) ENTITY TYPES IN 3NF

25 Data Normalisation 25 Boyce-Codd Normal Form (BCNF) v A relation is in BCNF if every determinate is a candidate key v For a relation with only one candidate key, 3NF and BCNF are equivalent v Violation of BCNF is rare, may occur in a relation that : contains two (or more) composite candidate keys and which overlap, that is share at least one attribute in common

26 Data Normalisation 26 BCNF Client_no Interview Date Interview Time Staff_noRoom_no CR76 13-May-95 10.30SG5G101 CR5612.00SG5G101 CR74 12.00SG37G102 CR5610-Jun-9510.00SG5 G102 The following FDs hold : Client_No,Interview_Date ->Interview_time,Staff_no,Room_no Staff_no,Interview_Date,Interview_time -> Client_no Staff_no,Interview_date -> Room_no Client_no,Interview_date and Staff_no,Interview_date are composite candidate keys that share the common attribute Interview_date CLIENT_INTERVIEW

27 Data Normalisation 27 BCNF The relation CLIENT_INTERVIEW is in 3NF but not BCNF To transform to BCNF: Remove the violating FD and create two relations: INTERVIEW (Client_no, Interview_date, Interview_time, Staff_no STAFF_ROOM (Staff_no,Interview_date,Room_no)

28 Data Normalisation 28 Fourth Normal Form v An entity type is in 4NF if it is in 3NF and there are no multivalued dependencies between its attribute types v Any entity type in 3NF is transformed to 4NF u Detect any multivalued dependencies u Decompose entity type

29 Data Normalisation 29 AUTHOR_NO BOOK_NOSUBJECT BOOK_TITLE AUTHOR_NAME A1 A2 A3 B1 B2 Comp. Sc. Maths Comp. Sc. Maths Methods Method Methods Calculus Jones Smith Brown Multivalued Dependencies - 1 AUTHOR (Author_no, Author-name) BOOK (Book_no, Book-_title) AUTHOR-BOOK-SUBJECT (Author_no, Book_no, Subject) IN 3rd NORMAL FORM author_no book_no subject author_name book_title

30 Data Normalisation 30 Multivalued Dependencies - 2 vExample models that "each AUTHOR is associated with all the SUBJECTS under which the BOOK is classified" vThe attribute SUBJECT contains redundant values. If SUBJECT were deleted from rows 1 & 2 the values could be deduced from rows 3 & 4 Anomaly because the same set of SUBJECT is associated with each AUTHOR of the same BOOK AUTHOR_NO BOOK_NO SUBJECT B1 B2 Comp. Sc. Maths Comp. Sc. Maths A1 A2 A3

31 Data Normalisation 31 Fourth Normal Form AUTHOR (Author_no, Author_name) BOOK (Book_no, Book_Title) AUTHOR-BOOK (Author_no, Book_no) BOOK-SUBJECT (Book_no, Subject) IN 4th NORMAL FORM AUTHOR_NO BOOK_NO SUBJECT A1 A2 A3 B1 B2 Comp. Sc. Maths Comp. Sc. Maths AUTHOR_NO BOOK_NO A1 A2 A3 B1 B2 BOOK_NO SUBJECT B1 B2 Comp. Sc. Maths

32 Data Normalisation 32 Conclusions v Data Normalisation is a bottom-up technique that ensures the basic properties of the relational model u no duplicate tuples u no nested relations v Data normalisation is often used as the only technique for database design - implementation view v A more appropriate approach is to complement conceptual modelling with data normalisation


Download ppt "DATA NORMALISATION Pamela Quick. Data Normalisation 2 Objectives  Data normalisation aims to derive record structures which avoid anomalies in u Insertion."

Similar presentations


Ads by Google