Normalisation. Databases: Topic 4

Size: px
Start display at page:

Download "Normalisation. Databases: Topic 4"

Transcription

1 Normalisation Databases: Topic 4

2 Resources for this Topic Readings (text): - Chapter 3 Other Readings: - Chapple, M (n.d) Database Normalization Basics, Retrieved from - (2008) Normalization Example,

3 Topic Objectives This topic aims to introduce you to normalisation as an important process in relational database design. It addresses the following unit learning objectives: Demonstrate an understanding of database principles and theory, particularly those relating to the Relational Model Design a database, demonstrating practical skills in normalisation and data modelling In order to achieve the unit learning objectives, on successful completion of this topic, you should be able to: Define and explain the types of modification anomalies associated with redundant information in tables Explain the purpose of normalisation Identify functional dependencies among attributes Define, and use examples of as appropriate, the following terms: Partial functional dependency Transitive functional dependency Give definitions of the following: 1NF 2NF 3NF BCNF Be able to identify which normal form a given relation is in Normalise a given relation to a more appropriate normal form Discuss some limitations that may be associated with normalisation

4 Topic Outline Relational design guidelines Modification anomalies Insertion Deletion Update Functional dependencies Normal forms: 1NF, 2NF, 3NF, BCNF Limitations of the normalisation process

5 1. Relational Design Guidelines

6 Normalisation - Normalisation is a technique for producing a set of suitable relations that support the data requirements of an enterprise. - Characteristics of a suitable set of relations include: - the minimal number of attributes necessary to support the data requirements of the enterprise; - attributes with a close logical relationship are found in the same relation; - minimal redundancy with each attribute represented only once with the important exception of attributes that form all or part of foreign keys.

7 Why bother? - Bad/poor/suboptimal designs: - have negative impacts on the performance of the database - have negative impacts on the ability of the database to be used for decision making

8 Some high level design guidelines - Relations should be simple to understand - This means they should correspond to a single real-world concept - Relations should not have any update anomalies - Normalisation should remove these anomalies - Usually the database will contain several relations. Design should ensure that relations can be joined (to get information from more than one relation) without generating 'extra' records - This is done by ensuring that any joins will be made between the primary key of one relation and the foreign key of the other - Functional dependencies that exist in the original data should be preserved in the database design

9 2. Modification Anomalies

10 Modification Anomalies - Modification anomalies may arise when data in a relation containing redundant data are modified - They lead to inconsistency in the database: - Insertion anomalies - The need to enter more data than is required - Update anomalies - Not all instances of data update - Deletion anomalies - The unintentional deletion of data - GOOD DESIGN IS THE BEST WAY TO AVOID INCONSISTENCIES

11 Examples StudentID StudentName Address Unit Code Unit Title Offering Mark Bruce 1 Random Cres ICT218 Databases S Bruce 1 Random Cres ICT231 Systems Analysis and Design S Mary 46 The Mews ICT231 Systems Analysis and Design S Mary 46 The Mews ICT218 Databases S INSERTION ANOMALY: To insert a new unit in the example above, it is necessary to know a student and an offering of the unit. UPDATE ANOMALY: If we change Mary s address we need to change two rows DELETION ANOMALY: if we delete Bruce s enrolment in Databases in Semester 1, 2010, we lose all information regarding that offering.

12 Can you identify how anomalies could occur in this relation? StaffNum Name Position Salary SchoolNum School School Phone S21 Barry Brightwater School Dean MH47 Happiness x005 S37 Deloris Delight Lecturer LH53 Hopeless Causes x003 S14 Carrie Cumbersome Professor LH53 Hopeless Causes x003 S09 Albert Algorithm School Dean 9000 XS67 Low Self Esteem x007 S05 Edwina Elocution School Dean LH53 Hopeless Causes x003 S41 Frank Forensic Cleaner 9000 MH47 Happiness x005

13 Are those problems resolved? StaffNum Name Position Salary SchoolNum S21 Barry Brightwater School Dean MH47 S37 Deloris Delight Lecturer LH53 S14 Carrie Cumbersome Professor LH53 S09 Albert Algorithm School Dean 9000 XS67 S05 Edwina Elocution School Dean LH53 S41 Frank Forensic Cleaner 9000MH47 SchoolNum School School Phone MH47 Happiness x005 LH53 Hopeless Causes x003 XS67 Low Self Esteem x007

14 Decomposition of Relations - When decomposing relations in the normalisation process, two important facets of the original data must be preserved: - Lossless Join - Any instance of the original relation can be identified from the decomposed relations - Dependency Preservation - Any constraint on the original relation can be maintained by enforcing the constraint on each of the smaller relations

15 StaffNum Name Position Salary SchoolNum School School Phone S21 Barry Brightwater School Dean MH47 Happiness x005 S37 Deloris Delight Lecturer LH53 Hopeless Causes x003 S14 Carrie Cumbersome Professor LH53 Hopeless Causes x003 S09 Albert Algorithm School Dean 9000 XS67 Low Self Esteem x007 S05 Edwina Elocution School Dean LH53 Hopeless Causes x003 S41 Frank Forensic Cleaner 9000 MH47 Happiness x005 StaffNum Name Position Salary SchoolNum S21 Barry Brightwater School Dean MH47 S37 Deloris Delight Lecturer LH53 S14 Carrie Cumbersome Professor LH53 S09 Albert Algorithm School Dean 9000 XS67 S05 Edwina Elocution School Dean LH53 S41 Frank Forensic Cleaner 9000MH47 SchoolNum School School Phone MH47 Happiness x005 LH53 Hopeless Causes x003 XS67 Low Self Esteem x007 Do we have lossless-joins here?

16 3. Functional Dependencies

17 Functional Dependencies - Normalisation is a way of transforming an unsatisfactory relation schema (one with modification anomalies) into a 'better' design by reducing redundancy - A functional dependency is a relationship between attributes such that the value of one attribute can be found from the value of another

18 Why bother? - FDs represent information about the system we are modelling which should be preserved - Normal forms 1NF, 2NF, 3NF and BCNF are based on functional dependencies between the attributes in a relation (higher normal forms are based on other dependencies)

19 X à Y We can say that X determines Y if: - There exists at most one value of Y for every value of X - For example: we can say that student number determines date of birth as for each student number there is one and only one date of birth. - Can we say that student name determines student number?

20 Example: Consider the following relation: EMPLOYEE ( EmployeeID, Name, Address, DeptNo ) if the value of EmployeeID is known, the values of Name, Address and DeptNo can be found - in other words: Name, Address, DeptNo are functionally dependent on EmployeeID EmployeeID functionally determines Name, Address, DeptNo EmployeeID is called the determinant of the FD

21 Writing FDs We can write FDs as: EmployeeID Name, Address, DeptNo OR Name EmployeeID Address DeptNo (StudentNo, Unit, Semester, Year) Grade

22 Some rules about FD s - Reflexivity - If Y Í X, then X à Y - Augmentation - If X à Y, then XZ à YZ - Transitivity - If X à Y, and Y à Z, then X à Z - Decomposition - If X à YZ, then XàY and XàZ - Union - If X à Y, and X à Z, the X à YZ

23 Example: What functional dependencies can you identify in the following relation (assuming the data is representative)? List only the direct dependencies StudentID Name Course OfferingNo Semester Year Grade UnitCode Title S1 Kyle IT HD ICT231 Systems Analysis S1 Kyle IT D ICT208 BI T&T S2 Helen IT D ICT231 Systems Analysis S2 Helen IT C ICT218 Databases S2 Helen IT N ICT218 Databases

24 Example: What functional dependencies can you identify in the following relation (assuming the data is representative)? List only the direct dependencies StaffNum Name Position Salary SchoolNum School School Phone S21 Barry Brightwater School Dean MH47 Happiness x005 S37 Deloris Delight Lecturer LH53 Hopeless Causes x003 S14 Carrie Cumbersome Professor LH53 Hopeless Causes x003 S09 Albert Algorithm School Dean 9000 XS67 Low Self Esteem x007 S05 Edwina Elocution School Dean LH53 Hopeless Causes x003 S41 Frank Forensic Cleaner 9000 MH47 Happiness x005

25 Example: What functional dependencies can you identify in the following relation (assuming the data is representative)? List only the direct dependencies StaffNum Name Position Salary SchoolNum School School Phone S21 Barry Brightwater School Dean MH47 Happiness x005 S37 Deloris Delight Lecturer LH53 Hopeless Causes x003 S14 Carrie Cumbersome Professor LH53 Hopeless Causes x003 S09 Albert Algorithm School Dean 9000 XS67 Low Self Esteem x007 S05 Edwina Elocution School Dean LH53 Hopeless Causes x003 S41 Frank Forensic Cleaner 9000 MH47 Happiness x005

26 Example: What functional dependencies can you identify in the following relation (assuming the data is representative)? List only the direct dependencies StaffNum Name Position Salary SchoolNum School School Phone S21 Barry Brightwater School Dean MH47 Happiness x005 S37 Deloris Delight Lecturer LH53 Hopeless Causes x003 S14 Carrie Cumbersome Professor LH53 Hopeless Causes x003 S09 Albert Algorithm School Dean 9000 XS67 Low Self Esteem x007 S05 Edwina Elocution School Dean LH53 Hopeless Causes x003 S41 Frank Forensic Cleaner 9000 MH47 Happiness x005

