primary key constraint foreign key constraint

Slides:



Advertisements
Similar presentations
Schema Refinement and Normal Forms
Advertisements

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 16 Relational Database Design Algorithms and Further Dependencies.
Schema Refinement and Normal Forms Given a design, how do we know it is good or not? What is the best design? Can a bad design be transformed into a good.
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.
Database Management COP4540, SCS, FIU Functional Dependencies (Chapter 14)
Database Management Systems, 3ed, R. Ramakrishnan and J. Gehrke1 Schema Refinement and Normal Forms Chapter 19.
Functional Dependencies and Normalization for Relational Databases.
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
Schema Refinement and Normal Forms. The Evils of Redundancy v Redundancy is at the root of several problems associated with relational schemas: – redundant.
1 Functional Dependency and Normalization Informal design guidelines for relation schemas. Functional dependencies. Normal forms. Normalization.
1 Schema Refinement and Normal Forms Chapter 19 Raghu Ramakrishnan and J. Gehrke (second text book) In Course Pick-up box tomorrow.
1 Schema Refinement and Normal Forms Yanlei Diao UMass Amherst April 10, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
Functional Dependencies CS 186, Spring 2006, Lecture 21 R&G Chapter 19 Science is the knowledge of consequences, and dependence of one fact upon another.
Chapter 10 Functional Dependencies and Normalization for Relational Databases.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Normal Forms1. 2 The Problems of Redundancy Redundancy is at the root of several problems associated with relational schemas: Wastes storage Causes problems.
CSCD34 - Data Management Systems - A. Vaisman1 Schema Refinement and Normal Forms.
King Saud University College of Computer & Information Sciences Computer Science Department CS 380 Introduction to Database Systems 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.
Schema Refinement and Normal Forms Chapter 19 1 Database Management Systems 3ed, R.Ramakrishnan & J.Gehrke.
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 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.
Ihr Logo Fundamentals of Database Systems Fourth Edition El Masri & Navathe Chapter 10 Functional Dependencies and Normalization for Relational Databases.
Logical Database Design (1 of 3) John Ortiz Lecture 6Logical Database Design (1)2 Introduction  The logical design is a process of refining DB schema.
1 Lecture 6: Schema refinement: Functional dependencies
1 Functional Dependencies and Normalization Chapter 15.
Christoph F. Eick: Functional Dependencies, BCNF, and Normalization 1 Functional Dependencies, BCNF and Normalization.
Database Systems/COMP4910/Spring02/Melikyan1 Schema Refinement and Normal Forms.
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
1 Schema Refinement and Normal Forms Week 6. 2 The Evils of Redundancy  Redundancy is at the root of several problems associated with relational schemas:
Lecture 8: Database Concepts May 4, Outline From last lecture: creating views Normalization.
Deanship of Distance Learning Avicenna Center for E-Learning 1 Session - 7 Sequence - 2 Normalization Functional Dependencies Presented by: Dr. Samir Tartir.
1 Functional Dependencies. 2 Motivation v E/R  Relational translation problems : –Often discover more “detailed” constraints after translation (upcoming.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Schema Refinement and Normal Forms Chapter 15.
Functional Dependencies R&G Chapter 19 Science is the knowledge of consequences, and dependence of one fact upon another. Thomas Hobbes ( )
Database Management Systems, 3ed, R. Ramakrishnan and J. Gehrke1 Schema Refinement and Normal Forms Chapter 19.
Chapter 7 Functional Dependencies Copyright © 2004 Pearson Education, Inc.
CS 405G: Introduction to Database Systems Instructor: Jinze Liu Fall 2009.
ICS 421 Spring 2010 Relational Model & Normal Forms Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 1/19/20101Lipyeow.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
1 Schema Refinement and Normal Forms Chapter The Evils of Redundancy  Redundancy is at the root of several problems associated with relational.
CS542 1 Schema Refinement Chapter 19 (part 1) Functional Dependencies.
Database Management Systems, 3ed, R. Ramakrishnan and J. Gehrke1 Schema Refinement and Normal Forms Chapter 19.
Chapter 8 Relational Database Design. 2 Relational Database Design: Goals n Reduce data redundancy (undesirable replication of data values) n Minimize.
11/06/97J-1 Principles of Relational Design Chapter 12.
1 CS 430 Database Theory Winter 2005 Lecture 8: Functional Dependencies Second, Third, and Boyce-Codd Normal Forms.
1 Schema Refinement and Normal Forms Chapter The Evils of Redundancy  Redundancy causes several problems associated with relational schemas: 
Normalization and FUNctional Dependencies. Redundancy: root of several problems with relational schemas: –redundant storage, insert/delete/update anomalies.
Functional Dependencies and Normalization for Relational Databases 1 Chapter 15 تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة من الادوات في.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Chapter 14 Functional Dependencies and Normalization Informal Design Guidelines for Relational Databases –Semantics of the Relation Attributes –Redundant.
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
1 CS122A: Introduction to Data Management Lecture #12: Relational DB Design Theory (1) Instructor: Chen Li.
COP 6726: New Directions in Database Systems
Functional Dependency and Normalization
Normalization Functional Dependencies Presented by: Dr. Samir Tartir
Schema Refinement & Normalization Theory
Functional Dependencies
Database Management systems Subject Code: 10CS54 Prepared By:
Functional Dependencies
Normalization.
Schema Refinement and Normalization
Chapter 19 (part 1) Functional Dependencies
Presentation transcript:

primary key constraint foreign key constraint miniworld Requirements & collection analysis refinement Database Requirements Conceptual Design Conceptual Schema ( ER diagram ) DBMS independent Data Model Mapping DBMS specific Conceptual Schema ( Relations ) primary key constraint foreign key constraint

Schema Refinement and Normal Forms Conceptual database design gives us a set of relation schemas and integrity constraints Given a design, how do we know it is good or not? A design can be evaluated from various perspectives, our focus is on data redundancy Conceptual design Schemas ICs

The Evils of Redundancy Redundancy is at the root of several problems associated with relational schemas: redundant storage Insertion/update/deletion anomalies

Example Schema Constraints: Hourly_Emps (ssn, name, lot, rating, hrly_wages, hrs_worked) Constraints: ssn is the primary key If two tuples have the same value on rating, they have the same value on hrly_wages

Solution: Decomposition If we break Hourly_Emps into Hourly_Emps2 and Wages, then we don’t have updates, insertion, deletion anomalies. Wages Hourly_Emps2

Decomposition Concerns Should a relation be decomposed? If a relation is not in certain form, some problems (e.g., redundancy) will arise, are these problems tolerable? Aforementioned anomalies Potential performance loss: Queries over the original relation may required to join the decomposed relations How to decompose a relation? Two properties must be preserved: lossless-join: the data in the original relation can be recovered from the smaller relations dependency-preservation: all constraints on the original relation must still hold by enforcing some constraints on each of the small relations

Functional Dependencies (FDs) In a relation schema R, a set of attributes X functionally determines a set of attributes Y if and only if whenever two tuples of R agree on X value, they must necessarily agree on the Y value. XY where r(R) is an instance of R, XY: Y is functionally dependent on X, or X uniquely determines Y or X functionally determines Y, or X determines Y

X Y Z X1 Y2 Z1 Z2 X2 Z3 Does this data set violate X->Y? Does this data set violate Z->Y? X Y Z X1 Y1 Z1 Z2 Y2 Does this data set violate X->Y? Does this data set violate XY->Z? Does this data set violate Z->X? No, No, Yes, Yes, No

An FD is a statement about all allowable relations. Must be identified based on semantics of application. Given some allowable instance r1 of R, we can check if it violates some FD f, but we cannot tell if f holds over R! A primary key constraint is a special case of an FD The attributes in the key play the role of X, and the set of all attributes in the relation plays the role of Y K is a candidate key for R means that KR. However, KR does not require K to be minimal!

Example 1 Hourly_Emps (ssn, name, lot, rating, hrly_wages, hrs_worked) Notation: We will denote this relation schema by listing the attributes: SNLRWH This is really the set of attributes {S,N,L,R,W,H}. Sometimes, we will refer to all attributes of a relation by using the relation name. (e.g., Hourly_Emps for SNLRWH) Some FDs on Hourly_Emps: ssn is the key: SSNLRWH (or {S}{S,N,L,R,W,H}) rating determines hrly_wages : RW

Example 2 FD: did->lot Works_for(ssn,name,did,since) dname lot name ssn did budget Works_for Employees Departments Additional Constraints: Employees are assigned parking lots based on their department. All employees in the same department is given the same lot. FD: did->lot Works_for(ssn,name,did,since) Department (did,dname,budget,lot);

Dependency Reasoning A set of dependencies may imply some additional dependencies. EMP_DEPT(ENAME,SSN,BDATE,ADDRESS,DNUMBER,DNAME,DMGRSSN) F={SSN->{ENAME,BDATE,ADDRESS,DNUMBER}, DNUMBER->{DNAME,DMGRSSN} } F infers the following additional functional dependencies: F {SSN}->{DNAME,DMGRSSN} F {SSN}->{SSN} F {DNUMBER}->{DNAME}

Some important questions Dependency Reasoning A set of dependencies may imply some additional dependencies. Some important questions Given a set of attributes X, what attributes can be determined by X Given an FD set, what other dependencies are implied Given an FD set F, what is the minimum set of dependencies that is equivalent to F

Armstrong’s Axioms Armstrong’s Axioms where X, Y, Z are sets of attributes: Reflexivity: If X Y, then XY. Augmentation: If XY, then XZ YZ for any Z. Transitivity: If X Y and YZ, then XZ.

PROOFS Reflexive rule: If X Y, then XY. Let {t1,t2} r(R) such that t1[X]=t2[X] Since Y X, t1[X]=t2[X] t1[Y]=t2[Y] XY.

PROOFS (Cont’d) Transitive rule: If XY and YZ, then XZ. Let XY and (1) YZ (2) such that t1[X]=t2[X], (3) we have: (1) t1[Y]=t2[Y] (4) (2)&(4) t1[Z]=t2[Z] (5) (3)&(5) XZ

PROOFS (Cont’d) Augmentation rule: If XY, then XZYZ. Assume that the Augmentation rule is not true. t1[X] = t2[X] (1) t1[Y] = t2[Y] (2) t1[XZ] = t2[XZ] (3) t1[YZ] != t2[YZ] (4) (1)&(3) t1[Z]=t2[Z] (5) (2)&(5) t1[YZ]=t2[YZ] (6) (6) Contradicts (4)

Additional Inference Rules for Functional Dependencies Union: If X Y and X  Z, then X  YZ. Decomposition: If XYZ, then XY and XZ. Pseudotransitive Rule: If XY and WYZ then WXZ.

PROOFS (Cont’d) Union rule: If XY and XZ, then XYZ. Given XY and (1) XZ. (2) Applying Augmentation rule on (1), we have XXXY XXY. (3) Applying Augmentation rule on (2), we have XYZY XYYZ . (4) Applying Transitive rule on (3) and (4), we have XYZ.

PROOFS (Cont’d) Decomposition rule: If XYZ then XY and XZ. Given XYZ. (1) Since Y YZ, reflexive rule gives YZY. (2) Applying Transitive rule on (1) and (2), we have XY. XZ is derived in a similar way.

PROOFS (Cont’d) Pseudotransitive rule: If XY and WYZ, then WXZ. Given XY (1) and WYZ. (2) Applying Augmentation rule on (1), we have WXWY. (3) Applying Transitive rule on (3)&(2), we have WXZ.

Exercise Prove or disprove the following inference rules {WY,XZ} |= {WXY} {XY,XW,WYZ} |= {XZ} {XY} |= {XYZ} {XY, Z Y} |= {XZY} Prove using inference rules Disprove by showing a counter example