Functional Dependencies. Babies Exercise 2.2.5: At a birth, there is one baby (twins would be represented by two births), one mother, any number of nurses,

Slides:



Advertisements
Similar presentations
1 Lecture 7 Design Theory for Relational Databases (part 1) Slides based on
Advertisements

1 Design Theory for Relational Databases Functional Dependencies Decompositions Normal Forms.
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.
Database Management Systems Chapter 3 The Relational Data Model (II) Instructor: Li Ma Department of Computer Science Texas Southern University, Houston.
Functional Dependencies - Example
1 Convert E/R to Relation May 18, Entity Set -> Relation Relation: Beers(name, manf) Beers name manf.
Topics to be discusses Functional Dependency Key
Chapter 4 Notes. Entity-Relationship Model E/R Diagrams Weak Entity Sets Converting E/R Diagrams to Relations.
Functional Dependencies, Normalization Rose-Hulman Institute of Technology Curt Clifton.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 227 Database Systems I Design Theory for Relational Databases.
Functional Dependencies
Functional Dependencies. Babies At a birth, there is one baby (twins would be represented by two births), one mother, any number of nurses, and a doctor.
Design Principles: Faithfulness
Entity-Relationship Model. The process of designing a database begins with: –an analysis of what information the database must hold, and –the relationships.
Design Principles: Faithfulness
1 The Relational Data Model Functional Dependencies.
The Relational Data Model Database Model (E/R) Relational Schema Physical storage Diagrams (E/R) Tables: row names: attributes rows: tuples Complex file.
1 Functional Dependencies Meaning of FD’s Keys and Superkeys Inferring FD’s.
Movies length titleyearfilmType Voices isa Cartoons isa MurderMystery weapon toStar Our Movie Example.
1 Functional Dependencies Meaning of FD’s Keys and Superkeys Inferring FD’s Source: slides by Jeffrey Ullman.
Entity-Relationship Model
A four-way Relationship
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.
1 Multivalued Dependencies Fourth Normal Form. 2 A New Form of Redundancy uMultivalued dependencies (MVD’s) express a condition among tuples of a relation.
Operations in the Relational Model These operation can be expressed in an algebra, called “relational algebra”. In this algebra relations are the operands.
1 Normalization Anomalies Boyce-Codd Normal Form 3 rd Normal Form.
From E/R Diagrams to Relations. The Relational Data Model Database Model (E/R) Relational Schema Physical storage Diagrams (E/R) Tables: row names: attributes.
Fall 2001Arthur Keller – CS 1803–1 Schedule Today Oct. 2 (T) Relational Model. u Read Sections Assignment 1 due. Personal Letter of Introduction.
Bad DB Design Duplicate of data Duplicate of data Updating Updating Deleting Deleting.
Fall 2001Arthur Keller – CS 1804–1 Schedule Today Oct. 4 (TH) Functional Dependencies and Normalization. u Read Sections Project Part 1 due. Oct.
CS411 Database Systems Kazuhiro Minami
1 Design Theory for Relational Databases Functional Dependencies Decompositions Normal Forms.
Database Management Systems Chapter 3 The Relational Data Model (III) Instructor: Li Ma Department of Computer Science Texas Southern University, Houston.
Databases 1 Seventh lecture. Topics of the lecture Extended relational algebra Normalization Normal forms 2.
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.
© D. Wong Ch. 2 Entity-Relationship Data Model (continue)  Data models  Entity-Relationship diagrams  Design Principles  Modeling of constraints.
Entity-Relationship Model
Functional Dependencies. FarkasCSCE 5202 Reading and Exercises Database Systems- The Complete Book: Chapter 3.1, 3.2, 3.3., 3.4 Following lecture slides.
1 IT 244 Database Management System Topic 7 The Relational Data Model Functional Dependencies Ref : -A First Course in Database System (Jeffrey D Ullman,
IST 210 Normalization 2 Todd Bacastow IST 210. Normalization Methods Inspection Closure Functional dependencies are key.
© D. Wong Ch. 3 (continued)  Database design problems  Functional Dependency  Keys of relations  Decompositions based on Functional Dependency.
Home Work. Design Principles and Weak Entity Sets.
1 Multivalued Dependencies Fourth Normal Form Reasoning About FD’s + MVD’s.
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
1 Functional Dependencies 函数依赖 Meaning of FD’s Keys and Superkeys Functional Dependencies.
1 The Relational Data Model Tables Schemas Conversion from E/R to Relations Functional Dependencies.
Functional Dependencies Zaki Malik September 25, 2008.
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.
Databases 1 Sixth lecture. 2 Functional Dependencies X -> A is an assertion about a relation R that whenever two tuples of R agree on all the attributes.
© 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.
© D. Wong Ch. 3 (part 1)  Relational Model basics  From E/R diagram to Relations.
Lecture # 17 Chapter # 10 Normalization Database Systems.
Design Theory for Relational Databases Functional Dependencies Decompositions Normal Forms: BCNF, Third Normal Form Introduction to Multivalued Dependencies.
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.
4NF & MULTIVALUED DEPENDENCY By Kristina Miguel. Review  Superkey – a set of attributes which will uniquely identify each tuple in a relation  Candidate.
1 Database Design: DBS CB, 2 nd Edition Physical RDBMS Model: Schema Design and Normalization Ch. 3.
Design Theory for Relational Databases
CPSC-310 Database Systems
Transforming E/R to Relational Model.
Multivalued Dependencies & Fourth Normal Form (4NF)
Exercise R(A,B,C,D) with FD’s ABC, CD, and DA
Multivalued Dependencies & Fourth Normal Form
Multivalued Dependencies & Fourth Normal Form
Functional Dependencies
SQL – Constraints & Triggers
Multivalued Dependencies
Anomalies Boyce-Codd Normal Form 3rd Normal Form
Presentation transcript:

Functional Dependencies

Babies Exercise 2.2.5: At a birth, there is one baby (twins would be represented by two births), one mother, any number of nurses, and any number of doctors. Suppose, therefore, that we have entity sets Babies, Mothers, Nurses, and Doctors. Suppose we also use a relationship Births, which connects these four entity sets. Note that a tuple of the relationship set for Births has the form (baby, mother, nurse, doctor)

Babies (Cont’ed) There are certain assumptions that we might wish to incorporate into our design. For each, tell how to add arrows or other elements to the E/R diagram in order to express the assumption. a) For every baby, there is a unique mother. b) For every combination of a baby, nurse, and doctor, there is a unique mother. c) For every combination of a baby and a mother there is a unique doctor.

