1 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Normalisation 5.

Slides:



Advertisements
Similar presentations
Requirements Engineering Processes – 2
Advertisements

Applications Computational LogicLecture 11 Michael Genesereth Spring 2004.
Feichter_DPG-SYKL03_Bild-01. Feichter_DPG-SYKL03_Bild-02.
© 2008 Pearson Addison Wesley. All rights reserved Chapter Seven Costs.
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
Chapter 1 The Study of Body Function Image PowerPoint
Copyright © 2011, Elsevier Inc. All rights reserved. Chapter 6 Author: Julia Richards and R. Scott Hawley.
Author: Julia Richards and R. Scott Hawley
1 Copyright © 2013 Elsevier Inc. All rights reserved. Appendix 01.
Properties Use, share, or modify this drill on mathematic properties. There is too much material for a single class, so you’ll have to select for your.
UNITED NATIONS Shipment Details Report – January 2006.
By John E. Hopcroft, Rajeev Motwani and Jeffrey D. Ullman
1 RA I Sub-Regional Training Seminar on CLIMAT&CLIMAT TEMP Reporting Casablanca, Morocco, 20 – 22 December 2005 Status of observing programmes in RA I.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Properties of Real Numbers CommutativeAssociativeDistributive Identity + × Inverse + ×
FACTORING ax2 + bx + c Think “unfoil” Work down, Show all steps.
Year 6 mental test 10 second questions
Fourth normal form: 4NF 1. 2 Normal forms desirable forms for relations in DB design eliminate redundancies avoid update anomalies enforce integrity constraints.
5NF and other normal forms
Functional dependencies 1. 2 Outline motivation: update anomalies cause: not expressed constraints on data (FDs) functional dependencies (FDs) definitions.
Relational data integrity
Dependency preservation, 3NF revisited and BCNF
Normal forms - 1NF, 2NF and 3NF
1 Term 2, 2004, Lecture 5, Physical DesignMarian Ursu, Department of Computing, Goldsmiths College Physical Design 3.
1 Term 2, 2004, Lecture 2, Normalisation - IntroductionMarian Ursu, Department of Computing, Goldsmiths College Normalisation Introduction.
1 Term 2, 2004, Lecture 6, TransactionsMarian Ursu, Department of Computing, Goldsmiths College Transactions 3.
1 Term 2, 2004, Lecture 6, Views and SecurityMarian Ursu, Department of Computing, Goldsmiths College Views and Security 3.
1 Term 2, 2007, Lectures 2/3, NormalisationD. Tidhar (based on M. Ursu) Department of Computing, Goldsmiths College Normalisation 5.
Lecture 7 Enhanced Entity-Relationship Modelling & Advanced Normalisation.
1 Discreteness and the Welfare Cost of Labour Supply Tax Distortions Keshab Bhattarai University of Hull and John Whalley Universities of Warwick and Western.
CS 319: Theory of Databases
Dr. Alexandra I. Cristea CS 319: Theory of Databases: C3.
REVIEW: Arthropod ID. 1. Name the subphylum. 2. Name the subphylum. 3. Name the order.
Randomized Algorithms Randomized Algorithms CS648 1.
EU market situation for eggs and poultry Management Committee 20 October 2011.
EU Market Situation for Eggs and Poultry Management Committee 21 June 2012.
Normalization of Database Tables
XML and Databases Exercise Session 3 (courtesy of Ghislain Fourny/ETH)
2 |SharePoint Saturday New York City
IP Multicast Information management 2 Groep T Leuven – Information department 2/14 Agenda •Why IP Multicast ? •Multicast fundamentals •Intradomain.
VOORBLAD.
Name Convolutional codes Tomashevich Victor. Name- 2 - Introduction Convolutional codes map information to code bits sequentially by convolving a sequence.
Factor P 16 8(8-5ab) 4(d² + 4) 3rs(2r – s) 15cd(1 + 2cd) 8(4a² + 3b²)
Basel-ICU-Journal Challenge18/20/ Basel-ICU-Journal Challenge8/20/2014.
1..
CONTROL VISION Set-up. Step 1 Step 2 Step 3 Step 5 Step 4.
© 2012 National Heart Foundation of Australia. Slide 2.
Understanding Generalist Practice, 5e, Kirst-Ashman/Hull
6.4 Best Approximation; Least Squares
Functional Dependencies and Normalization for Relational Databases
Model and Relationships 6 M 1 M M M M M M M M M M M M M M M M
25 seconds left…...
Januar MDMDFSSMDMDFSSS
Analyzing Genes and Genomes
Systems Analysis and Design in a Changing World, Fifth Edition
©Brooks/Cole, 2001 Chapter 12 Derived Types-- Enumerated, Structure and Union.
Essential Cell Biology
Intracellular Compartments and Transport
PSSA Preparation.
Essential Cell Biology
Immunobiology: The Immune System in Health & Disease Sixth Edition
1 Chapter 13 Nuclear Magnetic Resonance Spectroscopy.
Energy Generation in Mitochondria and Chlorplasts
Normalisation to 3NF Database Systems Lecture 11 Natasha Alechina.
Database Design Dr. M.E. Fayad, Professor
Fourth normal form: 4NF.
Database Design Dr. M.E. Fayad, Professor
Presentation transcript:

