cs 405g: introduction to database systems 26 final exam review chen qian university of kentucky

20
CS 405G: Introduction to Database Systems 26 Final exam review Chen Qian University of Kentucky

Upload: berenice-bryan

Post on 17-Jan-2016

226 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS 405G: Introduction to Database Systems 26 Final exam review Chen Qian University of Kentucky

CS 405G: Introduction to Database Systems

26 Final exam reviewChen Qian

University of Kentucky

Page 2: CS 405G: Introduction to Database Systems 26 Final exam review Chen Qian University of Kentucky

Final exam

Tuesday 05/05/14 10:30 – 12:00 This classroom.

04/21/23 Chen Qian @ University of Kentucky 2

Page 3: CS 405G: Introduction to Database Systems 26 Final exam review Chen Qian University of Kentucky

Read the mid-term review

ER diagram Relational Algebra SQL (important!)

04/21/23 Chen Qian @ Univ of Kentucky

Page 4: CS 405G: Introduction to Database Systems 26 Final exam review Chen Qian University of Kentucky

04/21/23 Chen Qian @ Univ of Kentucky

Functional dependencies

A functional dependency (FD) has the form X -> Y, where X and Y are sets of attributes in a relation R

X -> Y means that whenever two tuples in R agree on all the attributes in X, they must also agree on all attributes in Y

Page 5: CS 405G: Introduction to Database Systems 26 Final exam review Chen Qian University of Kentucky

04/21/23 Chen Qian @ University of Kentucky

FD examples

Address (street_address, city, state, zip) street_address, city, state -> zip zip -> city, state zip, state -> zip?

This is a trivial FD Trivial FD: LHS RHS

zip -> state, zip? This is non-trivial, but not completely non-trivial Completely non-trivial FD: LHS ∩ RHS = ?

5

Page 6: CS 405G: Introduction to Database Systems 26 Final exam review Chen Qian University of Kentucky

04/21/23 Chen Qian @ Univ of Kentucky

Attribute closure

Given R, a set of FD’s F that hold in R, and a set of attributes Z in R:The closure of Z (denoted Z+) with respect to F is the set of all attributes {A1, A2, …} functionally determined by Z (that is, Z -> A1 A2 …)

Algorithm for computing the closure Start with closure = Z If X -> Y is in F and X is already in the closure, then also

add Y to the closure Repeat until no more attributes can be added

Page 7: CS 405G: Introduction to Database Systems 26 Final exam review Chen Qian University of Kentucky

04/21/23 Chen Qian @ University of Kentucky

Using attribute closure

Given a relation R and set of FD’s F Does another FD X -> Y follow from F?

Compute X+ with respect to F If Y X+, then X -> Y follow from F

Is K a super key of R? Compute K+ with respect to F If K+ contains all the attributes of R, K is a super key

Is a super key K a key of R? Test where K’ = K – { a | a K} is a superkey of R for all

possible a

7

Page 8: CS 405G: Introduction to Database Systems 26 Final exam review Chen Qian University of Kentucky

04/21/23 Chen Qian @ University of Kentucky

Rules of FD’s

Armstrong’s axioms Reflexivity: If Y X, then X -> Y Augmentation: If X -> Y, then (X,Z) -> (Y,Z) for any Z Transitivity: If X -> Y and Y -> Z, then X -> Z

Rules derived from axioms Splitting: If X -> YZ, then X -> Y and X -> Z Combining: If X -> Y and X -> Z, then X -> YZ

8

Page 9: CS 405G: Introduction to Database Systems 26 Final exam review Chen Qian University of Kentucky

First Normal Form ( 1NF )

A relation is in first normal form if the domain of each attribute contains only atomic values, and the value of each attribute contains only a single value from that domain.

04/21/23 Chen Qian @ University of Kentucky 9

Page 10: CS 405G: Introduction to Database Systems 26 Final exam review Chen Qian University of Kentucky

04/21/23 Chen Qian @ University of Kentucky 10

2nd Normal Form

An attribute A of a relation R is a nonprimary attribute if it is not part of any key in R, otherwise, A is a primary attribute.

R is in (general) 2nd normal form if every nonprimary attribute A in R is not partially functionally dependent on any key of R

How to identify 2NF How to decompose relations

Page 11: CS 405G: Introduction to Database Systems 26 Final exam review Chen Qian University of Kentucky

Third normal form

• 3NF requires that there are no non-trivial functional dependencies of non-key attributes on something other than a superset of a candidate key.

• Recall: non-trivial FD means LHS has no intersection with RHS.

• In summary, all non-key attributes are mutually independent.

04/21/23 Chen Qian @ University of Kentucky 11

Page 12: CS 405G: Introduction to Database Systems 26 Final exam review Chen Qian University of Kentucky

• A table is said to be in the BCNF if and only if it is in the 3NF and every non-trivial, left-irreducible functional dependency has a candidate key as its determinant.

•How to find violations

•How to decompose relations

04/21/23 Chen Qian @ University of Kentucky 12

BC normal form

Page 13: CS 405G: Introduction to Database Systems 26 Final exam review Chen Qian University of Kentucky

04/21/23 Chen Qian @ University of Kentucky 13

Conflicts

precedence graph conflict-serializable schedule

Page 14: CS 405G: Introduction to Database Systems 26 Final exam review Chen Qian University of Kentucky

04/21/23 Chen Qian @ University of Kentucky 14

Lock

exclusive lock and shared locks

Two-phase locking All lock requests precede all unlock requests

Strict 2PL Only release locks at commit/abort time

Examples

Page 15: CS 405G: Introduction to Database Systems 26 Final exam review Chen Qian University of Kentucky

04/21/23 Chen Qian @ University of Kentucky 15

Disk

Disk structure Cylinder, platter, track, etc.

Random disk access Seek time + rotational delay + transfer time

Page 16: CS 405G: Introduction to Database Systems 26 Final exam review Chen Qian University of Kentucky

File Storage

Heap file as a list or page directory Record format Page layout

04/21/23 Chen Qian @ University of Kentucky 16

Page 17: CS 405G: Introduction to Database Systems 26 Final exam review Chen Qian University of Kentucky

Tree-Structured Indexes: Introduction

Tree-structured indexing techniques support both range selections and equality selections.

ISAM =Indexed Sequential Access Method static structure; early index technology.

B+ tree: dynamic, adjusts gracefully under inserts and deletes.

Operations: search, range query, insert, delete (important!)

Understand the examples in the exercise slides!

04/21/23 Chen Qian @ University of Kentucky 17

Page 18: CS 405G: Introduction to Database Systems 26 Final exam review Chen Qian University of Kentucky

Hashing

Static hashing

Dynamic hashing Extensible and linear hashing

Understand examples in slides

04/21/23 Chen Qian @ University of Kentucky 18

Page 19: CS 405G: Introduction to Database Systems 26 Final exam review Chen Qian University of Kentucky

Final Exam

1. True/False 2. Functional Dependency and Normal Forms 3. SQL 4. Index (B+ Tree) 5. Index (B+ Tree) 6. Storage

04/21/23 Chen Qian @ University of Kentucky 19

Page 20: CS 405G: Introduction to Database Systems 26 Final exam review Chen Qian University of Kentucky

Good luck and hope you enjoy this class!

Don’t forget: You give me a grade

04/21/23 Chen Qian @ University of Kentucky 20