Relational Database Design (Discussion Session)

Slides:



Advertisements
Similar presentations
Schema Refinement: Normal Forms
Advertisements

Schema Refinement: Canonical/minimal Covers
Schema Refinement and Normal Forms
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 16 Relational Database Design Algorithms and Further Dependencies.
Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources.
Logical Database Design (3 of 3) John Ortiz. Lecture 7Logical Database Design (2)2 Normalization  If a relation is not in BCNF or 3NF, we refine it by.
CS 440 Database Management Systems Practice problems for normalization.
Review for Final Exam Lecture Week 14. Problems on Functional Dependencies and Normal Forms.
1 Design Theory. 2 Minimal Sets of Dependancies A set of dependencies is minimal if: 1.Every right side is a single attribute 2.For no X  A in F and.
CS Algorithm : Decomposition into 3NF  Obviously, the algorithm for lossless join decomp into BCNF can be used to obtain a lossless join decomp.
Classroom Exercise: Normalization
Normalization DB Tuning CS186 Final Review Session.
Normalization DB Tuning CS186 Final Review Session.
Normal Form Design addendum by C. Zaniolo. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts Normal Form Design Compute the canonical cover.
Cs3431 Normalization Part II. cs3431 Attribute Closure : Example Consider R (A, B, C, D, E) with FDs A  B, B  C, CD  E Does A  E hold ? (Is A  E.
Database Systems Normal Forms. Decomposition Suppose we have a relation R[U] with a schema U={A 1,…,A n } – A decomposition of U is a set of schemas.
Normal Forms1. 2 The Problems of Redundancy Redundancy is at the root of several problems associated with relational schemas: Wastes storage Causes problems.
CS143 Review: Normalization Theory Q: Is it a good table design? We can start with an ER diagram or with a large relation that contain a sample of the.
THIRD NORMAL FORM (3NF) A relation R is in BCNF if whenever a FD XA holds in R, one of the following statements is true: XA is a trivial FD, or X is.
R EVIEW. 22 Exam Su 3:30PM - 6:30PM 2010/12/12 Room C9000.
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
CS 405G: Introduction to Database Systems Instructor: Jinze Liu Fall 2009.
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
© 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.
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
Functional Dependencies and Normalization 1 Instructor: Mohamed Eltabakh Part 2.
Advanced Normalization
Design Theory for Relational Databases
CS 440 Database Management Systems
Design Theory for RDB Normal Forms.
Schedule Today: Next After that Normal Forms. Section 3.6.
Schema Refinement and Normal Forms
CS411 Database Systems 08: Midterm Review Kazuhiro Minami 1.
Module 5: Overview of Database Design -- Normalization
Normalization First Normal Form (1NF) Boyce-Codd Normal Form (BCNF)
Canonical Cover & Normal Forms
Relational Database Design
CS 480: Database Systems Lecture 22 March 6, 2013.
3.1 Functional Dependencies
Handout 4 Functional Dependencies
Advanced Normalization
Chapter 8: Relational Database Design
Problems in Designing Schema
Functional Dependencies and Normalization
Canonical Cover & Normal Forms
CSCI 4333 Database Design and Implementation – Exercise (3)
Functional Dependencies and Normalization
How to test Whether Subschemes in BCNF??
Functional Dependencies and Normalization
Cse 344 May 16th – Normalization.
Functional Dependencies and Relational Schema Design
Introduction to Database Systems CSE 444 Lectures 8 & 9 Database Design October 12 & 15, 2007.
Lecture 09: Functional Dependencies, Database Design
Relational Data Base Design in Practice
Normalization Part II cs3431.
Lecture 8: Database Design
Normalization cs3431.
Some slides are from Dr. Sara Cohen
CS 405G: Introduction to Database Systems
Instructor: Mohamed Eltabakh
Instructor: Mohamed Eltabakh
Third Normal Form.
CSC 453 Database Systems Lecture
Lecture 6: Functional Dependencies
CSCI 6315 Applied Database Systems – Exercise (5)
Chapter 7a: Overview of Database Design -- Normalization
Functional Dependencies and Normalization
Functional Dependencies and Normalization
CS4222 Principles of Database System
Presentation transcript:

Relational Database Design (Discussion Session) Jianguo Wang Office hour: Friday 5pm – 6pm at CSE 3217

Functional dependency A functional dependency (FD) has the form of X → Y (X implies Y), where X and Y are sets of attributes Whenever two tuples are identical on all the attributes in X, they must also be identical in all the attributes in Y . Examples sid → sname {sid, cid} → gpa

Closure of an attribute set The closure of a set X of attributes is the set of all such attributes A that X → A can be deduced from F R = ABCDEF F = {AC, BCD, ADE} X = AB Computing X+ : Initially: X(0) = AB Applying AC: X(1) = ABC Applying BCD: X(2) = ABCD Applying ADE: X(3) = ABCDE No more changes: X(4) = X(3) X+ = ABCDE

Candidate key A candidate key is a set X of attributes in R such that X+ includes all the attributes in R. There is no proper subset Y of X such that Y+ includes all the attributes in R. A super key is a super set of key Example: R(A, B, C, D), F = {A → B, B → C} A is not a candidate key, because A+ = {A, B, C} AD is a candidate key, because AD+ = {A, B, C, D} ABD is a super key

Normal forms – BCNF For every functional dependency X→Y (YX) Example: X has to be a super key, i.e., X has to contain a candidate key Example: 4 attributes A, B, C, D, and F = {A → B, B → C} R(A, B, C) does not satisfy BCNF A is the key B → C does not include A R(A, B) satisfies BCNF

BCNF decomposition with lossless join For each FD XA, if it does not satisfy BCNF (i.e., X is not a super key), decompose it S1 = XA S2 = X(S  A)

FDs: CT, CS G, HR C, HS R, TH R Example FDs: CT, CS G, HR C, HS R, TH R CTHRSG violation: CS  G (CS)+ = CSTG, i.e., CS is not a super key CSG CTHRS no violation, (CS)+ = CSG violation: C  T C+ = CT CT CHRS no violation: 2 attributes violation: CH  R (CH)+ = CHTR CHR CHS no violation: C+ = CT, H+ = H, R+ = R, S+ = S Resulting decomposition: CSG, CT, CHR, CHS

Normal forms – 3NF For every functional dependency X→Y (YX), at least one of the following holds: X is a super key, i.e., X contains a candidate key Y belongs to a candidate key No, A and D are candidate key, B → C violates

3NF decomposition with dependency preserving Step 1: Simplify the set of FDs (eliminate redundancies) , called the minimal cover Rewrite the FDs with single attributes on RHS Replace AB  CD with AB  C and AB  D Eliminate redundant FDs F = {A  C, A  B, B  C} A  C is redundant (it is implied by A  B and B  C) Eliminate redundant attributes from LHS of FDs F = {A  B, AB  C} B is redundant in AB  C because A by itself determines C (A  C is implied by F)

3NF decomposition with dependency preserving Step 2: the decomposition is defined as  = {XA1 … Am | XAiF}{BR | B does not occur in F} Example R = CTHRSG F = CT CS G HR C HS R HT R Then  = {CT, CSG, HRC, HSR, HTR}

Decomposition with lossless join and dependency preserving Step 1: compute 3NF decomposition with dependency preserving Step 2: examine each set to see whether they have already contained a candidate key if not, add it

Example R: ABCDE F = {AC, BCD ADE}  = {AC, BCD, ADE} None of AC, BCD, ADE is a superkey AC+ = AC, BCD+ = BCD, ADE+ = ADEC AB is a key, add it to   = {AB, AC, BCD, ADE}

Testing lossless join Consider 5 attributes: A, B, C, D, E FD = {ABC, CD, DE} Consider a decomposition is R1(A,B,C); R2(C,D); and R3(D,E) Is this satisfying lossless join decomposition? A B C D E a1 a2 a3 - a4 a5 R1 a4 a5 R2 R3