1 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Normalisation 5

2 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Outline Boyce-Codd Normal Form (BCNF) normalisation non-loss decomposition Heaths theorem normalisation process semantic assumptions and FDs CKs decomposition normalisation vs dependency preservation a decomposition may yield to a better solution than another one either-or situations: normalise or preserve FDs

3 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College 1

4 2NF and 3NF optional 2NF a relation is in 2NF if and only if it is in 1NF and all non-key attributes are irreducibly dependent on the candidate keys 3NF (Zaniolo) R is a relation; X is any set of attributes of R; A is any single attribute of R; consider the following conditions: –X contains A –X contains a candidate key of R –A is contained in a candidate key of R if either of the three is true for every FD X A then R is in 3NF

5 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College BCNF a relation is in Boyce/Codd normal form (BCNF) if and only if every non-trivial irreducible FD has a candidate key as its determinant informally the determinant of each relevant FD is a CK

6 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Example devise examples in class relations in BCNF relations not in BCNF

7 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College BCNF any relation can be non-loss decomposed into an equivalent set of BCNF relations BCNF 3NF 2NF 1NF BCNF is still not guaranteed to be free of any update anomalies

8 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College 2

9 Normalisation the process of transforming a relation with redundancies into an equivalent set of relations that have less redundancies transformation projection input :: one relation, say R output :: many relations, say R 1, …, R n equivalent non-loss decomposition R 1 join R 2 … join R n = R R 1, …, R n should have normal forms higher than or equal to that of R

10 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Non-loss decomposition (Patient, Symptom, Doctor, Office, Diagnosis) semantic assumptions exercise

11 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Lossy Decomposition (Patient, Symptom, Doctor, Office, Diagnosis) semantic assumptions exercise

12 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Heaths theorem can be used as the basis for normalisation theorem suppose R = (A, B, C), where A, B and C are disjoint sets of attributes A B then R = (A, B) join (A, C) state in English

13 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Normalisation – rules of thumb take as basis for normalisation/Heaths theorem a problem FD maximise B when applying Heaths theorem, on the basis of A B try to maintain a one-to-one correspondence with real life entities

14 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Normalisation steps semantic assumptions FDs CKs decomposition

15 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Simple example (M_id, M_name, Type, Value) M_id M_name M_id Type M_id Value Type Value not BCNF Heaths theorem for Type Value results (Type, Value) (M_id, M_name, Type) both relations are now in BCNF

16 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College 3

17 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Example (R) (project, task, max-budget, duration, payment-rate, contractor, contr-time) FDs: (project, task) max_budget, duration (task, max_budget, duration) payment_rate (project, task, contractor) contr_time (project, task, max-budget, duration, payment-rate, contractor, contr-time)

18 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Example – decomposition for R Heaths theorem for R (the initial relation) based on task, max_budget, duration payment_rate leads to: R 1 (task, max_budget, duration, payment_rate) R 2 (project, task, max_budget, duration, contractor, contr_time) R 1 is in BCNF R 2 is not in BCNF, due to project, task max_budget, duration