27 FD s and PK s A primary key is simply a more restrictive type of FD - a FD in which the value of the determinant is unique eg. In the relation: EMP_DEPT (EmpID, Name, Address, DeptNo, DeptName) we have the FDs: EmpID Name, Address, DeptNo, DeptName DeptNo DeptName In any instance of EMP_DEPT the same DeptNo may occur many times, but the value for EmpID (the primary key) is unique

28 Deriving PK s from FD s If we do not know the candidate key(s) of a relation, they can be found: - From the semantics (meaning) of the relation - By examining the FDs that occur in the relation - we can use a dependency diagram to identify the minimum combination of attributes from which all others can be found

29 Example: What is the candidate key of this relation? SchoolNumàSchool, Phone StaffNum Name Position Salary SchoolNum School School Phone S21 Barry Brightwater School Dean MH47 Happiness x005 S37 Deloris Delight Lecturer LH53 Hopeless Causes x003 S14 Carrie Cumbersome Professor LH53 Hopeless Causes x003 S09 Albert Algorithm School Dean 9000 XS67 Low Self Esteem x007 S05 Edwina Elocution School Dean LH53 Hopeless Causes x003 S41 Frank Forensic Cleaner 9000 MH47 Happiness x005 Here, staffnum is the determinant Name, Position, salary and SchoolNum are determined by staffnum

30 Dependency Diagrams

31 4. Normal Forms

32 Normal Forms - As above, we are most interested in 1NF, 2NF, 3NF and BCNF - For practical purposes, we usually aim to have relations in 3NF or BCNF, although denormalisation can sometimes be necessary for performance reasons

33 1NF -- BCNF Each NF become progressively more restrictive the higher the NF; the definition of any NF includes the definition of the preceding NF - 1NF:All valid relations are in 1NF - 2NF:1NF PLUS no partial functional dependencies - 3NF:2NF PLUS no transitive functional dependencies - BCNF: 3NF PLUS all determinants are candidate keys

34 First Normal Form (1NF) - For a relation to be in 1NF, it needs to be a valid relation - No repeating groups or nesting in relations - This relation is NOT in 1NF (i.e., it is unnormalised) StudentID Name Course OfferingNo Semester Year Grade UnitCode Title S1 Kyle IT HD ICT231 Systems Analysis D ICT208 BI T&T S2 Helen IT D ICT231 Systems Analysis C ICT218 Databases N ICT218 Databases

35 Solution StudentID Name Course OfferingNo Semester Year Grade UnitCode Title S1 Kyle IT HD ICT231 Systems Analysis D ICT208 BI T&T S2 Helen IT D ICT231 Systems Analysis C ICT218 Databases N ICT218 Databases - Repeat StdID, Name and Course for each tuple StudentID Name Course OfferingNo Semester Year Grade UnitCode Title S1 Kyle IT HD ICT231 Systems Analysis S1 Kyle IT D ICT208 BI T&T S2 Helen IT D ICT231 Systems Analysis S2 Helen IT C ICT218 Databases S2 Helen IT N ICT218 Databases - Can you find examples of modification anomalies in this design?

36 Solution StudentID Name Course OfferingNo Semester Year Grade UnitCode Title S1 Kyle IT HD ICT231 Systems Analysis D ICT208 BI T&T S2 Helen IT D ICT231 Systems Analysis C ICT218 Databases N ICT218 Databases - Repeat StdID, Name and Course for each tuple StudentID Name Course OfferingNo Semester Year Grade UnitCode Title S1 Kyle IT HD ICT231 Systems Analysis S1 Kyle IT D ICT208 BI T&T S2 Helen IT D ICT231 Systems Analysis S2 Helen IT C ICT218 Databases } S2 Helen IT N ICT218 Databases Update Anomaly - Can you find examples of modification anomalies in this design?

37 Solution StudentID Name Course OfferingNo Semester Year Grade UnitCode Title S1 Kyle IT HD ICT231 Systems Analysis D ICT208 BI T&T S2 Helen IT D ICT231 Systems Analysis C ICT218 Databases N ICT218 Databases - Repeat StdID, Name and Course for each tuple StudentID Name Course OfferingNo Semester Year Grade UnitCode Title S1 Kyle IT HD ICT231 Systems Analysis S1 Kyle IT D ICT208 BI T&T S2 Helen IT D ICT231 Systems Analysis S2 Helen IT C ICT218 Databases S2 Helen IT N ICT218 Databases Insertion Anomaly Add student Jones: S3, Jones - Can you find examples of modification anomalies in this design?

38 Solution StudentID Name Course OfferingNo Semester Year Grade UnitCode Title S1 Kyle IT HD ICT231 Systems Analysis D ICT208 BI T&T S2 Helen IT D ICT231 Systems Analysis C ICT218 Databases N ICT218 Databases - Repeat StdID, Name and Course for each tuple StudentID Name Course OfferingNo Semester Year Grade UnitCode Title S1 Kyle IT HD ICT231 Systems Analysis S1 Kyle IT D ICT208 BI T&T S2 Helen IT D ICT231 Systems Analysis S2 Helen IT C ICT218 Databases S2 Helen IT N ICT218 Databases Insertion Anomaly Add unit ASAD: ICT353, SAD - Can you find examples of modification anomalies in this design?

39 Solution StudentID Name Course OfferingNo Semester Year Grade UnitCode Title S1 Kyle IT HD ICT231 Systems Analysis D ICT208 BI T&T S2 Helen IT D ICT231 Systems Analysis C ICT218 Databases N ICT218 Databases - Repeat StdID, Name and Course for each tuple StudentID Name Course OfferingNo Semester Year Grade UnitCode Title S1 Kyle IT HD ICT231 Systems Analysis S1 Kyle IT D ICT208 BI T&T S2 Helen IT D ICT231 Systems Analysis S2 Helen IT C ICT218 Databases S2 Helen IT N ICT218 Databases Deletion Anomaly - Can you find examples of modification anomalies in this design?

40 Second Normal Form (2NF) - A relation is in 2NF if: - It is in 1NF, AND - There are no partial functional dependencies - A partial functional dependency exists where a nonkey attribute is dependent on only part of the key, rather than the whole of the key

41 Partial Functional Dependencies - Given the relation below: - Where the PK is StudentID, OfferingNo - and the FD s are: - StudentID à Name, Course - OfferingNo à Semester, Year, UnitCode, Title - StudentID, OfferingNo à Grade StudentID Name Course OfferingNo Semester Year Grade UnitCode Title S1 Kyle IT HD ICT231 Systems Analysis S1 Kyle IT D ICT208 BI T&T S2 Helen IT D ICT231 Systems Analysis S2 Helen IT C ICT218 Databases S2 Helen IT N ICT218 Databases

42 Partial Functional Dependencies - Given the relation below: - Where the PK is StudentID, OfferingNo - and the FD s are: - StudentID à Name, Course [PFD] - OfferingNo à Semester, Year, UnitCode, Title [PFD] - StudentID, OfferingNo à Grade StudentID Name Course OfferingNo Semester Year Grade UnitCode Title S1 Kyle IT HD ICT231 Systems Analysis S1 Kyle IT D ICT208 BI T&T S2 Helen IT D ICT231 Systems Analysis S2 Helen IT C ICT218 Databases S2 Helen IT N ICT218 Databases

43 Modification Anomalies with PFD s - There are a number of anomalies that arise from the present design: - If we were to change the title of ICT218, then we would have to update the title for every offering of the unit - If we were to delete the only offering of unit ICT208, then we would lose all details of that unit - Could we insert a new unit into this table? StudentID Name Course OfferingNo Semester Year Grade UnitCode Title S1 Kyle IT HD ICT231 Systems Analysis S1 Kyle IT D ICT208 BI T&T S2 Helen IT D ICT231 Systems Analysis S2 Helen IT C ICT218 Databases S2 Helen IT N ICT218 Databases

44 Solution The solution (for the PFDs) is to create relations based on the FD s where the determinants are components of the primary key: Relation1 (StdID, Name, Course) Relation2 (OfferingNo, UnitCode, Title, Semester, Year) There is also a further functional dependency in the table on the previous slide: StdID, OfferingNo Grade As the determinant of this FD IS the PK it will form a third relation: Relation3 (OfferingNo, StdID, Grade)

45 So - Now each nonkey attribute is fully FD on the key of the relation it is in, so each relation is in at least 2NF - We have also eliminated the potential anomalies identified in the original relation.

46 Third Normal Form (3NF) - A relation is in 3NF IF: - It is in 2NF, and - there are no transitive functional dependencies (TFD s) - A TFD exists where a non-key attribute is determined by another non-key attribute