Functional Dependencies X -> A is an assertion about a relation R that whenever two tuples of R agree on all the attributes of X, then they must also agree on the attribute A. –Say “X -> A holds in R.” –Convention: …, X, Y, Z represent sets of attributes; A, B, C,… represent single attributes. –Convention: no set formers in sets of attributes, just ABC, rather than {A,B,C}.

Let’s consider the relation: –Movie(title, year, length, filmType, studioName, starName). There are several functional dependencies that we can reasonably assert. title year  length title year  filmType shorthand: title year  length filmType studioName title year  studioName These assertions make sense if we remember the original design: –Attributes title and year form a key for movie objects. –Thus, given a title and a year there is a unique length, filmType and a unique owning studio. Functional Dependencies - Example

Example Drinkers(name, addr, beersLiked, manf, favBeer) Reasonable FD’s to assert: 1.name -> addr 2.name -> favBeer 3.beersLiked -> manf

Example Data nameaddr beersLiked manffavBeer JanewayVoyager Bud A.B.WickedAle JanewayVoyager WickedAle Pete’sWickedAle SpockEnterprise Bud A.B.Bud Because name -> addr Because name -> favBeer Because beersLiked -> manf

FD’s With Multiple Attributes No need for FD’s with > 1 attribute on right. –But sometimes convenient to combine FD’s as a shorthand. –Example: name -> addr and name -> favBeer become name -> addr favBeer > 1 attribute on left may be essential. –Example: bar beer -> price

K is a superkey for relation R if K functionally determines all of R. K is a key for R if K is a superkey, but no proper subset of K is a superkey. Example. Attributes {title, year, starName} form a key for the previous Movie relation. Why? Keys of Relations

Because the first property of keyness is satisfied: –title year functionally determines length, filmType and studioName. So does their superset {title, year, starName}. –starName functionally determines itself (starName). So does the superset {title, year, starName}. –Concluding title, year, starName functionally determine all the attributes. And, also the second property of keyness is satisfied: No proper subset of {title, year, starName} functionally determines all attributes. –{title, year} do not determine starName, because a movie can have many stars. –{year, starName} do not determine title, because we can have a star in two movies in the same year. –{title, starName} do not determine let’s say year, because we could have two movies with the same title made in different years. It can be the case these two movies to have a star in common. It is very difficult to find such cases. However, if we make {title, starName} key, then we prohibit the user to insert a new movie, which has the same title as a previous inserted old movie, and where a star plays again (not necessary in the same role). Remember, the constraints are supposed to hold for all the instances, not only for the current DB instance. Keys of Relations (Continued)