Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 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

2 Rules about Functional Dependencies The Transitive Rule : If A 1 A 2 A 3 …... A n  B 1 B 2 B 3 ….. B m and B 1 B 2 B 3 …... B n  C 1 C 2 C 3 ….. C K hold in relation R, then A 1 A 2 A 3 …... A n  C 1 C 2 C 3 ….. C K also holds in R.

3 Rules about FD’s The Transitive Rule : If A 1 A 2 A 3 …... A n  B 1 B 2 B 3 ….. B m and B 1 B 2 B 3 …... B n  C 1 C 2 C 3 ….. C K hold in relation R, then A 1 A 2 A 3 …... A n  C 1 C 2 C 3 ….. C K also holds in R. If some of the C’s are among the A’s, we may eliminate them from the right side by the trivial- dependencies rule.

4 Rules about FD’s –A Complete Set Inference Rules Reflexivity. If { B 1 B 2 B 3 ….. B m }  { A 1 A 2 A 3 …... A n }, then A 1 A 2 A 3 …... A n  B 1 B 2 B 3 ….. B m. These are what we have called trivial FD’s. Augmentation. If A 1 A 2 A 3 …... A n  B 1 B 2 B 3 ….. B m, then A 1 A 2 A 3 …... A n C 1 C 2 C 3 ….. C K  B 1 B 2 B 3 ….. B m C 1 C 2 C 3 ….. C K for any set of attributes C 1 C 2 C 3 ….. C K. Transitivity. If A 1 A 2 A 3 …... A n  B 1 B 2 B 3 ….. B m and B 1 B 2 B 3 …... B n  C 1 C 2 C 3 ….. C K then A 1 A 2 A 3 …... A n  C 1 C 2 C 3 ….. C K

5 Design S (Relational DB Schema) Explore in detail the problems that arise when S is flawed Then, use “decomposition” breaking R into two smaller schemas R 1 and R 2 Next, introduce “BCNF” to eliminate these problems Explain how to assure the BCNF condition by decomposing relation schemas

6 FD’s and Normalization Anomalies 1.Redundancy 2.Update Anomalies 3.Deletion Anomalies

7 FD’s and Normalization Decomposing Relations The accepted way to eliminate anomalies is to decompose relations Decomposition of R involves splitting the attributes of R to make the schemas of two new Rs Decompostion rule involves populating those new Rs with tuples by “projecting” the tuples of R

8 FD’s and Normalization After decomposition ==> pick a decomposition that eliminates anomalies Given R  {A 1 A 2 A 3 …... A n } decompose R into S  {B 1 B 2 B 3 ….. B m } and T  {C 1 C 2 C 3 ….. C K } | 1. {A 1 A 2 A 3 …... A n } = {B 1 B 2 B 3 ….. B m }  {C 1 C 2 C 3 ….. C K }. 2.Tuples in relation S are the projections onto {B 1 B 2 B 3 ….. B m }  tuples in R 3.Similarly, tuples in relation T are the projections,onto set of attributes {C 1 C 2 C 3 ….. C K }, of the tuples in the current r(R)

9 Functional Dependencies and Normal Forms BCNF Goal of decomposition => replace a relation by several that do not exhibit anomalies There is a simple condition under which the anomalies mentioned above can be guaranteed not to exist BCNF

10 FDs / NFs BCNF ==> A relation R is BCNF iff: Whenever there is a nontrivial FD A 1 A 2 A 3 …... A n  B for R, it is the case that {A 1 A 2 A 3 …... A n } is a superkey for R, that is the left side of every nontrivial FD must be a superkey

11 FD’s and NF’s The decomposition strategy we shall follow is to look for a nontrivial FD A 1 A 2 A 3 …... A n  B 1 B 2 B 3 ….. B m that violates BCNF==> {A 1 A 2 A 3 …... A n } is not a superkey. As a heuristic, add to the right side as many attributes as are functionally determined by {A 1 A 2 A 3 …... A n }. A’s B’s Others

12 FD’s and Normal Forms title year  length filmType studioName ==> is a BCNF violation!! In this case the right side already includes all the attributes functionally determined by title and year, so use this BCNF violation to decompose Movies into: 1.FD {title, year, length, filmType, studioName} 2.The schema with all attributes of Movies except the three that appear on the right side (length, filmType, and studioName) leaving the second schema: FD {title, year, starName} Both are BCNF!!

13 FD’s and NF’s 4NF => BCNF => 3NF R’s in 3NF R’s in BCNF R’s in 4NF

14 FD’s and NF’s Properties of NF’s and their decompositions: Property3NFBCNF4NF Eliminates redundancyMostYesYes due to FD’s Eliminates redundancyNoNoYes due to MVD’s Preserves FD’sYesMaybeMaybe Preserves MVD’sMaybeMaybeMaybe

15 Introduction to Relational Algebra (Chapter 5) Focus => relational model and describing queries about the content of relations called “Relational Algebra” We will begin by introducing the operations of relational algebra This algebra formally applies to sets of tuples, i.e., relations

16 Introduction to Relational Algebra (Chapter 5) NOTE: Commercial DBMS’s use slightly different model of relations => bags and not sets Bags may contain duplicate tuples! While it is often useful to think of relational algebra as a set algebra, we also need to be conscious of the effects of duplicates on the results of the operations in relational algebra!

17 Introduction to Relational Algebra (Chapter 5) We will learn about a special algebra called relational algebra! These relational algebra operations construct new relations from given relations !!! When the given relations are stored data, then the constructed relations can be answers to queries about this data!

18 Introduction to Relational Algebra (Chapter 5) Basic of Relational Algebra Set Operations on Relations Projection Selection Cartesian Product Natural Joins Theta-Joins


Download ppt "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."

Similar presentations


Ads by Google