47 Example Relation1 (StdID, Name, Course) Relation2 (OfferingNo, Year, Semester, UnitCode, Title) Relation3 (StdID, OfferingNo, Grade) There is a transitive dependency in Relation2: OfferingNo UnitCode UnitCode Title The TD is OfferingNo à Title because Unit Code is a non-key attribute What kinds of anomalies are present in the current design? StudentID Name Course S1 Kyle IT S2 Helen IT OfferingNo Semester Year UnitCode Title ICT231 Systems Analysis ICT208 BI T&T ICT218 Databases ICT218 Databases StudentID OfferingNo Grade S HD S D S D S C S N

48 Example Relation1 (StdID, Name, Course) Relation2 (OfferingNo, Year, Semester, UnitCode, Title) Relation3 (StdID, OfferingNo, Grade) There is a transitive dependency in Relation2: OfferingNo UnitCode UnitCode Title The TD is OfferingNo à Title because Unit Code is a non-key attribute What kinds of anomalies are present in the current design? StudentID Name Course S1 Kyle IT S2 Helen IT OfferingNo Semester Year UnitCode Title ICT231 Systems Analysis ICT208 BI T&T ICT218 Databases ICT218 Databases StudentID OfferingNo Grade S HD S D S D S C S N

49 Solution To transform a relation in 2NF only to a set of relations each in at least 3NF, - Create a set of relations based on the full and non-transitive dependencies in the original: Relation2-1 (OfferingNo, Year, Semester, UnitCode) Relation2-2 (UnitCode, Title) - Now each attribute is fully and nontransitively dependent on the key of its relation, so each relation is in (at least) 3NF - Note that we can join the relations on the key and foreign key - Note too, that the original relation was about offerings AND units. The new relations are both about one thing only. OfferingNo Semester Year UnitCode ICT ICT ICT ICT218 UnitCode Title ICT231 Systems Analysis ICT208 BI T&T ICT218 Databases

50 Cheat Sheet Note: We have a compound primary key: AID,BID PFD TFD AID BID Cdata Edata Fdata Gdata 1 A xxx xxx xxx xxx 1 B xxx xxx xxx xxx 1 B xxx xxx xxx xxx

51 Examples Given the following relation and functional dependencies: 1. What is (are) the candidate key(s)? 2. Which NF is the relation in? 3. Convert the relation into a relation or set of relations in at least 3NF STUDENT (StudentNo, Name, PrimaryMajor, School) StudentNo à Name, PrimaryMajor PrimaryMajor à School

52 Examples Given the following relation and functional dependencies: 1. What is (are) the candidate key(s)? 2. Which NF is the relation in? 3. Convert the relation into a relation or set of relations in at least 3NF STUDENT (StudentNo, Name, PrimaryMajor, School) StudentNo à Name, PrimaryMajor PrimaryMajor à School

53 Examples Given the following relation and functional dependencies: 1. What is (are) the candidate key(s)? 2. Which NF is the relation in? 3. Convert the relation into a relation or set of relations in at least 3NF STUDENT (StudentNo, Name, PrimaryMajor, School) StudentNo à Name, PrimaryMajor PrimaryMajor à School

54 Examples Given the following relation and functional dependencies: 1.What is (are) the candidate key(s)? 2.Which NF is the relation in? 3.Convert the relation into a relation or set of relations in at least 3NF STUDENT (StudentNo, Name, PrimaryMajor, School) StudentNo à Name, PrimaryMajor PrimaryMajor à School 1NF?

55 Examples Given the following relation and functional dependencies: 1.What is (are) the candidate key(s)? 2.Which NF is the relation in? 3.Convert the relation into a relation or set of relations in at least 3NF STUDENT (StudentNo, Name, PrimaryMajor, School) StudentNo à Name, PrimaryMajor PrimaryMajor à School 1NF Yes, it is a valid relation.

56 Examples Given the following relation and functional dependencies: 1.What is (are) the candidate key(s)? 2.Which NF is the relation in? 3.Convert the relation into a relation or set of relations in at least 3NF STUDENT (StudentNo, Name, PrimaryMajor, School) StudentNo à Name, PrimaryMajor PrimaryMajor à School 1NF Yes, it is a valid relation. 2NF?

57 Examples Given the following relation and functional dependencies: 1.What is (are) the candidate key(s)? 2.Which NF is the relation in? 3.Convert the relation into a relation or set of relations in at least 3NF STUDENT (StudentNo, Name, PrimaryMajor, School) StudentNo à Name, PrimaryMajor PrimaryMajor à School 1NF Yes, it is a valid relation. 2NF Yes, no non-key attributes determine by partial key

58 Examples Given the following relation and functional dependencies: 1.What is (are) the candidate key(s)? 2.Which NF is the relation in? 3.Convert the relation into a relation or set of relations in at least 3NF STUDENT (StudentNo, Name, PrimaryMajor, School) StudentNo à Name, PrimaryMajor PrimaryMajor à School 1NF Yes, it is a valid relation. 2NF Yes, no non-key attributes determine by partial key 3NF?

59 Examples Given the following relation and functional dependencies: 1.What is (are) the candidate key(s)? 2.Which NF is the relation in? 3.Convert the relation into a relation or set of relations in at least 3NF STUDENT (StudentNo, Name, PrimaryMajor, School) StudentNo à Name, PrimaryMajor PrimaryMajor à School 1NF Yes, it is a valid relation. TFD 2NF Yes, no non-key attributes determine by partial key 3NF No, It is Transitive, a non-key determines a non-key

60 Examples Given the following relation and functional dependencies: 1. What is (are) the candidate key(s)? 2. Which NF is the relation in? 3. Convert the relation into a relation or set of relations in at least 3NF STUDENT (StudentNo, Name, PrimaryMajor, School) StudentNo à Name, PrimaryMajor PrimaryMajor à School SOLUTION: STUDENT (StudentNo, Name, PrimaryMajor) MAJOR (PrimaryMajor, School) TFD

61 Examples Given the following relation and functional dependencies: 1.What is (are) the candidate key(s)? 2.Which NF is the relation in? 3.Convert the relation into a relation or set of relations in at least 3NF ENROLS (StudentNo, Name, UnitCode, UnitName, Grade) StudentNo à Name UnitCode à UnitName StudentNo, UnitCode à Grade

62 Examples Given the following relation and functional dependencies: 1.What is (are) the candidate key(s)? 2.Which NF is the relation in? 3.Convert the relation into a relation or set of relations in at least 3NF ENROLS (StudentNo, Name, UnitCode, UnitName, Grade) StudentNo à Name UnitCode à UnitName StudentNo, UnitCode à Grade

63 Examples Given the following relation and functional dependencies: 1.What is (are) the candidate key(s)? 2.Which NF is the relation in? 3.Convert the relation into a relation or set of relations in at least 3NF ENROLS (StudentNo, Name, UnitCode, UnitName, Grade) StudentNo à Name UnitCode à UnitName StudentNo, UnitCode à Grade 1NF Yes, it is a valid relation.

64 Examples Given the following relation and functional dependencies: 1.What is (are) the candidate key(s)? 2.Which NF is the relation in? 3.Convert the relation into a relation or set of relations in at least 3NF PFD PFD ENROLS (StudentNo, Name, UnitCode, UnitName, Grade) StudentNo à Name UnitCode à UnitName StudentNo, UnitCode à Grade 1NF Yes, it is a valid relation. 2NF No, non-key attributes determine by partial key

65 Examples Given the following relation and functional dependencies: 1.What is (are) the candidate key(s)? 2.Which NF is the relation in? 3.Convert the relation into a relation or set of relations in at least 3NF PFD PFD ENROLS (StudentNo, Name, UnitCode, UnitName, Grade) SOLUTION STUDENTS (StudentNo, Name) UNITS (UnitCode, UnitName) ENROLS (StudentNo, UnitCode, Grade)

66 Examples Given the following relation and functional dependencies: 1.What is (are) the candidate key(s)? 2.Which NF is the relation in? 3.Convert the relation into a relation or set of relations in at least 3NF COORDINATES (UnitCode, Semester, Option, Coordinator) UnitCode, Semester, Option à Coordinator

67 Examples Given the following relation and functional dependencies: 1.What is (are) the candidate key(s)? 2.Which NF is the relation in? 3.Convert the relation into a relation or set of relations in at least 3NF COORDINATES (UnitCode, Semester, Option, Coordinator) UnitCode, Semester, Option à Coordinator

68 Examples Given the following relation and functional dependencies: 1.What is (are) the candidate key(s)? 2.Which NF is the relation in? 3.Convert the relation into a relation or set of relations in at least 3NF COORDINATES (UnitCode, Semester, Option, Coordinator) UnitCode, Semester, Option à Coordinator

69 Examples Given the following relation and functional dependencies: 1.What is (are) the candidate key(s)? 2.Which NF is the relation in? 3.Convert the relation into a relation or set of relations in at least 3NF COORDINATES (UnitCode, Semester, Option, Coordinator) UnitCode, Semester, Option à Coordinator 1NF Yes, it is a valid relation. 2NF Yes, no PFD, no non-key attributes determine by partial key 3NF Yes, no TFDs, no non-key determines a non-key

