Final Review Zaki Malik November 20, 2008. Basic Operators Covered.

Slides:



Advertisements
Similar presentations
DB Review Session. ER Diagrams 1 Where does the salary attribute belong? Actor id name address birthday Acted In Movie title type year salary.
Advertisements

1 TRC vs DRC 한욱신. 2 Queries in TRC and DRC  TRC Q = {t| f(t)} where t is a (free) tuple variable and f(t) is a well-formed formula  DRC.
4NF and 5NF Prof. Sin-Min Lee Department of Computer Science.
SQL and Relational Algebra Zaki Malik September 02, 2008.
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.
SQL Review.
4NF. PTypes Planes HasType Employees MServices Auth. MWorks Assignment AppliedOn States Dates PTypes(model, capacity,…) Planes(regno, model) Employees(sin,…)
Multivalued Dependency Prof. Sin-Min Lee Department of Computer Science.
1 Multi-valued Dependencies Salman Azhar Multi-valued Dependencies Fourth Normal Form These slides use some figures, definitions, and explanations from.
1 Multivalued Dependencies Fourth Normal Form Source: Slides by Jeffrey Ullman.
1 Multivalued Dependencies Fourth Normal Form. 2 Definition of MVD uA multivalued dependency (MVD) on R, X ->->Y, says that if two tuples of R agree on.
1 SQL (Simple Query Language). 2 Query Components A query can contain the following clauses –select –from –where –group by –having –order by Only select.
1 Multivalued Dependencies Fourth Normal Form Sources: Slides by Jeffrey Ullman book by Ramakrishnan & Gehrke.
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:
Lecture #3 Functional Dependencies Normalization Relational Algebra Thursday, October 12, 2000.
Multivalued Dependency Prof. Sin-Min Lee Department of Computer Science.
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.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Relational Algebra Chapter 4, Part A.
Fall 2001Arthur Keller – CS 1805–1 Schedule Today Oct. 9 (T) Multivalued Dependencies, Relational Algebra u Read Sections 3.7, Assignment 2 due.
1 The Oracle Database System Querying the Data Database Course The Hebrew University of Jerusalem.
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.
Relation Decomposition A, A, … A 12n Given a relation R with attributes Create two relations R1 and R2 with attributes B, B, … B 12m C, C, … C 12l Such.
Functional Dependencies and Relational Schema Design.
Relational Algebra.
Midterm Review Zaki Malik October 09, Basic Operators Covered.
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.
SCUJ. Holliday - coen 1784–1 Schedule Today: u Normal Forms. u Section 3.6. Next u Relational Algebra. Read chapter 5 to page 199 After that u SQL Queries.
BCNF & Lossless Decomposition Prof. Sin-Min Lee Department of Computer Science.
SQL Part I: Standard Queries. COMP-421: Database Systems - SQL Queries I 2 Example Instances sid sname rating age 22 debby debby lilly.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Relational Algebra.
Database Management Systems 1 Raghu Ramakrishnan Database Design Review Aug 24, 2015 Instructor: Xintao Wu.
Functional Dependencies. FarkasCSCE 5202 Reading and Exercises Database Systems- The Complete Book: Chapter 3.1, 3.2, 3.3., 3.4 Following lecture slides.
4NF (Multivalued Dependency), and 5NF (Join Dependency)
IST 210 Normalization 2 Todd Bacastow IST 210. Normalization Methods Inspection Closure Functional dependencies are key.
1 Lecture 7: Normal Forms, Relational Algebra Monday, 10/15/2001.
© D. Wong Ch. 3 (continued)  Database design problems  Functional Dependency  Keys of relations  Decompositions based on Functional Dependency.
© D. Wong Normalization  Purpose: process to eliminate redundancy in relations due to functional or multi-valued dependencies.  Decompose relation.
Functional Dependencies and Relational Schema Design.
1 Multivalued Dependencies Fourth Normal Form Reasoning About FD’s + MVD’s.
1 Multivalued Dependencies Fourth Normal Form Reasoning About FD’s + MVD’s.
CMPT 258 Database Systems SQL Queries (Chapter 5).
3 Spring Chapter Normalization of Database Tables.
Multivalued Dependencies and 4th NF CIS 4301 Lecture Notes Lecture /21/2006.
Functional Dependencies Zaki Malik September 25, 2008.
CS411 Database Systems Kazuhiro Minami 04: Relational Schema Design.
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.
1 Lecture 9: Database Design Wednesday, January 25, 2006.
1 CS122A: Introduction to Data Management Lecture #7 Relational Algebra I Instructor: Chen Li.
1 SQL: The Query Language. 2 Example Instances R1 S1 S2 v We will use these instances of the Sailors and Reserves relations in our examples.
1 CS122A: Introduction to Data Management Lecture 8 Introduction to SQL Instructor: Chen Li.
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.
Formal definition of a key A key is a set of attributes A 1,..., A n such that for any other attribute B: A 1,..., A n  B A minimal key is a set of attributes.
Database Systems (資料庫系統)
CS411 Database Systems 08: Midterm Review Kazuhiro Minami 1.
Schedule Today: Jan. 23 (wed) Week of Jan 28
Relational Algebra Chapter 4, Part A
Database Systems 10/13/2010 Lecture #4.
BCNF and Normalization
CPSC-310 Database Systems
Multivalued Dependencies & Fourth Normal Form (4NF)
Mulitvalued Dependencies
Multivalued Dependencies & Fourth Normal Form
Multivalued Dependencies & Fourth Normal Form
Multivalued Dependencies
Presentation transcript:

Final Review Zaki Malik November 20, 2008

Basic Operators Covered

Renaming If two relations have the same attribute, disambiguate the attributes by prefixing the attribute with the name of the relation it belongs to. How do we answer the query “Name pairs of students who live at the same address”? Students(Name, Address) – We need to take the cross-product of Students with itself? – How do we refer to the two “copies” of Students? – Use the rename operator. RA: : give R the name S; R has n attributes, which are called A 1,A 2,...,A n in S SQL: Use the AS keyword in the FROM clause: Students AS Students1 renames Students to Students1. SQL: Use the AS keyword in the SELECT clause to rename attributes. S ( A 1,A 2,... A n ) (R)

Q5: Find the names of sailors who have reserved a red or a green boat Reserves(sid, bid, day) Sailors(sid, sname, rating, age) Boats(bid, bname, color) Solution: π sname (σ color= ‘ red ’ or color = ‘ green ’ Boats ∞ Reserves ∞ Sailors) Reserves(sid, bid, day) Sailors(sid, sname, rating, age) Boats(bid, bname, color)

Q6: Find the names of sailors who have reserved a red and a green boat Reserves(sid, bid, day) Sailors(sid, sname, rating, age) Boats(bid, bname, color) Solution: π sname (σ color= ‘ red ’ and color = ‘ green ’ Boats ∞ Reserves ∞ Sailors) Reserves(sid, bid, day) Sailors(sid, sname, rating, age) Boats(bid, bname, color) A ship cannot have TWO colors at the same time π sname (σ color= ‘ red ’ Boats ∞ Reserves ∞ Sailors) ∩ π sname (σ color = ‘ green ’ Boats ∞ Reserves ∞ Sailors)

Basic SQL Query SELECT [DISTINCT] target-list FROM relation-list WHERE qualification; Relation-list: A list of relation names (possibly with range- variable after each name). Target-list: A list of attributes of relations in relation-list Qualification: conditions on attributes DISTINCT: optional keyword for duplicate removal. – Default = no duplicate removal!

7 Representing “Multiplicity” Show a many-one relationship by an arrow entering the “one” side. Show a one-one relationship by arrows entering both entity sets. In some situations, we can also assert “exactly one,” i.e., each entity of one set must be related to exactly one entity of the other set. To do so, we use a rounded arrow. Many One One ) Exactly One

11 Triviality of FDs

Boyce-Codd Normal Form

Closures of FDs vs. Closures of Attributes

Checking for BCNF Violations

Decomposition into BCNF

Decomposing Courses

Third Normal Form (3NF)

19 Definition of MVD A multivalued dependency (MVD) X ->->Y is an assertion that if two tuples of a relation agree on all the attributes of X, then their components in the set of attributes Y may be swapped, and the result will be two tuples that are also in the relation.

20 Definition of MVD

Example t v u

22 MVD Rules Every FD is an MVD – If X ->Y, then swapping Y ’s between two tuples that agree on X doesn’t change the tuples. – Therefore, the “new” tuples are surely in the relation, and we know X ->->Y. Definition of keys depend on FDs and not MDs

23 4NF Definition A relation R is in 4NF if whenever X ->->Y is a nontrivial MVD, then X is a superkey. – Nontrivial means that: 1.Y is not a subset of X, and 2.X and Y are not, together, all the attributes. – Note that the definition of “superkey” still depends on FD’s only.

24 Decomposition and 4NF If X ->->Y is a 4NF violation for relation R, we can decompose R using the same technique as for BCNF. 1.XY is one of the decomposed relations. 2.All but Y – X is the other.

25 Example Drinkers(name, addr, phones, beersLiked) FD: name -> addr MVD’s: name ->-> phones name ->-> beersLiked Key is – {name, phones, beersLiked}. Which dependencies violate 4NF ? – All

26 Example, Continued Decompose using name -> addr: 1.Drinkers1(name, addr)  In 4NF, only dependency is name -> addr. 2.Drinkers2(name, phones, beersLiked)  Not in 4NF. MVD’s name ->-> phones and name ->-> beersLiked apply.  Key ?  No FDs, so all three attributes form the key.

27 Example: Decompose Drinkers2 Either MVD name ->-> phones or name ->-> beersLiked tells us to decompose to: – Drinkers3(name, phones) – Drinkers4(name, beersLiked)

Midterm Points Distribution In Order of Point Percentage – FDs, MDs, Normalization – Relational Algebra and SQL – ER Modeling