© D. Wong 2003 1 Ch. 3 (continued)  Database design problems  Functional Dependency  Keys of relations  Decompositions based on Functional Dependency.

Slides:



Advertisements
Similar presentations
CS 440 Database Management Systems Lecture 4: Constraints, Schema Design.
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.
Database Management COP4540, SCS, FIU Functional Dependencies (Chapter 14)
Relational Normalization Theory. Limitations of E-R Designs Provides a set of guidelines, does not result in a unique database schema Does not provide.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 6 A First Course in Database Systems.
Functional Dependencies - Example
Database Systems The Relational Data Model
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 227 Database Systems I Design Theory for Relational Databases.
Instructor: Amol Deshpande  Data Models ◦ Conceptual representation of the data  Data Retrieval ◦ How to ask questions of the database.
The Relational Model System Development Life Cycle Normalisation
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 8 A First Course in Database Systems.
Closure The closure of {B 1 …B k } under the set of FDs S, denoted by {B 1 …B k } +, is defined as follows: {B 1 …B k } + = {B | any relation satisfies.
Functional Dependencies Definition: If two tuples agree on the attributes A, A, … A 12n then they must also agree on the attributes B, B, … B 12m Formally:
CMSC424: Database Design Instructor: Amol Deshpande
The principal problem that we encounter is redundancy, where a fact is repeated in more than one tuple. Most common cause: attempts to group into one relation.
Winter 2002Arthur Keller – CS 1804–1 Schedule Today: Jan. 15 (T) u Normal Forms, Multivalued Dependencies. u Read Sections Assignment 1 due. Jan.
Normalization I.
1 Functional Dependency and Normalization Informal design guidelines for relation schemas. Functional dependencies. Normal forms. Normalization.
CMSC424: Database Design Instructor: Amol Deshpande
Databases 6: Normalization
Fall 2001Arthur Keller – CS 1804–1 Schedule Today Oct. 4 (TH) Functional Dependencies and Normalization. u Read Sections Project Part 1 due. Oct.
Chapter 14 Advanced Normalization Transparencies © Pearson Education Limited 1995, 2005.
Functional Dependencies and Relational Schema Design.
Chapter 8: Relational Database Design First Normal Form First Normal Form Functional Dependencies Functional Dependencies Decomposition Decomposition Boyce-Codd.
©Silberschatz, Korth and Sudarshan7.1Database System Concepts Chapter 7: Relational Database Design First Normal Form Pitfalls in Relational Database Design.
Chapter 10 Functional Dependencies and Normalization for Relational Databases.
CS 405G: Introduction to Database Systems 16. Functional Dependency.
Normalization Goal = BCNF = Boyce-Codd Normal Form = all FD’s follow from the fact “key  everything.” Formally, R is in BCNF if for every nontrivial FD.
Relational Database Design by Relational Database Design by Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany) DIRECTOR ARUNAI ENGINEERING.
Lecture 6 Normalization: Advanced forms. Objectives How inference rules can identify a set of all functional dependencies for a relation. How Inference.
Schema Refinement and Normal Forms Chapter 19 1 Database Management Systems 3ed, R.Ramakrishnan & J.Gehrke.
Design Theory for Relational Databases 2015, Fall Pusan National University Ki-Joune Li.
BCNF & Lossless Decomposition Prof. Sin-Min Lee Department of Computer Science.
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.
Revisit FDs & BCNF Normalization 1 Instructor: Mohamed Eltabakh
© D. Wong Ch. 2 Entity-Relationship Data Model (continue)  Data models  Entity-Relationship diagrams  Design Principles  Modeling of constraints.
Functional Dependencies. FarkasCSCE 5202 Reading and Exercises Database Systems- The Complete Book: Chapter 3.1, 3.2, 3.3., 3.4 Following lecture slides.
IST 210 Normalization 2 Todd Bacastow IST 210. Normalization Methods Inspection Closure Functional dependencies are key.
1 Functional Dependencies. 2 Motivation v E/R  Relational translation problems : –Often discover more “detailed” constraints after translation (upcoming.
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
© D. Wong Normalization  Purpose: process to eliminate redundancy in relations due to functional or multi-valued dependencies.  Decompose relation.
CS 157B Database Systems Dr. T Y Lin. Updates 1.Red color denotes updated data (ppt) 2.Class participation will be part of “extra” credits to to “quiz.
Chapter 5.1 and 5.2 Brian Cobarrubia Database Management Systems II January 31, 2008.
3 Spring Chapter Normalization of Database Tables.
CS 405G: Introduction to Database Systems Instructor: Jinze Liu Fall 2009.
Functional Dependencies CIS 4301 Lecture Notes Lecture 8 - 2/7/2006.
CS 222 Database Management System Spring Lecture 4 Database Design Theory Korra Sathya Babu Department of Computer Science NIT Rourkela.
Ch 7: Normalization-Part 1
CPSC 603 Database Systems Lecturer: Laurie Webster II, M.S.S.E., M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 5 Introduction to a First Course in Database Systems.
CS411 Database Systems Kazuhiro Minami 04: Relational Schema Design.
Database Management Systems, 3ed, R. Ramakrishnan and J. Gehrke1 Schema Refinement and Normal Forms Chapter 19.
© D. Wong Functional Dependencies (FD)  Given: relation schema R(A1, …, An), and X and Y be subsets of (A1, … An). FD : X  Y means X functionally.
Databases : Functional Dependencies 2007, Fall Pusan National University Ki-Joune Li.
Chapter 8 Relational Database Design. 2 Relational Database Design: Goals n Reduce data redundancy (undesirable replication of data values) n Minimize.
1 CS 430 Database Theory Winter 2005 Lecture 8: Functional Dependencies Second, Third, and Boyce-Codd Normal Forms.
Normalization and FUNctional Dependencies. Redundancy: root of several problems with relational schemas: –redundant storage, insert/delete/update anomalies.
1 Chapter 3 The Relational Data Model. 2 Contents u3.1 Basics of the Relational Model u3.2 From E/R diagrams to Relational Designs u3.4 Functional Dependencies.
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
Advanced Normalization
Relational Database Design by Dr. S. Sridhar, Ph. D
3.1 Functional Dependencies
Advanced Normalization
Normal forms First Normal Form (1NF) Second Normal Form (2NF)
Functional Dependencies and Normalization
Mulitvalued Dependencies
Functional Dependencies
Relational Database Design
Design Theory for Relational Databases
Presentation transcript:

© D. Wong Ch. 3 (continued)  Database design problems  Functional Dependency  Keys of relations  Decompositions based on Functional Dependency (normalization) –Boyce-Codd Normal Form (BCNF) –Third Normal Form –Recovering information from a decomposition  Multivalued Dependencies and decomposition –Fourth Normal Form  Relationships Among Normal Forms

© D. Wong Database Design Problems  Principal kinds of anomalies that constitute bad db design: –Redundancy –Update Anomalies –Deletion Anomalies –Insertion Anomalies  Want to find a good relation schema design for the relational model

© D. Wong Redundancy  Information repeated unnecessarily in several tuples.  Example: –length and filmType for Movie

© D. Wong Update Anomalies  Change information in one tuple but leave the same information unchanged in another  A consequence of redundancy  Cause potential inconsistency  Example: –Change length of Star Wars in one tuple but not the others

© D. Wong Deletion Anomalies  A set of values becomes empty (deleted), may lose other information as side effect  Example: –Deleting the only star listed for the movie Mighty Ducks

© D. Wong Insertion Anomalies  Cannot insert a tuple because some of the data not yet available  Inverse to deletion anomalies  Problem of using null value to fill the missing / unavailable data: –When the data becomes available, will we remember to delete the one with nulls –If the missing data is part of a key, then can’t use null  Example: –Cannot start to keep track of the information of a new movie when the cast is not yet determined

© D. Wong  Dependency is an assertion that only a subset of all possible relations are ‘legal’. An assertion about the real world, cannot be proved.  It’s a form of constraints.  Dependencies in a relation means some sort of redundancy in the legal relations.  Example: title, year  length  Functional dependencies (FD)  Multivalued dependencies (MVD) Dependencies titleyearlengthfilmTypestudioNamestarName Star wars ColorFoxCarrieFisher 1977???ColorFox Mark Hamil

© D. Wong Functional Dependencies (FD)  Given: relation schema R(A1, …, An), and X and Y be subsets of (A1, … An). FD : X  Y means X functionally determines Y e.g. A 1 A 2 …A n  B 1 B 2 …B m  X  Y is an assertion about R that whenever two tuples agree on all the attributes of X, then they must also agree on attributes of Y.  It’s a constraint on the data that may appear within a relation. (i.e. schema level control of data)  It’s a restriction on relations that depend only on the equality or inequality of values, i.e. value-oblivious  It’s the most important type of value-oblivious constraints.  Value-oblivious constraints have the greatest impact for designing database schemas

© D. Wong Significance of Functional Dependencies  Key: 1.Entity set R (A1, …, An), and X is a subset of A1, …, An that form a key for R, then may assert: X  Y where Y is any subset of {A1, …, An} 2.R(A1, …, An) is a many-one relationship from entity set E1 to entity set E2, and among the Ai’s are attributes that form a key X for E1 and a key Y for E2, then may assert: X  Y  Tool for explaining the process of normalization

© D. Wong Representing FD using Relational Algebra  Example 5.31 MovieStar (name, address, gender, birthdate) FD: name  address  (  (MovieStar) x  (MovieStar)) =   MS1.name=MS2.name AND MS1.address  MS2.address (  MS1 (MovieStar) x  MS2 (MovieStar)) = 

© D. Wong Keys in the E/R Model  key for an entity set E is a set K of one or more attributes such that, given any two distinct entities e 1 and e 2 in E, e 1 and e 2 cannot have identical values for each of the attributes in the key K. –A key can consist of more than one attribute –There can be more than one possible key (candidate keys), but designate one as the “primary key”. –Attributes that constitute the primary key cannot be null –If the entity set is in an isa-hierarchy, require the root entity set have all the attributes needed for a key. –In E/R diagram, attributes of a key are underlined

© D. Wong Keys of Relations K is a key for relation R if: 1.K  all attributes of R 2.For no proper subset of K is (1) true (i.e. a key must be minimal) 3.If K at least satisfies (1), then K is a superkey Example: {title, year, starName) forms a key for the Movie relation Superkeys: A set of attributes that contains a key is called a superkey

© D. Wong Discovering Keys for relations Consider relation R: 1. If R comes from an entity set, then the key for the relation is the key attributes of this entity set 2. If R is from a many-many relationship, then the keys of both connected entity sets are the key attributes for R 3. If R is from a many-one relationship from entity set E1 to entity set E2, then the keys attributes of E1 are the key attributes for R 4. If R is from a one-one relationship, then the key attributes for either of the connected entity sets are key attributes of R. More than 1 candidate key in this case.

© D. Wong FD Rules  Splitting / Combining rule  Trivial Dependencies  Armstrong’s Axioms: 1.Reflexivity 2.Augmentatioin 3.Transitivity  Computing closure of attributes  Finding all implied FD’s ( Ref. section: 3.5.7)

© D. Wong Splitting / Combining rule  FD: A 1 A 2 …A n  B 1 B 2 …B m vs. A 1 A 2 …A n  B 1... A 1 A 2 …A n  B m  Splitting rule: replace FD I by the set of FDs II  Combining rule: replace the set of FDs II by FD I I II

© D. Wong Trivial Dependencies  FD A 1 A 2 …A n  B is trivial if B is one of the A’s  Every trivial dependency holds in every relation  For FD A 1 A 2 …A n  B 1 B 2 …B m –Trivial if the B’s are a subset of the A’s e.g. title year  title –Nontrivial if at least one of the B’s is not among the A’s –Completely nontrivial if none of the B’s is also one of the A’s  Trivial-dependency rule: –A 1 A 2 …A n  B 1 B 2 …B m  A 1 A 2 …A n  C 1 C 2 …C k where the C’s are all those B’s that are not also A’s

© D. Wong Armstrong’s Axioms: A set of inference rules: (Pg. 135, 2 nd ed. Pg.99) 1. Reflexivity If {B 1, B 2, …, B m }  {A 1, A 2, …, A n }, then A 1 A 2 …A n  B 1 B 2 …B m. // trivial dependencies 2. Augmentatioin If A 1 A 2 …A n  B 1 B 2 …B m, then A 1 A 2 …A n C 1 …C k  B 1 B 2 …B m C 1 …C k for any set of attributes C 1 …C k 3. Transitivity If A 1 A 2 …A n  B 1 B 2 …B m and B 1 B 2 …B m  C 1 …C k then A 1 A 2 …A n  C 1 …C k