70 Examples Given the following relation and functional dependencies: 1. What is (are) the candidate key(s)? 2. Which NF is the relation in? 3. Convert the relation into a relation or set of relations in at least 3NF SHOP (ShopNo, ItemNo, Date, QtySold) Each shop sells a number of items on each day Shop No Item No Date S1 M2 3/10 4 S1 M3 3/10 4 S2 M2 3/10 2 S1 M2 4/10 7 Qty Sold

71 Examples Given the following relation and functional dependencies: 1. What is (are) the candidate key(s)? 2. Which NF is the relation in? 3. Convert the relation into a relation or set of relations in at least 3NF SHOP (ShopNo, ItemNo, Date, QtySold) Each shop sells a number of items on each day Shop No Item No Date S1 M2 3/10 4 S1 M3 3/10 4 S2 M2 3/10 2 S1 M2 4/10 7 Qty Sold

72 Examples Given the following relation and functional dependencies: 1. What is (are) the candidate key(s)? 2. Which NF is the relation in? 3. Convert the relation into a relation or set of relations in at least 3NF SHOP (ShopNo, ItemNo, Date, QtySold) Each shop sells a number of items on each day Shop No Item No Date S1 M2 3/10 4 S1 M3 3/10 4 S2 M2 3/10 2 S1 M2 4/10 7 Qty Sold

73 Examples Given the following relation and functional dependencies: 1. What is (are) the candidate key(s)? 2. Which NF is the relation in? 3. Convert the relation into a relation or set of relations in at least 3NF SHOP (ShopNo, ItemNo, Date, QtySold) Each shop sells a number of items on each day Shop No Item No Date S1 M2 3/10 4 S1 M3 3/10 4 S2 M2 3/10 2 S1 M2 4/10 7 1NF Yes, it is a valid relation. 2NF Yes, no PFD, no non-key attributes determine by partial key 3NF Yes, no TFDs, no non-key determines a non-key Qty Sold

74 Examples Given the following relation and functional dependencies: 1. What is (are) the candidate key(s)? 2. Which NF is the relation in? 3. Convert the relation into a relation or set of relations in at least 3NF APPLICATION (ApplicNo, Customer, CustAddress, DateApproved) Each loan application is by one customer but each customer may make many applications ApplicNo Customer Address Date Appr X97 JoeBlog Perth 2/3 X99 Vicki Sydney 3/3 Y72 JoeBlog Perth 3/3

75 Examples Given the following relation and functional dependencies: 1. What is (are) the candidate key(s)? 2. Which NF is the relation in? 3. Convert the relation into a relation or set of relations in at least 3NF APPLICATION (ApplicNo, Customer, CustAddress, DateApproved) Each loan application is by one customer but each customer may make many applications ApplicNo Customer Address Date Appr X97 JoeBlog Perth 2/3 X99 Vicki Sydney 3/3 Y72 JoeBlog Perth 3/3

76 Examples Given the following relation and functional dependencies: 1. What is (are) the candidate key(s)? 2. Which NF is the relation in? 3. Convert the relation into a relation or set of relations in at least 3NF APPLICATION (ApplicNo, Customer, CustAddress, DateApproved) Each loan application is by one customer but each customer may make many applications ApplicNo Customer Address Date Appr X97 JoeBlog Perth 2/3 X99 Vicki Sydney 3/3 Y72 JoeBlog Perth 3/3

77 Examples Given the following relation and functional dependencies: 1. What is (are) the candidate key(s)? 1NF Yes, it is a valid relation. 2NF Yes, no PFD, no non-key attributes determine by partial key 3NF No, there is a non-key determines a non-key 2. Which NF is the relation in? 3. Convert the relation into a relation or set of relations in at least 3NF APPLICATION (ApplicNo, Customer, CustAddress, DateApproved) Each loan application is by one customer but each customer may make many applications ApplicNo Customer Address Date Appr X97 JoeBlog Perth 2/3 X99 Vicki Sydney 3/3 Y72 JoeBlog Perth 3/3 TFD

78 Examples Part No Description Vendor Address UnitCost 1234 Logic Chip Fast Chips Perth Smart Chips Sydney Memory chip Fast Chips Perth 3.00 Quality Chips Sydney 2.00 Smart Chips Sydney 5.00 (a) Convert this table to a single relation (called PART-SUPPLIER) in first normal form. Illustrate the relation with the same sample data. (b) List the functional dependencies in PART-SUPPLIER and identify the candidate key(s). (c) Convert PART-SUPPLIER to a set of relations in at least third normal form.

79 Examples Part No Description Vendor Address UnitCost 1234 Logic Chip Fast Chips Perth Smart Chips Sydney Memory chip Fast Chips Perth NF NO! It is not a valid relation. Quality Chips Sydney 2.00 Smart Chips Sydney 5.00 (a) Convert this table to a single relation (called PART-SUPPLIER) in first normal form. Illustrate the relation with the same sample data. (b) List the functional dependencies in PART-SUPPLIER and identify the candidate key(s). (c) Convert PART-SUPPLIER to a set of relations in at least third normal form.

80 Examples Part No Description Vendor Address UnitCost 1234 Logic Chip Fast Chips Perth Logic Chip Smart Chips Sydney Memory chip Fast Chips Perth Memory chip Quality Chips Sydney Memory chip Smart Chips Sydney NF Fix it. (a) Convert this table to a single relation (called PART-SUPPLIER) in first normal form. Illustrate the relation with the same sample data. (b) List the functional dependencies in PART-SUPPLIER and identify the candidate key(s). (c) Convert PART-SUPPLIER to a set of relations in at least third normal form.

81 Examples Part No Description Vendor Address UnitCost 1234 Logic Chip Fast Chips Perth Logic Chip Smart Chips Sydney Memory chip Fast Chips Perth Memory chip Quality Chips Sydney Memory chip Smart Chips Sydney 5.00 (a) Convert this table to a single relation (called PART-SUPPLIER) in first normal form. Illustrate the relation with the same sample data. (b) List the functional dependencies in PART-SUPPLIER and identify the candidate key(s). (c) Convert PART-SUPPLIER to a set of relations in at least third normal form.

82 Examples Part No Description Vendor Address UnitCost 1234 Logic Chip Fast Chips Perth Logic Chip Smart Chips Sydney Memory chip Fast Chips Perth Memory chip Quality Chips Sydney Memory chip Smart Chips Sydney 5.00 (a) Convert this table to a single relation (called PART-SUPPLIER) in first normal form. Illustrate the relation with the same sample data. (b) List the functional dependencies in PART-SUPPLIER and identify the candidate key(s). (c) Convert PART-SUPPLIER to a set of relations in at least third normal form.

83 Examples Part No Description Vendor Address UnitCost 1234 Logic Chip Fast Chips Perth Logic Chip Smart Chips Sydney Memory chip Fast Chips Perth Memory chip Quality Chips Sydney Memory chip Smart Chips Sydney NF Yes, we fixed it. (a) Convert this table to a single relation (called PART-SUPPLIER) in first normal form. Illustrate the relation with the same sample data. (b) List the functional dependencies in PART-SUPPLIER and identify the candidate key(s). (c) Convert PART-SUPPLIER to a set of relations in at least third normal form.

84 Examples Part No Description Vendor Address UnitCost 1234 Logic Chip Fast Chips Perth Logic Chip Smart Chips Sydney Memory chip Fast Chips Perth Memory chip Quality Chips Sydney Memory chip Smart Chips Sydney NF Yes, we fixed it. (a) Convert this table to a single relation (called PART-SUPPLIER) in first normal 2NF form.? Illustrate the relation with the same sample data. (b) List the functional dependencies in PART-SUPPLIER and identify the candidate key(s). (c) Convert PART-SUPPLIER to a set of relations in at least third normal form.

85 Examples PFD PFD Part No Description Vendor Address UnitCost 1234 Logic Chip Fast Chips Perth Logic Chip Smart Chips Sydney Memory chip Fast Chips Perth Memory chip Quality Chips Sydney Memory chip Smart Chips Sydney NF Yes, we fixed it. (a) Convert this table to a single relation (called PART-SUPPLIER) in first normal 2NF form. No, we Illustrate have 2 the Partial relation Functional with the Dependencies same sample data. (b) List the functional dependencies in PART-SUPPLIER and identify the candidate key(s). (c) Convert PART-SUPPLIER to a set of relations in at least third normal form.

86 Examples PFD PFD Part No Description Vendor Address UnitCost 1234 Logic Chip Fast Chips Perth Logic Chip Smart Chips Sydney Memory chip Fast Chips Perth Memory chip Quality Chips Sydney Memory chip Smart Chips Sydney 5.00 SOLUTION (a) Convert this table to a single relation (called PART-SUPPLIER) in first normal PART form. (PartNo, Illustrate Description) the relation with the same sample data. (b) VENDOR List the functional (Vendor, Address) dependencies in PART-SUPPLIER and identify the candidate PART-SUPPLIER key(s). (PartNo, Vendor, UnitCost) (c) Convert PART-SUPPLIER to a set of relations in at least third normal form.

