COMP1212 COMP1212 Anomalies and Dependencies Dr. Mabruk Ali.

Slides:



Advertisements
Similar presentations
Functional Dependencies and Normalization for Relational Databases
Advertisements

Chapter 3 Notes. 3.1 Functional Dependencies A functional dependency is a statement that – two tuples of a relation that agree on some particular set.
Ch 10, Functional Dependencies and Normal forms
Functional Dependencies and Normalization for Relational Databases.
Kingdom of Saudi Arabia Ministry of Higher Education Al-Imam Muhammad Ibn Saud Islamic University College of Computer and Information Sciences Normalization.
Ms. Hatoon Al-Sagri CCIS – IS Department Normalization.
The Relational Model System Development Life Cycle Normalisation
Functional Dependencies and Normalization for Relational Databases
Part 6 Chapter 15 Normalization of Relational Database Csci455 r 1.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
METU Department of Computer Eng Ceng 302 Introduction to DBMS Functional Dependencies and Normalization for Relational Databases by Pinar Senkul resources:
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
1 Functional Dependency and Normalization Informal design guidelines for relation schemas. Functional dependencies. Normal forms. Normalization.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Chapter 5 Normalization Transparencies © Pearson Education Limited 1995, 2005.
Chapter 10 Functional Dependencies and Normalization for Relational Databases.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 6 NORMALIZATION FOR RELATIONAL DATABASES Instructor Ms. Arwa Binsaleh.
Week 6 Lecture Normalization
Functional Dependencies
DatabaseIM ISU1 Chapter 10 Functional Dependencies and Normalization for RDBs Fundamentals of Database Systems.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Topic 10 Functional Dependencies and Normalization for Relational Databases Faculty of Information Science and Technology Mahanakorn University of Technology.
Normalization Transparencies
Instructor: Churee Techawut Functional Dependencies and Normalization for Relational Databases Chapter 4 CS (204)321 Database System I.
Functional Dependencies and Normalization for Relational Databases.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Normalization Well structured relations and anomalies Normalization First normal form (1NF) Functional dependence Partial functional dependency Second.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 15 Basics of Functional Dependencies and Normalization for Relational.
CSE314 Database Systems Basics of Functional Dependencies and Normalization for Relational Databases Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E.
Ihr Logo Fundamentals of Database Systems Fourth Edition El Masri & Navathe Chapter 10 Functional Dependencies and Normalization for Relational Databases.
Ihr Logo Fundamentals of Database Systems Fourth Edition El Masri & Navathe Chapter 10 Functional Dependencies and Normalization for Relational Databases.
Lecture 5 Normalization. Objectives The purpose of normalization. How normalization can be used when designing a relational database. The potential problems.
Chapter 13 Normalization Transparencies Last Updated: 08 th May 2011 By M. Arief
Chapter 10 Normalization Pearson Education © 2009.
1 Functional Dependencies and Normalization Chapter 15.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Lecture 8: Database Concepts May 4, Outline From last lecture: creating views Normalization.
Design Process - Where are we?
Database Design FUNCTIONAL DEPENDENCES NORMAL FORMS D. Christozov / G.Tuparov INF 280 Database Systems: DB design: Normal Forms 1.
Chapter 7 Functional Dependencies Copyright © 2004 Pearson Education, Inc.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Ch 7: Normalization-Part 1
Deanship of Distance Learning Avicenna Center for E-Learning 1 Session - 7 Sequence - 1 Normalization DB Design Guidelines Presented by: Dr. Samir Tartir.
Al-Imam University Girls Education Center Collage of Computer Science 1 st Semester, 1432/1433H Chapter 10_part 1 Functional Dependencies and Normalization.
Chapter 15 1 Functional Dependencies and Normalization for Relational Databases تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة من الادوات في.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Chapter 14 Functional Dependencies and Normalization Informal Design Guidelines for Relational Databases –Semantics of the Relation Attributes –Redundant.
Chapter 8 Relational Database Design Topic 1: Normalization Chuan Li 1 © Pearson Education Limited 1995, 2005.
10/3/2017.
Functional Dependency and Normalization
Functional Dependencies and Normalization for Relational Databases
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Database Management systems Subject Code: 10CS54 Prepared By:
Chapter 14 & Chapter 15 Normalization Pearson Education © 2009.
Chapter 14 Normalization – Part I Pearson Education © 2009.
Normalization Dale-Marie Wilson, Ph.D..
Normalization DB Design Guidelines Presented by: Dr. Samir Tartir
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Chapter 14 Normalization.
國立臺北科技大學 課程:資料庫系統 2015 fall Chapter 14 Normalization.
Database Normalisation
Sampath Jayarathna Cal Poly Pomona
Chapter Outline 1 Informal Design Guidelines for Relational Databases
Presentation transcript:

COMP1212 COMP1212 Anomalies and Dependencies Dr. Mabruk Ali

Semantics of the Relation Attributes GUIDELINE 1: Informally, each tuple in a relation should represent one entity or relationship instance. (Applies to individual relations and their attributes). Attributes of different entities (EMPLOYEEs, DEPARTMENTs, PROJECTs) should not be mixed in the same relation Only foreign keys should be used to refer to other entities Entity and relationship attributes should be kept apart as much as possible. Bottom Line: Design a schema that can be explained easily relation by relation. The semantics of attributes should be easy to interpret.

Redundant Information in Tuples and Update Anomalies Mixing attributes of multiple entities may cause problems Information is stored redundantly wasting storage Problems with update anomalies ◦ Insertion anomalies ◦ Deletion anomalies ◦ Modification anomalies