19 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Example – decomposition for R 2 Heaths theorem for R 2, based on project, task max_budget, duration leads to R 21 (project, task, max_budget, duration) R 22 (project, task, contractor, contracted_time) R 21 is in BCNF R 22 is in BCNF

20 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Example – solution (task, max_budget, duration, payment_rate) (project, task, max_budget, duration) (project, task, contractor, contracted_time)

21 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College 4

22 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Decomposition – 2 or more solutions in the normalisation process, it may be possible that a certain (non-loss) decomposition yields to a better solution than another one

23 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Decomposition – 2 solutions – example Modules(M_id, M_name, Type, Value) solution #1 Modules_Descr(M_id, M_name, Type) Type_Val(Type, Val) solution #2 Modules_Descr(M_id, M_name, Type) Module_Val(M_id, Val) are they both non-loss? (apply Heaths theorem) is there one better than the other?

24 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Solution #1 vs Solution #2 updates u1: insert the fact that a 3 semester module is worth 1.5cu u2: modify 1 semester modules; they are not worth 0.5cu any longer, they are 0.75cu u3: change the type of a module but forget to change its value solution #2 u1 and u2 are impossible or very difficult to perform u3 is allowed solution #1 u1 and u2 are straightforward u3 is not allowed

25 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Solution #1 vs Solution #2 solution #1 more expressive certain facts cannot be expressed in solution #2; e.g. the value of a new type updates can be independently performed on the two component relations (i.e. all constraints are properly expressed) in solution #2: Type Value is lost, so this constraint must be enforced by the user by procedural code independent projections updates can be performed independently on each projection, without the danger of ending with inconsistent data

26 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Independent projections M-idTypeValue Solution #1Solution #2 M_name M-id Type M_name Type ValueM-id Type M_name M_id Value all direct : intra all transitive : inter one transitive : intra one direct : lost

27 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Independent projections - Risanen R 1 and R 2 are two projections of R; R 1 and R 2 are independent if and only if every FD in R is a logical consequence of the FDs in R 1 and R 2 the common attributes of R 1 and R 2 for a candidate key for at least one of R 1 or R 2 atomic relation cannot be decomposed into independent projections

28 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Dependency preservation R was decomposed (normalisation) into R 1, …, R n S - the set of FDs for R S 1, …, S n - the set of FDs for R 1, …, R n (each S i refers to only the attributes of R i ) S = S 1 … S n (usually, S S) the decomposition is dependency preserving if S + = S +

29 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College 5

30 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Normalisation vs dependency preservation there are cases when there is an either-or situation regarding the normalisation and the preserving of functional dependencies: either the relation is normalised and some FDs are lost or, some FDs are not lost (they are expressed in the original relation), but the relation is not in its higher normal form possible in this case, no solution is better than the other other criteria will have to be considered to judge better

31 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College a patient is treated by a single doctor for a certain disease each doctor only treats one kind of disease a doctor can treat more than one patient is this relation BCNF? can you identify update anomalies? consider also (Patient, Disease, Doctor, Treatment) with Patient, Disease Treatment Disease Doctor Patient Normalisation vs dependency preservation: Example

32 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Possible decompositions non-loss? (choose PKs) Heaths theorem (choose PKs)

33 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College BCNF vs dependency preservation and do not enforce a FD existing in the original specification, namely: e.g. a patient can be given two doctors that treat the same disease (the system will not disallow this); the constraint would have to be maintained by procedural code

34 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College BCNF vs dependency preservation not every FD is expressible through normalisation when the relation was in its original form (3NF) (Patient, Disease) Doctor was expressed a doctor could not be assigned to more than one patient-disease Doctor Disease was not expressed generated update anomalies in BCNF (decomposed) Doctor Disease was expressed (Patient, Disease) Doctor was not expressed generated update anomalies (refer to previous slide) this latter FD would not have been expressed even if the decomposition in all three 2-attribute relations had been considered

35 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College –

36 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Conclusions normal forms : formalisation of common sense art engineering possibility for automation; difficult, because of non- determinism (more than one choices at one step) BCNF always achievable not always free of update anomalies, because it cannot always express all the FDs existing in the problem there are higher normal forms (4NF, 5NF) defined on the basis of other concepts (not FDs)