87 Higher Normal Forms 1NF, 2NF, and 3NF are based largely on functional dependencies Recall: A relation is in 1NF if there are no multi-valued (or nested) attributes A relation is in 2NF if it is in 1NF AND there exists no partial functional dependencies A relation is in 3NF if it is in 2NF AND there exists no transitive functional dependencies

88 BCNF - Boyce-Codd Normal Form (BCNF) - Redundancies can still exist in relations in 3NF - Consider the following relation: - STUDENT_ADVISOR (StudentID, AdvisorName, Major) - Where: -a student can have many majors -a staff member will only advise for one major -a major can have more than one staff member as advisor - There are two Functional Dependencies: StudentID, Major à AdvisorName AdvisorName à Major StudentID AdvisorName Major 654 Bill BIS 655 Bob GT 656 Hui Min CS 656 Mary GT 657 Shabnam CFISM 658 Bill BIS Is the relation in 3NF, and are there any anomalies?

89 Example In the relation below, we have part of the key being determined by a non-key attribute Part of the key (Major), determined by non-key attribute (AdvisorName)

90 BCNF Definition We can see from the previous slide that 3NF does not guarantee removal of all anomalies -BCNF is a stricter version of 3NF - A relation is in BCNF if: It is in 3NF, and Every determinant is a candidate key

91 Solution Are there any modification anomalies present now?

92 BCNF Formal Stuff: Note that: All relations in BCNF are in 3NF Most relations in 3NF are also in BCNF Only when there is a FD X à Y where Y is a key attribute X is not a key of the relation is the relation in 3NF but not BCNF eg.( A, B, C ) with FDs AB à C and C à B candidate keys areab, AC Relation is not in BCNF, because in C à B, B is a key attribute C is not a key

93 5. Some limitations of normalisation

94 A final word on normalisation Normalisation helps to create a 'good' design However, don't be obsessive about it: eg.(name, Street, Suburb, Postcode) is in 2NF Name Ò Street, Suburb Suburb Ò Postcode should it be converted to two 3NF relations?? Codd spoke of the Minimal meaningful unit Good design also takes into account processing requirements (more later) - in practice, creating more tables means more joins, so slower processing this is the tradeoff for avoiding redundancy Need to look at how the database will be used in practice when making decisions about denormalisation (later)

95 6. Revision Questions

96 Outline - Relational design guidelines - Update anomalies - Functional dependency - Normal forms: 1NF, 2NF, 3NF - Limitations of the normalisation process

97 Revision questions Now. -What are the types of update anomalies associated with redundant information in tables? -Why is normalisation done? -What does partial functional dependency mean? -What does transitive functional dependency mean? -Define: 1NF, 2NF, 3NF, BCNF -What limitations are there that may be associated with normalisation? Later. -Can you identify which normal form a given relation is in? -Can you normalise a given relation to a more appropriate normal form?

Informal Design Guidelines for Relational Databases

Informal Design Guidelines for Relational Databases Outline Informal Design Guidelines for Relational Databases Semantics of the Relation Attributes Redundant Information in Tuples and Update Anomalies Null Values in Tuples Spurious Tuples Functional Dependencies

More information

Chapter 10. Chapter Outline. Chapter Outline. Functional Dependencies and Normalization for Relational Databases

Chapter 10. Chapter Outline. Chapter Outline. Functional Dependencies and Normalization for Relational Databases Chapter 10 Functional Dependencies and Normalization for Relational Databases Chapter Outline 1 Informal Design Guidelines for Relational Databases 1.1Semantics of the Relation Attributes 1.2 Redundant

More information

Chapter 14. Database Design Theory: Introduction to Normalization Using Functional and Multivalued Dependencies

Chapter 14. Database Design Theory: Introduction to Normalization Using Functional and Multivalued Dependencies Chapter 14 Database Design Theory: Introduction to Normalization Using Functional and Multivalued Dependencies Copyright 2012 Ramez Elmasri and Shamkant B. Navathe Chapter Outline 1 Informal Design Guidelines

More information

This lecture. Databases -Normalization I. Repeating Data. Redundancy. This lecture introduces normal forms, decomposition and normalization.

