Al-Imam University Girls Education Center Collage of Computer Science 1 st Semester, 1432/1433H Chapter 10_part 1 Functional Dependencies and Normalization.

Slides:



Advertisements
Similar presentations
Functional Dependencies and Normalization for Relational Databases
Advertisements

NORMALIZATION. Normalization Normalization: The process of decomposing unsatisfactory "bad" relations by breaking up their attributes into smaller relations.
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.
Functional Dependencies and Normalization for Relational Databases
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 15 Basics of Functional Dependencies and Normalization for Relational.
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 8 Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Announcements Homework 1 due Friday. Slip it under my office door (1155) or put in my mailbox on 5 th floor. Program 2 has been graded ;-( Program 3 out.
Chapter 10 Functional Dependencies and Normalization for Relational Databases.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 10 Functional Dependencies and Normalization for Relational Databases.
FUNCTIONAL DEPENDENCIES. Chapter Outline 1 Informal Design Guidelines for Relational Databases 1.1Semantics of the Relation Attributes 1.2 Redundant Information.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 6 NORMALIZATION FOR RELATIONAL DATABASES Instructor Ms. Arwa Binsaleh.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
King Saud University College of Computer & Information Sciences Computer Science Department CS 380 Introduction to Database Systems Functional Dependencies.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Normalization for Relational Databases.
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.
Instructor: Churee Techawut Functional Dependencies and Normalization for Relational Databases Chapter 4 CS (204)321 Database System I.
Top-Down Database Design Mini-world Requirements Conceptual schema E1 E2 R Relation schemas ?
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.
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.
Chapter Functional Dependencies and Normalization for Relational Databases.
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.
1 Functional Dependencies and Normalization Chapter 15.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Lecture 8: Database Concepts May 4, Outline From last lecture: creating views Normalization.
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.
Deanship of Distance Learning Avicenna Center for E-Learning 1 Session - 7 Sequence - 1 Normalization DB Design Guidelines Presented by: Dr. Samir Tartir.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 10 Functional Dependencies and Normalization for Relational Databases.
Al-Imam University Girls Education Center Collage of Computer Science 1 nd Semester, 1432/1433H Chapter 10_part2 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.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Functional Dependencies and Normalization for Relational Databases تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة من الادوات في ذلك. حيث المرجع.
10/3/2017.
10/3/2017.
Functional Dependency and Normalization
CHAPTER 14 Basics of Functional Dependencies and Normalization for Relational Databases.
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.
Functional Dependencies and Normalization for Relational Databases
Database Management systems Subject Code: 10CS54 Prepared By:
Normalization DB Design Guidelines Presented by: Dr. Samir Tartir
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Database Normalisation
Sampath Jayarathna Cal Poly Pomona
Chapter Outline 1 Informal Design Guidelines for Relational Databases
Presentation transcript:

Al-Imam University Girls Education Center Collage of Computer Science 1 st Semester, 1432/1433H Chapter 10_part 1 Functional Dependencies and Normalization for Relational Databases

Introduction to Databases 2 Chapter Outline Informal Design Guidelines for Relational Databases Functional Dependencies (FDs) Definition, Inference Rules and Normal Forms Based on Primary Keys Normal Forms Based on Primary Keys  First Normal Form  Second Normal Form  Third Normal Form

Introduction to Databases 3 Informal Design Guidelines for Relational Databases Relational database design: The grouping of attributes to form "good" relation schemas Two levels of relation schemas:  The logical "user view" level  The storage "base relation" level Design is concerned mainly with base relations Criteria for "good" base relations:  Discuss informal guidelines for good relational design  Discuss formal concepts of functional dependencies and normal forms 1NF 2NF 3NF BCNF

Introduction to Databases 4 Informal Design Guidelines for Relational Databases Four informal measures of quality for relation schema design: 1. Semantics of the Relation Attributes 2. Reducing the redundant information in tuples 3. Reducing Null values in tuples 4. Disallowing the possibility of one generating spurious tuples.

Introduction to Databases 5 1- Semantics of the Relation Attributes Each tuple in a relation should represent one entity or relationship instance  Only foreign keys should be used to refer to other entities  Entity and relationship attributes should be kept apart as much as possible Guideline #1: Design a schema that can be explained easily relation by relation. The semantics of attributes should be easy to interpret.

Introduction to Databases 6 2- 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 Attributes of different entities (EMPLOYEEs, DEPARTMENTs, PROJECTs) should not be mixed in the same relation.

Introduction to Databases 7 Example of An Update Anomaly Consider the relation: EMP_PROJ ( Emp#, Proj#, Ename, Pname, No_hours)  Update Anomaly Changing the name of project number P1 from “Billing” to “Customer-Accounting” may cause this update to be made for all 100 employees working on project P1  Insert Anomaly Cannot insert a project unless an employee is assigned to. Inversely- Cannot insert an employee unless he/she is assigned to a project.

Introduction to Databases 8  Delete Anomaly When a project is deleted, it will result in deleting all the employees who work on that project. Alternately, if an employee is the sole employee on a project, deleting that employee would result in deleting the corresponding project. Guideline #2: Design a schema that does not suffer from the insertion, deletion and update anomalies. If there are any present, then note them so that applications can be made to take them into account Example of An Update Anomaly (contd.)

Introduction to Databases 9 Two relation schemas suffering from update anomalies

Introduction to Databases 10 Base Relations EMP_PROJ with redundant information

Introduction to Databases Null Values in Tuples Reasons for nulls: a. attribute not applicable or invalid b. attribute value unknown (may exist) c. value known to exist, but unavailable Guideline #3: Relations should be designed such that their tuples will have as few NULL values as possible Attributes that are NULL frequently could be placed in separate relations (with the primary key)

Introduction to Databases Spurious Tuples Bad designs for a relational database may result in erroneous results for certain JOIN operations The "lossless join" property is used to guarantee meaningful results for join operations Guideline #4: The relations should be designed to satisfy the lossless join condition. No spurious tuples should be generated by doing join of any relations.

Introduction to Databases 13 Functional Dependencies Functional dependencies (FDs) are used to specify formal measures of the "goodness" of relational designs FDs and keys are used to define normal forms for relations FDs are constraints that are derived from the meaning and interrelationships of the data attributes

Introduction to Databases 14 Functional Dependencies (2) A set of attributes X functionally determines a set of attributes Y if the value of X determines a unique value for Y X  Y holds if whenever two tuples have the same value for X, they must have the same value for Y If t1[X]=t2[X], then t1[Y]=t2[Y] in any relation instance r(R) X  Y in R specifies a constraint on all relation instances r(R) FDs are derived from the real-world constraints on the attributes Written as X -> Y; can be displayed graphically on a relation schema as in Figures. (denoted by the arrow ).

Introduction to Databases 15 Examples of FD constraints 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 If K is a key of R, then K functionally determines all attributes in R (since we never have two distinct tuples with t1[K]=t2[K])

Introduction to Databases 16 Introduction to Normalization Normalization: Process of decomposing unsatisfactory "bad" relations by breaking up their attributes into smaller relations Normal form: Condition using keys and FDs of a relation to certify whether a relation schema is in a particular normal form  2NF, 3NF, BCNF based on keys and FDs of a relation schema

Introduction to Databases 17 First Normal Form Disallows composite attributes, multivalued attributes, and nested relations; attributes whose values for an individual tuple are non-atomic. Considered to be part of the definition of relation

Introduction to Databases 18 Normalization into 1NF

Introduction to Databases 19 Examples First Normal Form EMP_PROJ (Ssn, Ename, {Phone#}) { } Mulitvalue attribute EMP_PROJ1 (Ssn, Ename) EMP_PROJ2 (Ssn, Phone#) ■EMP_PROJ (Ssn, Ename (Fname, Lname)) ( ) composite attribute EMP_PROJ (Ssn, Fname,Lname) ■EMP_PROJ (Ssn, Ename, {PROJS (Pnamber, Hours)}) EMP_PROJ1 (Ssn, Ename) EMP_PROJ2 (Ssn, Pnamber, Hours)

Introduction to Databases 20

Introduction to Databases 21 Second Normal Form Uses the concepts of FDs, primary key Definitions:  Prime attribute - attribute that is member of the primary key K.  Full functional dependency - a FD Y  Z where removal of any attribute from Y means the FD does not hold any more.

Introduction to Databases 22 Examples Second Normal Form {SSN, PNUMBER}  HOURS is a full FD since neither SSN  HOURS nor PNUMBER  HOURS hold {SSN, PNUMBER}  ENAME is not a full FD (it is called a partial dependency ) since SSN  ENAME also holds A relation schema R is in second normal form (2NF) if every non-prime attribute A in R is fully functionally dependent on the primary key R can be decomposed into 2NF relations via the process of 2NF normalization

Introduction to Databases 23 Examples Second Normal Form

Introduction to Databases 24 Second Normal Form Note: The test for 2NF involves testing for functional dependencies whose left-hand side attributes are part of the primary key. If the primary key contains a single attribute, the test need not be applied at all.