Presentation is loading. Please wait.

Presentation is loading. Please wait.

Databases : Functional Dependencies 2007, Fall Pusan National University Ki-Joune Li.

Similar presentations


Presentation on theme: "Databases : Functional Dependencies 2007, Fall Pusan National University Ki-Joune Li."— Presentation transcript:

1 Databases : Functional Dependencies 2007, Fall Pusan National University Ki-Joune Li

2 STEMPNU 2 Properties of Table (or Relation) We should carefully observe the properties of table  Functional Dependency  Key  Decomposition of Table

3 STEMPNU 3 Definition of Functional Dependency FD (Functional Dependency) on a Relation R  iff A 1 A 2 A 3 … A n  B where A 1, A 2, A 3, …, A n, B are attributes of R  A set of attributes A 1 A 2 A 3 … A n functionally determines B  More than one B’s A 1 A 2 A 3 … A n  B 1 A 1 A 2 A 3 … A n  B 2 … A 1 A 2 A 3 … A n  B k A 1 A 2 A 3 … A n  B 1 B 2 … B k A 1 A 2 A 3 … A n B 1 B 2 B 3 … B k

4 STEMPNU 4 Functional Dependency: Example A Relation  Movies (title, year, length, filmType, studioName, starName) (title year)  length (title year)  filmType (title year)  studioName (title year)  length filmType studioName ? (title year)  starName : more than one star in a film

5 STEMPNU 5 Key Given a relation R  A set of one or more attributes {A 1, A 2, A 3, …, A n } is a KEY iff the set functionally determines all other attributes and no proper subset of {A 1, A 2, A 3, …, A n } functionally determines other attributes (Minimal)  Primary Key: If a relation has more than one keys, a key is defined as primary key  Super Key a set of attributes containing a key No minimality condition Example  Movies (title, year, length, filmType, studioName, starName)  What are keys ?

6 STEMPNU 6 How to discover keys From E-R Diagram: Underlined Attributes  It means that keys are defined based on the understanding of the real world  Example: Movies (title, year, length, filmType, studioName, starName) (year, starName) is not key if a star can make more than one film per year (year, starName) is a key if a star is allowed to make only one film per year Relation (A 1, A 2, B) for relationship between R 1 and R 2  One-One  One-Many  Many-One  Many-Many

7 STEMPNU 7 Rules about Functional Dependencies Functional Dependency  An important property of Relation (or Table)  Some interesting properties or rules of FD Transitive Rule  A  B and B  C then A  C Splitting/Combining Rule  A 1 A 2 A 3 …A n  B 1, A 1 A 2 A 3 …A n  B 2, …, A 1 A 2 A 3 … A n  B k iff A 1 A 2 A 3 … A n  B 1 B 2 … B k Trivial FD Rule: Given a FD A 1 A 2 A 3 …A n  B  FD is trivial if B is one of {A 1 A 2 A 3 …A n } : really trivial  FD is Completely non-trivial: B is not in {A 1 A 2 A 3 …A n }

8 STEMPNU 8 Rules about Functional Dependencies Trivial Dependency Rule  A 1 A 2 … A n  B 1 B 2 … B m is equivalent to A 1 A 2 … A n  C 1 C 2 … C k if {C 1 C 2 … C k }  { B 1 B 2 … B m } and for any C  {C 1 C 2 … C k }, C  {A 1 A 2 … A n }  Example: (year, title)  (studioName, year), (year, title)  studioName Unnecessary A 1 A 2 A 3 … A n C 1 C 2 C 3 … C k B 1 B 2 B 3 … B m

9 STEMPNU 9 Closure of Attributes Closure : {A 1 A 2 … A n } +  {A 1 A 2 … A n } is a set of attributes and S is a set of FD  Closure of {A 1 A 2 … A n } under FS: set of attributes B such that A 1 A 2 … A n  B Example  Given attributes A, B, C, D, E, and F  S: A B  C, B C  A D, D  E, and C F  B What is the closure of { A, B } ?


Download ppt "Databases : Functional Dependencies 2007, Fall Pusan National University Ki-Joune Li."

Similar presentations


Ads by Google