This lecture. Databases -Normalization I. Repeating Data. Redundancy. This lecture introduces normal forms, decomposition and normalization. This lecture Databases -Normalization I This lecture introduces normal forms, decomposition and normalization (GF Royle 2006-8, N Spadaccini 2008) Databases - Normalization I 1 / 23 (GF Royle 2006-8, N

More information

Chapter 10. Normalization. Chapter Outline. Chapter Outline(contd.)

Chapter 10. Normalization. Chapter Outline. Chapter Outline(contd.) Chapter 10 Normalization Chapter Outline 1 Informal Design Guidelines for Relational Databases 1.1Semantics of the Relation Attributes 1.2 Redundant Information in Tuples and Update Anomalies 1.3 Null

More information

Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 10-2

Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 10-2 Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 10-2 Chapter Outline 1 Informal Design Guidelines for Relational Databases 1.1Semantics of the Relation Attributes 1.2 Redundant

More information

Lecture 11 - Chapter 8 Relational Database Design Part 1

Lecture 11 - Chapter 8 Relational Database Design Part 1 CMSC 461, Database Management Systems Spring 2018 Lecture 11 - Chapter 8 Relational Database Design Part 1 These slides are based on Database System Concepts 6th edition book and are a modified version

More information

Databases -Normalization I. (GF Royle, N Spadaccini ) Databases - Normalization I 1 / 24

Databases -Normalization I. (GF Royle, N Spadaccini ) Databases - Normalization I 1 / 24 Databases -Normalization I (GF Royle, N Spadaccini 2006-2010) Databases - Normalization I 1 / 24 This lecture This lecture introduces normal forms, decomposition and normalization. We will explore problems

More information

Functional Dependencies and Finding a Minimal Cover

Functional Dependencies and Finding a Minimal Cover Functional Dependencies and Finding a Minimal Cover Robert Soulé 1 Normalization An anomaly occurs in a database when you can update, insert, or delete data, and get undesired side-effects. These side

More information

Functional Dependencies and. Databases. 1 Informal Design Guidelines for Relational Databases. 4 General Normal Form Definitions (For Multiple Keys)

Functional Dependencies and. Databases. 1 Informal Design Guidelines for Relational Databases. 4 General Normal Form Definitions (For Multiple Keys) 1 / 13 1 Informal Design Guidelines for Relational Databases 1.1Semantics of the Relation Attributes 1.2 Redundant d Information in Tuples and Update Anomalies 1.3 Null Values in Tuples 1.4 Spurious Tuples

More information

Normalization. Murali Mani. What and Why Normalization? To remove potential redundancy in design

Normalization. Murali Mani. What and Why Normalization? To remove potential redundancy in design 1 Normalization What and Why Normalization? To remove potential redundancy in design Redundancy causes several anomalies: insert, delete and update Normalization uses concept of dependencies Functional

More information

ACS-2914 Normalization March 2009 NORMALIZATION 2. Ron McFadyen 1. Normalization 3. De-normalization 3

ACS-2914 Normalization March 2009 NORMALIZATION 2. Ron McFadyen 1. Normalization 3. De-normalization 3 NORMALIZATION 2 Normalization 3 De-normalization 3 Functional Dependencies 4 Generating functional dependency maps from database design maps 5 Anomalies 8 Partial Functional Dependencies 10 Transitive

More information

Relational Database design. Slides By: Shree Jaswal

Relational Database design. Slides By: Shree Jaswal Relational Database design Slides By: Shree Jaswal Topics: Design guidelines for relational schema, Functional Dependencies, Definition of Normal Forms- 1NF, 2NF, 3NF, BCNF, Converting Relational Schema

More information

Normalisation Chapter2 Contents

Normalisation Chapter2 Contents Contents Objective... 64 Superkey & Candidate Keys... 65 Primary, Alternate and Foreign Keys... 65 Functional Dependence... 67 Using Instances... 70 Normalisation Introduction... 70 Normalisation Problems...

More information

Lectures 12: Design Theory I. 1. Normal forms & functional dependencies 2/19/2018. Today s Lecture. What you will learn about in this section

Lectures 12: Design Theory I. 1. Normal forms & functional dependencies 2/19/2018. Today s Lecture. What you will learn about in this section Today s Lecture Lectures 12: Design Theory I Professor Xiannong Meng Spring 2018 Lecture and activity contents are based on what Prof Chris Ré used in his CS 145 in the fall 2016 term with permission 1.

More information

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Winter 2009 Lecture 4 - Schema Normalization

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Winter 2009 Lecture 4 - Schema Normalization CSE 544 Principles of Database Management Systems Magdalena Balazinska Winter 2009 Lecture 4 - Schema Normalization References R&G Book. Chapter 19: Schema refinement and normal forms Also relevant to

More information

NORMAL FORMS. CS121: Relational Databases Fall 2017 Lecture 18

NORMAL FORMS. CS121: Relational Databases Fall 2017 Lecture 18 NORMAL FORMS CS121: Relational Databases Fall 2017 Lecture 18 Equivalent Schemas 2 Many different schemas can represent a set of data Which one is best? What does best even mean? Main goals: Representation

More information

UNIT 3 DATABASE DESIGN

UNIT 3 DATABASE DESIGN UNIT 3 DATABASE DESIGN Objective To study design guidelines for relational databases. To know about Functional dependencies. To have an understanding on First, Second, Third Normal forms To study about

More information

In This Lecture. Normalisation to BCNF. Lossless decomposition. Normalisation so Far. Relational algebra reminder: product

In This Lecture. Normalisation to BCNF. Lossless decomposition. Normalisation so Far. Relational algebra reminder: product In This Lecture Normalisation to BCNF Database Systems Lecture 12 Natasha Alechina More normalisation Brief review of relational algebra Lossless decomposition Boyce-Codd normal form (BCNF) Higher normal

More information

CSE 562 Database Systems

CSE 562 Database Systems Goal CSE 562 Database Systems Question: The relational model is great, but how do I go about designing my database schema? Database Design Some slides are based or modified from originals by Magdalena

More information

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Fall 2009 Lecture 3 - Schema Normalization

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Fall 2009 Lecture 3 - Schema Normalization CSE 544 Principles of Database Management Systems Magdalena Balazinska Fall 2009 Lecture 3 - Schema Normalization References R&G Book. Chapter 19: Schema refinement and normal forms Also relevant to this

More information

Database Management System

Database Management System Database Management System Lecture 4 Database Design Normalization and View * Some materials adapted from R. Ramakrishnan, J. Gehrke and Shawn Bowers Today s Agenda Normalization View Database Management

More information

Functional Dependencies and Normalization for Relational Databases Design & Analysis of Database Systems

Functional Dependencies and Normalization for Relational Databases Design & Analysis of Database Systems Functional Dependencies and Normalization for Relational Databases 406.426 Design & Analysis of Database Systems Jonghun Park jonghun@snu.ac.kr Dept. of Industrial Engineering Seoul National University

More information

Schema Refinement: Dependencies and Normal Forms

Schema Refinement: Dependencies and Normal Forms Schema Refinement: Dependencies and Normal Forms Grant Weddell David R. Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Spring 2012 CS 348 (Intro to

More information

Normalisation. Normalisation. Normalisation

Normalisation. Normalisation. Normalisation Normalisation Normalisation Main objective in developing a logical data model for relational database systems is to create an accurate and efficient representation of the data, its relationships, and constraints

More information

Functional Dependencies & Normalization for Relational DBs. Truong Tuan Anh CSE-HCMUT

Functional Dependencies & Normalization for Relational DBs. Truong Tuan Anh CSE-HCMUT Functional Dependencies & Normalization for Relational DBs Truong Tuan Anh CSE-HCMUT 1 2 Contents 1 Introduction 2 Functional dependencies (FDs) 3 Normalization 4 Relational database schema design algorithms

More information

Unit 3 : Relational Database Design

Unit 3 : Relational Database Design Unit 3 : Relational Database Design Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Content Relational Model: Basic concepts, Attributes and Domains, CODD's Rules, Relational

More information

Database Design Theory and Normalization. CS 377: Database Systems

Database Design Theory and Normalization. CS 377: Database Systems Database Design Theory and Normalization CS 377: Database Systems Recap: What Has Been Covered Lectures 1-2: Database Overview & Concepts Lecture 4: Representational Model (Relational Model) & Mapping

More information

Schema Refinement: Dependencies and Normal Forms

Schema Refinement: Dependencies and Normal Forms Schema Refinement: Dependencies and Normal Forms Grant Weddell Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Spring 2016 CS 348 (Intro to DB Mgmt)

More information

Database Management System Prof. Partha Pratim Das Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Database Management System Prof. Partha Pratim Das Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Database Management System Prof. Partha Pratim Das Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Lecture - 19 Relational Database Design (Contd.) Welcome to module

More information

IS 263 Database Concepts

IS 263 Database Concepts IS 263 Database Concepts Lecture 4: Normalization Instructor: Henry Kalisti 1 Department of Computer Science and Engineering Limitations of E- R Designs Provides a set of guidelines, does not result in

More information

Chapter 8: Relational Database Design

Chapter 8: Relational Database Design Chapter 8: Relational Database Design Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 8: Relational Database Design Features of Good Relational Design Atomic Domains

More information

Edited by: Nada Alhirabi. Normalization

Edited by: Nada Alhirabi. Normalization Edited by: Nada Alhirabi Normalization Normalization:Why do we need to normalize? 1. To avoid redundancy (less storage space needed, and data is consistent) Ssn c-id Grade Name Address 123 cs331 A smith

More information

Mapping ER Diagrams to. Relations (Cont d) Mapping ER Diagrams to. Exercise. Relations. Mapping ER Diagrams to Relations (Cont d) Exercise

Mapping ER Diagrams to. Relations (Cont d) Mapping ER Diagrams to. Exercise. Relations. Mapping ER Diagrams to Relations (Cont d) Exercise CSC 74 Database Management Systems Topic #6: Database Design Weak Entity Type E Create a relation R Include all simple attributes and simple components of composite attributes. Include the primary key

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe CHAPTER 14 Basics of Functional Dependencies and Normalization for Relational Databases Slide 14-2 Chapter Outline 1 Informal Design Guidelines for Relational Databases 1.1 Semantics of the Relation Attributes

More information

Chapter 14 Outline. Normalization for Relational Databases: Outline. Chapter 14: Basics of Functional Dependencies and

Chapter 14 Outline. Normalization for Relational Databases: Outline. Chapter 14: Basics of Functional Dependencies and Ramez Elmasri, Shamkant B. Navathe(2016) Fundamentals of Database Systems (7th Edition), pearson, isbn 10: 0-13-397077-9;isbn-13:978-0-13-397077-7. Chapter 14: Basics of Functional Dependencies and Normalization

More information

Schema Refinement: Dependencies and Normal Forms

Schema Refinement: Dependencies and Normal Forms Schema Refinement: Dependencies and Normal Forms M. Tamer Özsu David R. Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Fall 2012 CS 348 Schema Refinement

More information

Relational Database Design (II)

Relational Database Design (II) Relational Database Design (II) 1 Roadmap of This Lecture Algorithms for Functional Dependencies (cont d) Decomposition Using Multi-valued Dependencies More Normal Form Database-Design Process Modeling

More information

COSC Dr. Ramon Lawrence. Emp Relation

COSC Dr. Ramon Lawrence. Emp Relation COSC 304 Introduction to Database Systems Normalization Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Normalization Normalization is a technique for producing relations

More information

The Relational Model and Normalization

The Relational Model and Normalization The Relational Model and Normalization 1. Introduction 2 2. Relational Model Terminology 3 4. Normal Forms 11 5. Multi-valued Dependency 21 6. The Fifth Normal Form 22 The Relational Model and Normalization

More information

Distributed Database Systems By Syed Bakhtawar Shah Abid Lecturer in Computer Science

Distributed Database Systems By Syed Bakhtawar Shah Abid Lecturer in Computer Science Distributed Database Systems By Syed Bakhtawar Shah Abid Lecturer in Computer Science 1 Distributed Database Systems Basic concepts and Definitions Data Collection of facts and figures concerning an object

More information

Normal Forms. Winter Lecture 19

Normal Forms. Winter Lecture 19 Normal Forms Winter 2006-2007 Lecture 19 Equivalent Schemas Many schemas can represent a set of data Which one is best? What does best even mean? Main goals: Representation must be complete Data should

More information

Normalization Rule. First Normal Form (1NF) Normalization rule are divided into following normal form. 1. First Normal Form. 2. Second Normal Form

Normalization Rule. First Normal Form (1NF) Normalization rule are divided into following normal form. 1. First Normal Form. 2. Second Normal Form Normalization Rule Normalization rule are divided into following normal form. 1. First Normal Form 2. Second Normal Form 3. Third Normal Form 4. BCNF First Normal Form (1NF) As per First Normal Form, no

More information

Unit- III (Functional dependencies and Normalization, Relational Data Model and Relational Algebra)

Unit- III (Functional dependencies and Normalization, Relational Data Model and Relational Algebra) Unit- III (Functional dependencies and Normalization, Relational Data Model and Relational Algebra) Important questions Section A :(2 Marks) 1.What is Functional Dependency? Functional dependency (FD)

More information

Redundancy:Dependencies between attributes within a relation cause redundancy.

Redundancy:Dependencies between attributes within a relation cause redundancy. Normalization Normalization: It is the process of removing redundant data from your tables in order to improve storage efficiency, data integrity and scalability. This improvement is balanced against an

More information

Chapter 14. Chapter 14 - Objectives. Purpose of Normalization. Purpose of Normalization

Chapter 14. Chapter 14 - Objectives. Purpose of Normalization. Purpose of Normalization Chapter 14 - Objectives Chapter 14 Normalization The purpose of normalization. How normalization can be used when designing a relational database. The potential problems associated with redundant data

More information

Relational Design Theory. Relational Design Theory. Example. Example. A badly designed schema can result in several anomalies.

Relational Design Theory. Relational Design Theory. Example. Example. A badly designed schema can result in several anomalies. Relational Design Theory Relational Design Theory A badly designed schema can result in several anomalies Update-Anomalies: If we modify a single fact, we have to change several tuples Insert-Anomalies:

More information

CS211 Lecture: Database Design

CS211 Lecture: Database Design CS211 Lecture: Database Design Objectives: last revised November 21, 2006 1. To introduce the anomalies that result from redundant storage of data 2. To introduce the notion of functional dependencies

More information

Normalisation theory

Normalisation theory Normalisation theory Introduction to Database Design 2012, Lecture 7 Challenging exercises E-R diagrams example Normalisation theory, motivation Functional dependencies Boyce-Codd normal form (BCNF) 3rd

More information

Normalization is based on the concept of functional dependency. A functional dependency is a type of relationship between attributes.

Normalization is based on the concept of functional dependency. A functional dependency is a type of relationship between attributes. Lecture Handout Database Management System Lecture No. 19 Reading Material Database Systems Principles, Design and Implementation written by Catherine Ricardo, Maxwell Macmillan. Section 7.1 7.7 Database

More information

Schema Refinement and Normal Forms

Schema Refinement and Normal Forms Schema Refinement and Normal Forms Chapter 19 Quiz #2 Next Wednesday Comp 521 Files and Databases Fall 2010 1 The Evils of Redundancy Redundancy is at the root of several problems associated with relational

More information

Logical Database Design. ICT285 Databases: Topic 06

Logical Database Design. ICT285 Databases: Topic 06 Logical Database Design ICT285 Databases: Topic 06 1. What is Logical Database Design? Why bother? Bad logical database design results in bad physical database design, and generally results in poor database

More information

Draw A Relational Schema And Diagram The Functional Dependencies In The Relation >>>CLICK HERE<<<

Draw A Relational Schema And Diagram The Functional Dependencies In The Relation >>>CLICK HERE<<< Draw A Relational Schema And Diagram The Functional Dependencies In The Relation I need to draw relational schema and dependency diagram showing transitive and partial Functional dependency and normalization

More information

Steps in normalisation. Steps in normalisation 7/15/2014

Steps in normalisation. Steps in normalisation 7/15/2014 Introduction to normalisation Normalisation Normalisation = a formal process for deciding which attributes should be grouped together in a relation Normalisation is the process of decomposing relations

More information

Functional Dependencies CS 1270

Functional Dependencies CS 1270 Functional Dependencies CS 1270 Constraints We use constraints to enforce semantic requirements on a DBMS Predicates that the DBMS must ensure to be always true. Predicates are checked when the DBMS chooses

More information

Normalization Normalization

Normalization Normalization Normalization Normalization We discuss four normal forms: first, second, third, and Boyce-Codd normal forms 1NF, 2NF, 3NF, and BCNF Normalization is a process that improves a database design by generating

More information

Functional dependency theory

Functional dependency theory Functional dependency theory Introduction to Database Design 2012, Lecture 8 Course evaluation Recalling normal forms Functional dependency theory Computing closures of attribute sets BCNF decomposition

More information

Birkbeck. (University of London) BSc/FD EXAMINATION. Department of Computer Science and Information Systems. Database Management (COIY028H6)

Birkbeck. (University of London) BSc/FD EXAMINATION. Department of Computer Science and Information Systems. Database Management (COIY028H6) Birkbeck (University of London) BSc/FD EXAMINATION Department of Computer Science and Information Systems Database Management (COIY028H6) CREDIT VALUE: 15 credits Date of examination: 9 June 2016 Duration

More information

CS 338 Functional Dependencies

CS 338 Functional Dependencies CS 338 Functional Dependencies Bojana Bislimovska Winter 2016 Outline Design Guidelines for Relation Schemas Functional Dependency Set and Attribute Closure Schema Decomposition Boyce-Codd Normal Form

More information

Ryan Marcotte CS 475 (Advanced Topics in Databases) March 14, 2011

Ryan Marcotte  CS 475 (Advanced Topics in Databases) March 14, 2011 Ryan Marcotte www.cs.uregina.ca/~marcottr CS 475 (Advanced Topics in Databases) March 14, 2011 Outline Introduction to XNF and motivation for its creation Analysis of XNF s link to BCNF Algorithm for converting

More information

Functional Dependency

Functional Dependency Functional Dependency & Normalization in Relational Data Models Kudang B. Seminar Functional Dependency Functional dependency (FD) defines a constraint between two attributes (possibly groups of attributes)

More information

CS411 Database Systems. 05: Relational Schema Design Ch , except and

CS411 Database Systems. 05: Relational Schema Design Ch , except and CS411 Database Systems 05: Relational Schema Design Ch. 3.1-3.5, except 3.4.2-3.4.3 and 3.5.3. 1 How does this fit in? ER Diagrams: Data Definition Translation to Relational Schema: Data Definition Relational

More information

Relational Design: Characteristics of Well-designed DB

Relational Design: Characteristics of Well-designed DB 1. Minimal duplication Relational Design: Characteristics of Well-designed DB Consider table newfaculty (Result of F aculty T each Course) Id Lname Off Bldg Phone Salary Numb Dept Lvl MaxSz 20000 Cotts

More information

Functional Dependencies and Normalization

Functional Dependencies and Normalization Functional Dependencies and Normalization Jose M. Peña jose.m.pena@liu.se Overview Real world Databases DBMS Model Physical database Queries Processing of queries and updates Access to stored data Answers

More information

V. Database Design CS448/ How to obtain a good relational database schema

V. Database Design CS448/ How to obtain a good relational database schema V. How to obtain a good relational database schema Deriving new relational schema from ER-diagrams Normal forms: use of constraints in evaluating existing relational schema CS448/648 1 Translating an E-R

More information

To overcome these anomalies we need to normalize the data. In the next section we will discuss about normalization.

To overcome these anomalies we need to normalize the data. In the next section we will discuss about normalization. Anomalies in DBMS There are three types of anomalies that occur when the database is not normalized. These are Insertion, update and deletion anomaly. Let s take an example to understand this. Example:

More information

Detailed Data Modelling. Detailed Data Modelling. Detailed Data Modelling. Identifying Attributes. Attributes

Detailed Data Modelling. Detailed Data Modelling. Detailed Data Modelling. Identifying Attributes. Attributes IMS1002 /CSE1205 Systems Analysis and Design Detailed Data Modelling The objective of detailed data modelling is to develop a detailed data structure that: Detailed Data Modelling: Attribute Collection

More information

CS403- Database Management Systems Solved Objective Midterm Papers For Preparation of Midterm Exam

CS403- Database Management Systems Solved Objective Midterm Papers For Preparation of Midterm Exam CS403- Database Management Systems Solved Objective Midterm Papers For Preparation of Midterm Exam Question No: 1 ( Marks: 1 ) - Please choose one Which of the following is NOT a feature of Context DFD?

More information

The University of Nottingham

The University of Nottingham The University of Nottingham SCHOOL OF COMPUTER SCIENCE AND INFORMATION TECHNOLOGY A LEVEL 1 MODULE, SPRING SEMESTER 2006-2007 DATABASE SYSTEMS Time allowed TWO hours Candidates must NOT start writing

More information

Schema Refinement & Normalization Theory 2. Week 15

Schema Refinement & Normalization Theory 2. Week 15 Schema Refinement & Normalization Theory 2 Week 15 1 How do we know R is in BCNF? If R has only two attributes, then it is in BCNF If F only uses attributes in R, then: R is in BCNF if and only if for

More information

Database Systems. Normalization Lecture# 7

Database Systems. Normalization Lecture# 7 Database Systems Normalization Lecture# 7 Lecture 7: Normalization Normalization (Brief Overview) Functional Dependencies and Keys 1 st Normal Form 2 nd Normal Form 3 rd Normal Form Class Activity 3 Normalization

More information

Logical Database Design Normalization

Logical Database Design Normalization Chapter Four Logical Database Design Normalization Objectives Recalling Relational concepts Understand different anomalies and functional dependency concepts Use normalization to convert anomalous tables

More information

Chapter 2: Intro to Relational Model

Chapter 2: Intro to Relational Model Chapter 2: Intro to Relational Model Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Example of a Relation attributes (or columns) tuples (or rows) 2.2 Attribute Types The

More information

We shall represent a relation as a table with columns and rows. Each column of the table has a name, or attribute. Each row is called a tuple.

We shall represent a relation as a table with columns and rows. Each column of the table has a name, or attribute. Each row is called a tuple. Logical Database design Earlier we saw how to convert an unorganized text description of information requirements into a conceptual design, by the use of ER diagrams. The advantage of ER diagrams is that

More information

Wentworth Institute of Technology COMP2670 Databases Spring 2016 Derbinsky. Normalization. Lecture 9

Wentworth Institute of Technology COMP2670 Databases Spring 2016 Derbinsky. Normalization. Lecture 9 Lecture 9 1 Outline 1. Context 2. Objectives 3. Functional Dependencies 4. Normal Forms 1NF 2NF 3NF 2 Database Design and Implementation Process 3 Theory and process by which to evaluate and improve relational

More information

A subquery is a nested query inserted inside a large query Generally occurs with select, from, where Also known as inner query or inner select,

A subquery is a nested query inserted inside a large query Generally occurs with select, from, where Also known as inner query or inner select, Sub queries A subquery is a nested query inserted inside a large query Generally occurs with select, from, where Also known as inner query or inner select, Result of the inner query is passed to the main

More information

Detailed Data Modelling: Attribute Collection and Normalisation of Data

Detailed Data Modelling: Attribute Collection and Normalisation of Data Detailed Data Modelling IMS1002 /CSE1205 Systems Analysis and Design Detailed Data Modelling: Attribute Collection and Normalisation of Data The objective of detailed data modelling is to develop a detailed

More information

Normalization and Functional Dependencies. CS6302 Database management systems T.R.Lekhaa, AP/IT

Normalization and Functional Dependencies. CS6302 Database management systems T.R.Lekhaa, AP/IT Normalization and Functional Dependencies Normalization Normalization There are fournormal forms: first, second, third, and Boyce-Codd normal forms 1NF, 2NF, 3NF, and BCNF Normalization is a process that

More information

Schema Normalization. 30 th August Submitted By: Saurabh Singla Rahul Bhatnagar

Schema Normalization. 30 th August Submitted By: Saurabh Singla Rahul Bhatnagar Schema Normalization 30 th August 2011 Submitted By: Saurabh Singla 09010146 Rahul Bhatnagar 09010136 Normalization Consider the following ER diagram with some FD: Instructor iid A Student sid Department

More information

The Relational Data Model

The Relational Data Model The Relational Data Model Lecture 6 1 Outline Relational Data Model Functional Dependencies Logical Schema Design Reading Chapter 8 2 1 The Relational Data Model Data Modeling Relational Schema Physical

More information

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 6 Normalization of Database Tables

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 6 Normalization of Database Tables Database Systems: Design, Implementation, and Management Tenth Edition Chapter 6 Normalization of Database Tables Objectives In this chapter, students will learn: What normalization is and what role it

More information

From Murach Chap. 9, second half. Schema Refinement and Normal Forms

From Murach Chap. 9, second half. Schema Refinement and Normal Forms From Murach Chap. 9, second half The need for normalization A table that contains repeating columns Schema Refinement and Normal Forms A table that contains redundant data (same values repeated over and

More information

پوهنتون کابل پوهنحی كمپيوترساینس پوهنیار محمد شعیب "زرین خیل"

پوهنتون کابل پوهنحی كمپيوترساینس پوهنیار محمد شعیب زرین خیل پوهنتون کابل پوهنحی كمپيوترساینس : : تهیه کننده سال پوهنیار محمد شعیب "زرین خیل" 1389 Introduction to Database and Data Models - Relational Model 08 By: M Shuaib Zarinkhail 2010 Referential Integrity Constraint

More information

Database design III. Quiz time! Using FDs to detect anomalies. Decomposition. Decomposition. Boyce-Codd Normal Form 11/4/16

Database design III. Quiz time! Using FDs to detect anomalies. Decomposition. Decomposition. Boyce-Codd Normal Form 11/4/16 Lecture 3 Quiz time! Database design III Functional dependencies cont. BCNF and 3NF What s wrong with this schema? {(, 2, Databases, Steven Van Acker ), (, 4, Databases, Rogardt Heldal )} Redundancy! Using

More information

GUJARAT TECHNOLOGICAL UNIVERSITY

GUJARAT TECHNOLOGICAL UNIVERSITY Seat No.: Enrolment No. GUJARAT TECHNOLOGICAL UNIVERSITY BE - SEMESTER III (NEW) - EXAMINATION SUMMER 2017 Subject Code: 21303 Date: 02/06/2017 Subject Name: Database Management Systems Time: 10:30 AM

More information

Normalization. VI. Normalization of Database Tables. Need for Normalization. Normalization Process. Review of Functional Dependence Concepts

Normalization. VI. Normalization of Database Tables. Need for Normalization. Normalization Process. Review of Functional Dependence Concepts VI. Normalization of Database Tables Normalization Evaluating and correcting relational schema designs to minimize data redundancies Reduces data anomalies Assigns attributes to tables based on functional

More information

CS403- Database Management Systems Solved MCQS From Midterm Papers. CS403- Database Management Systems MIDTERM EXAMINATION - Spring 2010

CS403- Database Management Systems Solved MCQS From Midterm Papers. CS403- Database Management Systems MIDTERM EXAMINATION - Spring 2010 CS403- Database Management Systems Solved MCQS From Midterm Papers April 29,2012 MC100401285 Moaaz.pk@gmail.com Mc100401285@gmail.com PSMD01 CS403- Database Management Systems MIDTERM EXAMINATION - Spring

More information

Learning outcomes. On successful completion of this unit you will: 1. Understand data models and database technologies.

Learning outcomes. On successful completion of this unit you will: 1. Understand data models and database technologies. 2015-2016 Phil Smith Learning outcomes On successful completion of this unit you will: 1. Understand data models and database technologies. (Assignment 1) Recap and setting the scene Before we get to Normalisation

More information

Databases 1. Daniel POP

Databases 1. Daniel POP Databases 1 Daniel POP Week 6 & 7 Agenda Introduction to normalization Functional dependencies 1NF 2NF 3NF. Transitive dependencies BCNF 4NF. Multivalued dependencies 5NF De-normalization Normalization

More information

CS 2451 Database Systems: Database and Schema Design

CS 2451 Database Systems: Database and Schema Design CS 2451 Database Systems: Database and Schema Design http://www.seas.gwu.edu/~bhagiweb/cs2541 Spring 2018 Instructor: Dr. Bhagi Narahari Relational Model: Definitions Review Relations/tables, Attributes/Columns,

More information

Announcements (January 20) Relational Database Design. Database (schema) design. Entity-relationship (E/R) model. ODL (Object Definition Language)

Announcements (January 20) Relational Database Design. Database (schema) design. Entity-relationship (E/R) model. ODL (Object Definition Language) Announcements (January 20) 2 Relational Database Design Review for Codd paper due tonight via email Follow instructions on course Web site Reading assignment for next week (Ailamaki et al., VLDB 2001)

More information

Lectures 5 & 6. Lectures 6: Design Theory Part II

Lectures 5 & 6. Lectures 6: Design Theory Part II Lectures 5 & 6 Lectures 6: Design Theory Part II Lecture 6 Today s Lecture 1. Boyce-Codd Normal Form ACTIVITY 2. Decompositions & 3NF ACTIVITY 3. MVDs ACTIVITY 2 Lecture 6 > Section 1 1. Boyce-Codd Normal

More information

Database Systems CSE Comprehensive Exam Spring 2005

Database Systems CSE Comprehensive Exam Spring 2005 Database Systems CSE 5260 Spring 2005 Database Schema #1 Branch (Branch_Name, Branch_City, Assets) Customer (Customer_Name, SS#, Street, City, State, Zip_Code) Account (Account_Number, Branch_Name, Balance)

More information

Concepts from

Concepts from 1 Concepts from 3.1-3.2 Functional dependencies Keys & superkeys of a relation Reasoning about FDs Closure of a set of attributes Closure of a set of FDs Minimal basis for a set of FDs 2 Plan How can we

More information

CSCI 403: Databases 13 - Functional Dependencies and Normalization

CSCI 403: Databases 13 - Functional Dependencies and Normalization CSCI 403: Databases 13 - Functional Dependencies and Normalization Introduction The point of this lecture material is to discuss some objective measures of the goodness of a database schema. The method

More information

Chapter 3. The Relational database design

Chapter 3. The Relational database design Chapter 3 The Relational database design Chapter 3 - Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical relations and relations in the relational

More information

Database Management Systems Paper Solution

Database Management Systems Paper Solution Database Management Systems Paper Solution Following questions have been asked in GATE CS exam. 1. Given the relations employee (name, salary, deptno) and department (deptno, deptname, address) Which of

More information

CS425 Fall 2016 Boris Glavic Chapter 2: Intro to Relational Model

CS425 Fall 2016 Boris Glavic Chapter 2: Intro to Relational Model CS425 Fall 2016 Boris Glavic Chapter 2: Intro to Relational Model Modifies from: Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Textbook: Chapter 2 2.2 Example of a Relation

More information

TDDD12 Databasteknik Föreläsning 4: Normalisering

TDDD12 Databasteknik Föreläsning 4: Normalisering What is Good Design TDDD12 Databasteknik Föreläsning 4: Normalisering Can we be sure that the translation from the EER diagram to relational tables results in a good database design? Or: Confronted with

More information

Institute of Southern Punjab, Multan

Institute of Southern Punjab, Multan Institute of Southern Punjab, Multan Mr. Muhammad Nouman Farooq BSC-H (Computer Science) MS (Telecomm. and Networks) Honors: Magna Cumm Laude Honors Degree Gold Medalist! Blog Url: noumanfarooqatisp.wordpress.com

More information