









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










Computing & Information Sciences CIS 560: Database System Concepts Friday, 29 Sep 2006 Kansas State University
Friday, 29 September 2006
William H. Hsu Department of Computing and Information Sciences, KSU
KSOL course page: http://snipurl.com/va Course web site: http://www.kddresearch.org/Courses/Fall-2006/CIS Instructor home page: http://www.cis.ksu.edu/~bhsu
Reading for Next Class: First half of Chapter 7, Silberschatz et al. , 5 th^ edition
Computing & Information Sciences CIS 560: Database System Concepts Friday, 29 Sep 2006 Kansas State University
z Features of Good Relational Design z Atomic Domains and First Normal Form z Decomposition Using Functional Dependencies z Functional Dependency Theory z Algorithms for Functional Dependencies z Decomposition Using Multivalued Dependencies z More Normal Form z Database-Design Process z Modeling Temporal Data
Computing & Information Sciences CIS 560: Database System Concepts Friday, 29 Sep 2006 Kansas State University
z Suppose we combine borrow and loan to get bor_loan = ( customer_id , loan_number , amount ) z Result is possible repetition of information (L-100 in example below)
Computing & Information Sciences CIS 560: Database System Concepts Friday, 29 Sep 2006 Kansas State University
z Consider combining loan_branch and loan loan_amt_br = ( loan_number , amount , branch_name ) z No repetition (as suggested by example below)
Computing & Information Sciences CIS 560: Database System Concepts Friday, 29 Sep 2006 Kansas State University
z Domain is atomic if its elements are considered to be indivisible units Examples of non-atomic domains: Ö Set of names, composite attributes Ö Identification numbers like CS101 that can be broken up into parts z A relational schema R is in first normal form if the domains of all attributes of R are atomic z Non-atomic values complicate storage and encourage redundant (repeated) storage of data Example: Set of accounts stored with each customer, and set of owners stored with each account We assume all relations are in first normal form (and revisit this in Chapter 9)
Computing & Information Sciences CIS 560: Database System Concepts Friday, 29 Sep 2006 Kansas State University
z Atomicity is actually a property of how the elements of the domain are used. Example: Strings would normally be considered indivisible Suppose that students are given roll numbers which are strings of the form CS0012 or EE If the first two characters are extracted to find the department, the domain of roll numbers is not atomic. Doing so is a bad idea: leads to encoding of information in application program rather than in the database.
Computing & Information Sciences CIS 560: Database System Concepts Friday, 29 Sep 2006 Kansas State University
z Decide whether a particular relation R is in “good” form. z In the case that a relation R is not in “good” form, decompose it into a set of relations { R 1 , R 2 , ..., R (^) n } such that each relation is in good form the decomposition is a lossless-join decomposition z Our theory is based on: functional dependencies multivalued dependencies
Computing & Information Sciences CIS 560: Database System Concepts Friday, 29 Sep 2006 Kansas State University
z Constraints on the set of legal relations. z Require that the value for a certain set of attributes determines uniquely the value for another set of attributes. z A functional dependency is a generalization of the notion of a key.
Computing & Information Sciences CIS 560: Database System Concepts Friday, 29 Sep 2006 Kansas State University
z We use functional dependencies to: test relations to see if they are legal under a given set of functional dependencies. Ö If a relation r is legal under a set F of functional dependencies, we say that r satisfies F. specify constraints on the set of legal relations Ö We say that F holds on R if all legal relations on R satisfy the set of functional dependencies F. z Note: A specific instance of a relation schema may satisfy a functional dependency even if the functional dependency does not hold on all legal instances. For example, a specific instance of loan may, by chance, satisfy amount → customer_name.
Computing & Information Sciences CIS 560: Database System Concepts Friday, 29 Sep 2006 Kansas State University
z A functional dependency is trivial if it is satisfied by all instances of a relation Example : Ö customer_name, loan_number → customer_name Ö customer_name → customer_name In general, α →β is trivial if β ⊆ α
Computing & Information Sciences CIS 560: Database System Concepts Friday, 29 Sep 2006 Kansas State University
z Given a set F set of functional dependencies, there are certain other functional dependencies that are logically implied by F. For example: If A → B and B → C , then we can infer that A → C z The set of all functional dependencies logically implied by F is the closure of F. z We denote the closure of F by F +. z F+^ is a superset of F.
Computing & Information Sciences CIS 560: Database System Concepts Friday, 29 Sep 2006 Kansas State University
z α is a superkey for R
A relation schema R is in BCNF with respect to a set F of functional dependencies if for all functional dependencies in F +^ of the form
α →β
where α ⊆ R and β ⊆ R , at least one of the following holds:
Example schema not in BCNF:
bor_loan = ( customer_id, loan_number, amount )
because loan_number → amount holds on bor_loan but loan_number is not a superkey
Computing & Information Sciences CIS 560: Database System Concepts Friday, 29 Sep 2006 Kansas State University
z A relation schema R is in third normal form (3NF) if for all:
at least one of the following holds: α →β is trivial (i.e., β ∈ α) α is a superkey for R Each attribute A in β – α is contained in a candidate key for R. ( NOTE : each attribute may be in a different candidate key) z If a relation is in BCNF it is in 3NF (since in BCNF one of the first two conditions above must hold). z Third condition is a minimal relaxation of BCNF to ensure dependency preservation (will see why later).
Computing & Information Sciences CIS 560: Database System Concepts Friday, 29 Sep 2006 Kansas State University
z Let R be a relation scheme with a set F of functional dependencies. z Decide whether a relation scheme R is in “good” form. z In the case that a relation scheme R is not in “good” form, decompose it into a set of relation scheme { R 1 , R 2 , ..., R (^) n } such that each relation scheme is in good form the decomposition is a lossless-join decomposition Preferably, the decomposition should be dependency preserving.
Computing & Information Sciences CIS 560: Database System Concepts Friday, 29 Sep 2006 Kansas State University
z There are database schemas in BCNF that do not seem to be sufficiently normalized z Consider a database classes ( course, teacher, book )
such that ( c, t, b ) ∈ classes means that t is qualified to teach c, and b is a required textbook for c z The database is supposed to list for each course the set of teachers any one of which can be the course’s instructor, and the set of books, all of which are required for the course (no matter who teaches it).
Computing & Information Sciences CIS 560: Database System Concepts Friday, 29 Sep 2006 Kansas State University
z There are no non-trivial functional dependencies and therefore the relation is in BCNF z Insertion anomalies – i.e., if Marilyn is a new teacher that can teach database, two tuples need to be inserted (database, Marilyn, DB Concepts) (database, Marilyn, Ullman)
course teacher book database database database database database database operating systems operating systems operating systems operating systems
Avi Avi Hank Hank Sudarshan Sudarshan Avi Avi Pete Pete
DB Concepts Ullman DB Concepts Ullman DB Concepts Ullman OS Concepts Stallings OS Concepts Stallings classes
Computing & Information Sciences CIS 560: Database System Concepts Friday, 29 Sep 2006 Kansas State University
z Given a set F set of functional dependencies, there are certain other functional dependencies that are logically implied by F. For example: If A → B and B → C , then we can infer that A → C z The set of all functional dependencies logically implied by F is the closure of F. z We denote the closure of F by F+. z We can find all of F +^ by applying Armstrong’s Axioms: if β ⊆ α, then α →β (reflexivity) if α →β , then γ α → γβ (augmentation) if α →β , and β → γ, then α → γ (transitivity) z These rules are sound (generate only functional dependencies that actually hold) and complete (generate all functional dependencies that hold).
Computing & Information Sciences CIS 560: Database System Concepts Friday, 29 Sep 2006 Kansas State University
z R = (A, B, C, G, H, I) F = { A → B A → C CG → H CG → I B → H } z some members of F + A → H Ö by transitivity from A → B and B → H AG → I Ö by augmenting A → C with G, to get AG → CG and then transitivity with CG → I CG → HI Ö by augmenting CG → I to infer CG → CG I, and augmenting of CG → H to infer CGI → HI, and then transitivity
Computing & Information Sciences CIS 560: Database System Concepts Friday, 29 Sep 2006 Kansas State University
z To compute the closure of a set of functional dependencies F:
repeat for each functional dependency f in F + apply reflexivity and augmentation rules on f add the resulting functional dependencies to F + for each pair of functional dependencies f 1 and f 2 in F + if f 1 and f 2 can be combined using transitivity then add the resulting functional dependency to F + until F +^ does not change any further
NOTE : We shall see an alternative procedure for this task later
Computing & Information Sciences CIS 560: Database System Concepts Friday, 29 Sep 2006 Kansas State University
z We can further simplify manual computation of F +^ by using the following additional rules. If α →β holds a nd α → γ holds, then α →β γ holds (union) If α →β γ holds, then α →β holds and α → γ holds (decomposition) If α →β holds a nd γβ → δ holds, then α γ → δ holds (pseudotransitivity) The above rules can be inferred from Armstrong’s axioms.
Computing & Information Sciences CIS 560: Database System Concepts Friday, 29 Sep 2006 Kansas State University
There are several uses of the attribute closure algorithm: z Testing for superkey: To test if α is a superkey, we compute α+,^ and check if α+^ contains all attributes of R. z Testing functional dependencies To check if a functional dependency α → β holds (or, in other words, is in F +^ ), just check if β ⊆ α+. That is, we compute α+^ by using attribute closure, and then check if it contains β. Is a simple and cheap test, and very useful z Computing closure of F For each γ ⊆ R, we find the closure γ+, and for each S ⊆ γ+, we output a functional dependency γ → S.
Computing & Information Sciences CIS 560: Database System Concepts Friday, 29 Sep 2006 Kansas State University
z Sets of functional dependencies may have redundant dependencies that can be inferred from the others For example: A → C is redundant in: { A → B , B → C } Parts of a functional dependency may be redundant Ö E.g.: on RHS: { A → B , B → C , A → CD } can be simplified to { A → B , B → C , A → D } Ö E.g.: on LHS: {A → B , B → C , AC → D } can be simplified to {A → B , B → C , A → D } z Intuitively, a canonical cover of F is a “minimal” set of functional dependencies equivalent to F, having no redundant dependencies or redundant parts of dependencies