Slide 4 EmployeeSalaryProjectBudgetRole Brown20Alpha2Technician Green35Gamma15Designer Green35Epsilon9Designer Hoskins55Epsilon9Manager Hoskins55Gamma15Consultant Moore48Gamma15Manager Moore48Epsilon9Designer Data redundancy Values stored repetitively in relations (esp. poorly designed relations)  Potential for anomalous data to be stored This relation associates employees with projects. Assume no nulls are allowed.

Slide 5 Both values updated: OK Update anomalies Each person’s salary is repeated for each project they are involved with. What does this imply when we need to increase someone’s salary? EmployeeSalaryProjectBudgetRole Brown20Alpha2Technician GreenGamma15Designer GreenEpsilon9Designer Hoskins55Epsilon9Manager Hoskins55Gamma15Consultant MooreGamma15Manager Moore48Epsilon9Designer Only one value updated: ANOMALY 50

Slide 6 If a project ends (i.e., is deleted), what happens to the data for employees on that project? EmployeeSalaryProjectBudgetRole Green35Gamma15Designer Green35Epsilon9Designer Hoskins55Epsilon9Manager Hoskins55Gamma15Consultant Moore48Gamma15Manager Moore48Epsilon9Designer Brown20Alpha2Technician Delete project Alpha Delete anomalies What happens to (Brown, 20)? ANOMALY

Slide 7 Johnson hasn’t yet been assigned to a project, but no nulls allowed Insert anomalies What happens when we hire a new person? (remember, no nulls allowed) EmployeeSalaryProjectBudgetRole Brown20Alpha2Technician Green35Gamma15Designer Green35Epsilon9Designer Hoskins55Epsilon9Manager Hoskins55Gamma15Consultant Moore48Gamma15Manager Moore48Epsilon9Designer EmployeeSalaryProjectBudgetRole Brown20Alpha2Technician Green35Gamma15Designer Green35Epsilon9Designer Hoskins55Epsilon9Manager Hoskins55Gamma15Consultant Moore48Gamma15Manager Moore48Epsilon9Designer Johnson36??? Where do we store (Johnson, 36) until then? ANOMALY

Slide 8 EmployeeSalary Brown20 Green35 Hoskins55 Moore48 EmployeeProjectRole BrownAlphaTechnician GreenGammaDesigner GreenEpsilonDesigner HoskinsEpsilonManager HoskinsGammaConsultant MooreGammaManager MooreEpsilonDesigner ProjectBudget Alpha2 Gamma15 Epsilon9 The solution: Normalisation Breaking up the relation eliminates the worst of the redundancy

Functional Dependencies (FD) An important concept associated with normalization. Functional dependency describes the relationship between attributes. For example, if A and B are attributes of relation R, B is functionally dependent on A (denoted A → B), if each value of A in R is associated with exactly one value of B in R. An alternative way to describe the relationship between attributes A and B is to say that “A functionally determines B”. A Called (the Determinant) B Called (the dependent)

Characteristics of FDs Determinants should have the minimal number of attributes necessary to maintain the functional dependency with the attribute(s) on the right hand-side. This requirement is called full functional dependency.

Identifying FDs Identifying all functional dependencies between a set of attributes is relatively simple if the meaning of each attribute and the relationships between the attributes are well understood. This information should be provided by the enterprise in the form of discussions with users and/or documentation such as the users’ requirements specification.

Identifying FDs (Cont) However, if the users are unavailable for consultation and/or the documentation is incomplete then depending on the database application it may be necessary for the database designer to use their common sense and/or experience to provide the missing information.

Examples of FD constraints (1) social security number determines employee name SSN -> ENAME project number determines project name and location PNUMBER -> {PNAME, PLOCATION} employee ssn and project number determines the hours per week that the employee works on the project {SSN, PNUMBER} -> HOURS

Types of functional dependency Full Partial Transitive

Full Functional Dependency Full functional dependency indicates that if A and B are attributes of a relation. B is fully functionally dependent on A, if B is functionally dependent on A, but not on any proper subset of A. A functional dependency A → B is a partially dependency if there is some attribute that can be removed from A and yet the dependency still holds. A  B == LHS  RHS

Slide 16 Example of Full FD Example: R(Year, Course_code, Course_coordinator) ◦ year + course_code  course_coordinator ◦ (i.e., course_coordinator determined by combination of both a particular year and a course_code) ◦ If we remove either Year or Course code from the left hand side (LHS) (the determinant), the dependency is no longer exist. Year Course_code Course_coordinator

Slide 17 Partial functional dependency Subset of left hand side determines right hand side ◦ “extra” attributes on LHS are unnecessary Student ID Date of Birth Invoice Number Student Name Invoice Date Invoice Total R1(StudentId, StudentName,DateOfBirth) R2(InvoiceNumber, InvoiceDate, InvoiceTotal)

Slide 18 Now Full functional dependency left hand side determines right hand side ◦ No “extra” attributes on LHS are unnecessary Student ID Date of Birth Invoice Number Invoice Total

Slide 19 Transitive dependency ◦ part number determines supplier number ◦ supplier number determines supplier name ◦ therefore, part number alone also determines supplier name Ideally should not exist within the same relation Part number Supplier number Supplier name Part number Supplier name

Transitive Dependency It is important to recognize a transitive dependency because its existence in a relation can potentially cause update anomalies. Transitive dependency describes a condition where A, B, and C are attributes of a relation such that if A → B and B → C, then C is transitively dependent on A via B (provided that A is not functionally dependent on B or C).

MVD & JD Normal Forms will be discussed next lecture. The fourth normal form makes use of a new kind of dependency, called a multivalued dependency (MVD); MVDs are a generalization of FDs. The fifth normal form makes use of an­other new kind of dependency, called a join dependency (JD); JDs are a generalization of MVDs, just as MVDs are a generalization of FDs.

The End Lecture 05 - ER to Relation Mapping22