The Relational Data Model

Size: px
Start display at page:

Download "The Relational Data Model"

Transcription

1 The Relational Data Model Lecture 6 1 Outline Relational Data Model Functional Dependencies Logical Schema Design Reading Chapter 8 2 1

2 The Relational Data Model Data Modeling Relational Schema Physical storage Have seen this in SQL E/R diagrams Have seen this too Tables: column names: attributes rows: tuples Discuss next Complex file organization and index structures. 3 Terminology Table name or relation name Attribute names Products: Name Price Category Manufacturer gizmo $19.99 gadgets GizmoWorks Power gizmo $29.99 gadgets GizmoWorks SingleTouch $ photography Canon MultiTouch $ household Hitachi Tuples or rows or records 4 2

3 Schemas Relational Schema: Relation name plus attribute names E.g. Product(Name, Price, Category, Manufacturer) In practice we add the domain for each attribute Database Schema Set of relational schemas E.g. Product(Name, Price, Category, Manufacturer), Company(Name, Address, Phone), Instances Relational schema = R(A 1,,A k ) Instance = relation with k attributes (of type R) values of corresponding domains Database schema = R 1 ( ), R 2 ( ),, R n ( ) Instance = n relations, of types R 1, R 2,..., R n This is all mathematics, not to be confused with SQL tables! (What's a difference?) 6 3

4 Example Relational schema:product(name, Price, Category, Manufacturer) Instance: Name Price Category Manufacturer gizmo $19.99 gadgets GizmoWorks Power gizmo $29.99 gadgets GizmoWorks SingleTouch $ photography Canon MultiTouch $ household Hitachi 7 First Normal Form (1NF) A database schema is in First Normal Form if all tables are flat Student Student Name Alice Bob Carol GPA Courses Math DB OS DB OS Math OS May need to add keys Name Alice Bob Carol Takes Student Alice Carol Alice Bob Alice Carol GPA DB OS OS Course Math Math DB Course Course Math DB OS 8 4

5 Functional Dependencies A form of constraint hence, part of the schema Finding them is part of the database design Also used in normalizing the relations Warning: this is the most abstract, and hardest part of the course. 9 Definition: Functional Dependencies If two tuples agree on the attributes A 1, A 2,, A n then they must also agree on the attributes B 1, B 2,, B m Formally: A 1, A 2,, A n B 1, B 2,, B m 10 5

6 Examples EmpID Name Phone Position E0045 Smith 1234 Clerk E1847 John 9876 Salesrep E1111 Smith 9876 Salesrep E9999 Mary 1234 Lawyer EmpID Name, Phone, Position Position Phone but Phone Position 11 In General To check A B, erase all other columns A X1 X2 B Y1 Y2 check if the remaining relation is many-one (called functional in mathematics) 12 6

7 Example EmpID Name Phone Position E0045 Smith 1234 Clerk E1847 John 9876 Salesrep E1111 Smith 9876 Salesrep E9999 Mary 1234 Lawyer Position Phone 13 Typical Examples of FDs Product: name price, manufacturer Person: ssn name, age Company: name stockprice, president 14 7

8 Example Product(name, category, color, department, price) Consider these FDs: name color category department color, category price What do they say? 15 Example FD s are constraints on relations: On some instances they hold On others they don t name color category department color, category price name category color department price Gizmo Gadget Green Toys 49 Tweaker Gadget Green Toys 99 Does this instance satisfy all the FDs? 16 8

9 Example name color category department color, category price name category color department price Gizmo Gadget Green Toys 49 Tweaker Gadget Black Toys 99 Gizmo Stationary Green Office-supp. 59 What about this one? 17 Example If some FDs are satisfied, then others are satisfied too If all these FDs are true: name color category department color, category price Then this FD also holds: name, category price Why?? 18 9

10 Inference Rules for FD s A 1, A 2,, A n B 1, B 2,, B m Is equivalent to Splitting rule and Combining rule A 1, A 2,, A n B 1 A 1, A 2,, A n B A 1, A 2,, A n B m A1... Am B1... Bm 19 Inference Rules for FD s (continued) A 1, A 2,, A n A i Trivial Rule where i = 1, 2,..., n A 1 A m Why? 20 10

11 Inference Rules for FD s (continued) Transitive Closure Rule If A 1, A 2,, A n B 1, B 2,, B m and B 1, B 2,, B m C 1, C 2,, C p then A 1, A 2,, A n C 1, C 2,, C p Why? 21 A 1 A m B 1 B m C 1... C p 22 11

12 Example (continued) Start from the following FDs: Infer the following FDs: Inferred FD 4. name, category name 5. name, category color 6. name, category category 7. name, category color, category 8. name, category price 1. name color 2. category department 3. color, category price Which Rule did we apply? 23 Example (continued) Answers: 1. name color 2. category department 3. color, category price Inferred FD 4. name, category name 5. name, category color 6. name, category category 7. name, category color, category 8. name, category price Which Rule did we apply? Trivial rule Transitivity on 4, 1 Trivial rule Split/combine on 5, 6 Transitivity on 3,

13 Another Example Enrollment(student, major, course, room, time) student major major, course room course time What else can we infer? 25 Another Rule Augmentation If A 1, A 2,, A n B then A 1, A 2,, A n, C 1, C 2,, C p B Augmentation follows from trivial rules and transitivity How? 26 13

14 Problem: infer ALL FDs Given a set of FDs, infer all possible FDs How to proceed? Try all possible FDs, apply all 3 rules E.g. R(A, B, C, D): how many FDs are possible? Drop trivial FDs, drop augmented FDs Still way too many Better: use the Closure Algorithm (next) 27 Closure of a set of Attributes Given a set of attributes A 1,, A n The closure, {A 1,, A n } +, is the set of attributes B s.t. A 1,, A n B Example: name color category department color, category price Closures: name + = {name, color} {name, category} + = {name, category, color, department, price} color + = {color} 28 14

15 Closure Algorithm Start with X={A1,, An}. Example: Repeat until X doesn t change do: if B 1,, B n C is a FD and B 1,, B n are all in X name color category department color, category price then add C to X. {name, category} + = {name, category, color, department, price} 29 Example R(A,B,C,D,E,F) A, B C A, D E B D A, F B Compute {A,B} + X = {A, B, } Compute {A, F} + X = {A, F, } 30 15

16 Using Closure to Infer ALL FDs Example: A, B C A, D B B D Step 1: Compute X +, for every X: A+ = A, B+ = BD, C+ = C, D+ = D AB+ = ABCD, AC+ = AC, AD+ = ABCD ABC+ = ABD+ = ACD + = ABCD (no need to compute why?) BCD + = BCD, ABCD+ = ABCD Step 2: Enumerate all FD s X Y, s.t. Y X + and X Y = : AB CD, AD BC, ABC D, ABD C, ACD B 31 Problem: Finding FDs Approach 1: During Database Design Designer derives them from real-world knowledge of users Problem: knowledge might not be available Approach 2: From a Database Instance Analyze given database instance and find all FD s satisfied by that instance Useful if designers don t get enough information from users Problem: FDs might be artifical for the given instance 32 16

17 Find All FDs Student Dept Course Room Alice CSE C Bob Alice Carol CSE EE CSE C++ HW DB Do all FDs make sense in practice? Dan CSE Java 050 Elsa CSE DB 045 Frank EE Circuits Answer Course Dept, Room Dept, Room Course Student, Dept Course, Room Student, Course Dept, Room Student, Room Dept, Course Do all FDs make sense in practice? 34 17

18 Keys A key is a set of attributes A 1,..., A n s.t. for any other attribute B, we have A 1,..., A n B A minimal key is a set of attributes which is a key and for which no subset is a key Note: book calls them superkey and key 35 Computing Keys Compute X + for all sets X If X + = all attributes, then X is a key List only the minimal keys Note: there can be many minimal keys! Example: R(A,B,C), AB C, BC A Minimal keys: AB and BC 36 18

19 Examples of Keys Product(name, price, category, color) name, category price category color Keys are: {name, category} and all supersets Enrollment(student, address, course, room, time) student address room, time course student, course room, time 37 Relational Schema Design (or Logical Schema Design) Main idea: Start with some relational schema Find out its FD s Use them to design a better relational schema 38 19

20 Data Anomalies When a database is poorly designed we get anomalies: Redundancy: data is repeated Update anomalies: need to change in several places Delete anomalies: may lose data when we don t want 39 Relational Schema Design Example: Persons with several phones Name Fred SSN PhoneNumber City Seattle Fred Seattle Joe Westfield SSN Name, City but not SSN PhoneNumber Anomalies: Redundancy = repeat data Update anomalies = Fred moves to Bellevue Deletion anomalies = Joe deletes his phone number: what is his city? 40 20

21 Relation Decomposition Break the relation into two: Name SSN PhoneNumber City Fred Seattle Fred Seattle Joe Westfield Name Fred Joe SSN City Seattle Westfield SSN Anomalies have gone: No more repeated data Easy to move Fred to Bellevue (how?) Easy to delete all Joe s phone number (how?) PhoneNumber Relational Schema Design Conceptual Model: name Product buys Person price name ssn Relational Model: plus FD s Normalization: Eliminates anomalies 42 21

22 Decompositions in General R(A 1,..., A n, B 1,..., B m, C 1,..., C p ) R 1 (A 1,..., A n, B 1,..., B m ) R 2 (A 1,..., A n, C 1,..., C p ) R 1 = projection of R on A 1,..., A n, B 1,..., B m R 2 = projection of R on A 1,..., A n, C 1,..., C p 43 Decomposition Sometimes it is correct: Name Gizmo OneClick Gizmo Price Category Gadget Camera Camera Name Price Name Category Gizmo Gizmo Gadget OneClick OneClick Camera Gizmo Gizmo Camera Lossless decomposition 44 22

23 Incorrect Decomposition Sometimes it is not: Name Price Category Gizmo OneClick Gizmo Gadget Camera Camera What s incorrect?? Name Gizmo OneClick Gizmo Category Gadget Camera Camera Lossy decomposition Price Category Gadget Camera Camera 45 Decompositions in General R(A 1,..., A n, B 1,..., B m, C 1,..., C p ) R 1 (A 1,..., A n, B 1,..., B m ) R 2 (A 1,..., A n, C 1,..., C p ) If A 1,..., A n B 1,..., B m Then the decomposition is lossless Note: don t need necessarily A 1,..., A n C 1,..., C p Example: name price, hence the first decomposition is lossless 46 23

24 Normal Forms First Normal Form = all attributes are atomic Second Normal Form (2NF) = old and obsolete Third Normal Form (3NF) = this lecture Boyce Codd Normal Form (BCNF) = this lecture Others Boyce-Codd Normal Form A simple condition for removing anomalies from relations: A relation R is in BCNF if: If A 1,..., A n B is a non-trivial dependency in R, then {A 1,..., A n } is a key for R In English (though a bit vague): Whenever a set of attributes of R is determining another attribute, it should determine all the attributes of R

25 BCNF Decomposition Algorithm Repeat choose A 1,, A m B 1,, B n that violates the BNCF condition split R into R 1 (A 1,, A m, B 1,, B n ) and R 2 (A 1,, A m, [others]) continue with both R 1 and R 2 Until no more violations B s A s Others Is there a 2-attribute relation that is not in BCNF? R 1 R 2 49 Example Name SSN PhoneNumber City Fred Seattle Fred Seattle Joe Westfield Joe Westfield What are the dependencies? SSN Name, City What are the keys? {SSN, PhoneNumber} Is it in BCNF? 50 25

26 Decompose it into BCNF Name Fred SSN City Seattle SSN Name, City Joe Westfield SSN PhoneNumber Let s check anomalies: Redundancy? Update? Delete? 51 Summary of BCNF Decomposition Find a dependency that violates the BCNF condition: Heuristics: choose B, B, B as large as possible 1 2 m Decompose: A 1, A 2,, A n B 1, B 2,, B m Others R1 A s B s R2 Continue until there are no BCNF violations left. 2-attribute relations are BCNF 52 26

27 Example Decomposition Person(name, SSN, age, haircolor, phonenumber) SSN name, age age haircolor Decompose in BCNF (in class): Step 1: find all keys (How? Compute S +, for various sets S) Step 2: now decompose 53 Other Example R(A,B,C,D) A B, B C Key: AD Violations of BCNF: A B, A C, A BC Pick A BC: split into R1(A,BC) R2(A,D) What happens if we pick A B first? 54 27

28 Lossless Decompositions A decomposition is lossless if we can recover: R(A,B,C) Decompose R1(A,B) R2(A,C) Recover R (A,B,C) should be the same as R(A,B,C) R is in general larger than R. Must ensure R = R 55 Lossless Decompositions Given R(A,B,C) s.t. A B, the decomposition into R1(A,B), R2(A,C) is lossless 56 28

29 3NF: A Problem with BCNF Unit Company Product FD s: Unit Company; Company, Product Unit So, there is a BCNF violation, and we decompose. Unit Company Unit Company Unit Product No FDs Notice: we loose the FD: Company, Product Unit 57 So What s the Problem? Unit Company Unit Product Galaga99 UW Galaga99 databases Bingo UW Bingo databases No problem so far. All local FD s are satisfied. Let s put all the data back into a single table again (anomalies?): Unit Company Product Galaga99 UW databases Bingo UW databases Violates the dependency: company, product -> unit! 58 29

30 Solution: 3rd Normal Form (3NF) A simple condition for removing anomalies from relations: A relation R is in 3rd normal form if : Whenever there is a nontrivial dependency A 1, A 2,..., A n B for R, then {A 1, A 2,..., A n } is a key for R, or B is part of a key. Tradeoff: BCNF = no anomalies, but may lose some FDs 3NF = keeps all FDs, but may have some anomalies 59 30

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Fall 2009 Lecture 3 - Schema Normalization

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Fall 2009 Lecture 3 - Schema Normalization CSE 544 Principles of Database Management Systems Magdalena Balazinska Fall 2009 Lecture 3 - Schema Normalization References R&G Book. Chapter 19: Schema refinement and normal forms Also relevant to this

More information

CS411 Database Systems. 05: Relational Schema Design Ch , except and

CS411 Database Systems. 05: Relational Schema Design Ch , except and CS411 Database Systems 05: Relational Schema Design Ch. 3.1-3.5, except 3.4.2-3.4.3 and 3.5.3. 1 How does this fit in? ER Diagrams: Data Definition Translation to Relational Schema: Data Definition Relational

More information

CSE 562 Database Systems

CSE 562 Database Systems Goal CSE 562 Database Systems Question: The relational model is great, but how do I go about designing my database schema? Database Design Some slides are based or modified from originals by Magdalena

More information

Lectures 5 & 6. Lectures 6: Design Theory Part II

Lectures 5 & 6. Lectures 6: Design Theory Part II Lectures 5 & 6 Lectures 6: Design Theory Part II Lecture 6 Today s Lecture 1. Boyce-Codd Normal Form ACTIVITY 2. Decompositions & 3NF ACTIVITY 3. MVDs ACTIVITY 2 Lecture 6 > Section 1 1. Boyce-Codd Normal

More information

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Winter 2009 Lecture 4 - Schema Normalization

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Winter 2009 Lecture 4 - Schema Normalization CSE 544 Principles of Database Management Systems Magdalena Balazinska Winter 2009 Lecture 4 - Schema Normalization References R&G Book. Chapter 19: Schema refinement and normal forms Also relevant to

More information

Introduction to Database Systems CSE 544. Lecture #2 January 16, 2007

Introduction to Database Systems CSE 544. Lecture #2 January 16, 2007 Introduction to Database Systems CSE 544 Lecture #2 January 16, 2007 1 Review Questions: NULLS From Lecture 1: What is 3-valued logic? Why do we need it? What is a left outer join? Why do we sometimes

More information

FUNCTIONAL DEPENDENCIES

FUNCTIONAL DEPENDENCIES FUNCTIONAL DEPENDENCIES CS 564- Spring 2018 ACKs: Dan Suciu, Jignesh Patel, AnHai Doan WHAT IS THIS LECTURE ABOUT? Database Design Theory: Functional Dependencies Armstrong s rules The Closure Algorithm

More information

Introduction to Data Management CSE 344

Introduction to Data Management CSE 344 Introduction to Data Management CSE 344 Lectures 18: Design Theory CSE 344 - Winter 2017 1 Database Design Process Lec 16 Conceptual Model: name product makes company Relational Model: Tables + constraints

More information

Normalization. Murali Mani. What and Why Normalization? To remove potential redundancy in design

Normalization. Murali Mani. What and Why Normalization? To remove potential redundancy in design 1 Normalization What and Why Normalization? To remove potential redundancy in design Redundancy causes several anomalies: insert, delete and update Normalization uses concept of dependencies Functional

More information

Lectures 12: Design Theory I. 1. Normal forms & functional dependencies 2/19/2018. Today s Lecture. What you will learn about in this section

Lectures 12: Design Theory I. 1. Normal forms & functional dependencies 2/19/2018. Today s Lecture. What you will learn about in this section Today s Lecture Lectures 12: Design Theory I Professor Xiannong Meng Spring 2018 Lecture and activity contents are based on what Prof Chris Ré used in his CS 145 in the fall 2016 term with permission 1.

More information

CSE 344 AUGUST 1 ST ENTITIES

CSE 344 AUGUST 1 ST ENTITIES CSE 344 AUGUST 1 ST ENTITIES EXAMS Will hand back after class Quartiles 1 0 67 2 68 74 3 74 82 4 82 100 (no one actually got 0 or 100) ADMINISTRIVIA HW6 due Wednesday Spark SQL interface much easier to

More information

CS 564 Midterm Review

CS 564 Midterm Review Midterm Review CS 564 Midterm Review The Best Of Collection (Master Tracks), Vol. 1 Midterm Review Announcements Midterm next Wednesday In class: roughly 70 minutes Come in 10 minutes earlier! Midterm

More information

BCNF. Yufei Tao. Department of Computer Science and Engineering Chinese University of Hong Kong BCNF

BCNF. Yufei Tao. Department of Computer Science and Engineering Chinese University of Hong Kong BCNF Yufei Tao Department of Computer Science and Engineering Chinese University of Hong Kong Recall A primary goal of database design is to decide what tables to create. Usually, there are two principles:

More information

CSE 544 Principles of Database Management Systems

CSE 544 Principles of Database Management Systems CSE 544 Principles of Database Management Systems Magdalena Balazinska Winter 2015 Lecture 2 SQL and Schema Normalization 1 Announcements Paper review First paper review is due before lecture on Wednesday

More information

Design Theory for Relational Databases

Design Theory for Relational Databases By Marina Barsky Design Theory for Relational Databases Lecture 15 Functional dependencies: formal definition X Y is an assertion about a relation R that whenever two tuples of R agree on all the attributes

More information

CSE 544 Principles of Database Management Systems

CSE 544 Principles of Database Management Systems CSE 544 Principles of Database Management Systems Alvin Cheung Fall 2015 Lecture 2 SQL and Schema Normalization 1 Announcements Paper review First paper review is due on Wednesday 10:30am Details on website

More information

Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications. Overview - detailed. Goal. Faloutsos & Pavlo CMU SCS /615

Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications. Overview - detailed. Goal. Faloutsos & Pavlo CMU SCS /615 Faloutsos & Pavlo 15-415/615 Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #17: Schema Refinement & Normalization - Normal Forms (R&G, ch. 19) Overview - detailed

More information

CMU SCS CMU SCS CMU SCS CMU SCS whole nothing but

CMU SCS CMU SCS CMU SCS CMU SCS whole nothing but Faloutsos & Pavlo 15-415/615 Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #17: Schema Refinement & Normalization - Normal Forms (R&G, ch. 19) Overview - detailed

More information

Database Design Theory and Normalization. CS 377: Database Systems

Database Design Theory and Normalization. CS 377: Database Systems Database Design Theory and Normalization CS 377: Database Systems Recap: What Has Been Covered Lectures 1-2: Database Overview & Concepts Lecture 4: Representational Model (Relational Model) & Mapping

More information

In This Lecture. Normalisation to BCNF. Lossless decomposition. Normalisation so Far. Relational algebra reminder: product

In This Lecture. Normalisation to BCNF. Lossless decomposition. Normalisation so Far. Relational algebra reminder: product In This Lecture Normalisation to BCNF Database Systems Lecture 12 Natasha Alechina More normalisation Brief review of relational algebra Lossless decomposition Boyce-Codd normal form (BCNF) Higher normal

More information

Databases -Normalization I. (GF Royle, N Spadaccini ) Databases - Normalization I 1 / 24

Databases -Normalization I. (GF Royle, N Spadaccini ) Databases - Normalization I 1 / 24 Databases -Normalization I (GF Royle, N Spadaccini 2006-2010) Databases - Normalization I 1 / 24 This lecture This lecture introduces normal forms, decomposition and normalization. We will explore problems

More information

Functional Dependencies CS 1270

Functional Dependencies CS 1270 Functional Dependencies CS 1270 Constraints We use constraints to enforce semantic requirements on a DBMS Predicates that the DBMS must ensure to be always true. Predicates are checked when the DBMS chooses

More information

L12: ER modeling 5. CS3200 Database design (sp18 s2) 2/22/2018

L12: ER modeling 5. CS3200 Database design (sp18 s2)   2/22/2018 L12: ER modeling 5 CS3200 Database design (sp18 s2) https://course.ccs.neu.edu/cs3200sp18s2/ 2/22/2018 200 Announcements! Keep bringing your name plates J Exam 1 discussion: questions on grading: Piazza,

More information

This lecture. Databases -Normalization I. Repeating Data. Redundancy. This lecture introduces normal forms, decomposition and normalization.

This lecture. Databases -Normalization I. Repeating Data. Redundancy. This lecture introduces normal forms, decomposition and normalization. This lecture Databases -Normalization I This lecture introduces normal forms, decomposition and normalization (GF Royle 2006-8, N Spadaccini 2008) Databases - Normalization I 1 / 23 (GF Royle 2006-8, N

More information

Review: Attribute closure

Review: Attribute closure CS445 - Introduction to Database Management Systems Fall Semester 2015 LECTURE 10 Functional Dependencies, Normalization Part II TEXTBOOK REFERENCE: CHAPTER 19 CS445 DATABASES: LECTURE 10 1 Review: Attribute

More information

Fundamentals of Database Systems

Fundamentals of Database Systems Fundamentals of Database Systems Assignment: 3 Due Date: 23st August, 2017 Instructions This question paper contains 15 questions in 6 pages. Q1: Consider the following relation and its functional dependencies,

More information

Lecture 11 - Chapter 8 Relational Database Design Part 1

Lecture 11 - Chapter 8 Relational Database Design Part 1 CMSC 461, Database Management Systems Spring 2018 Lecture 11 - Chapter 8 Relational Database Design Part 1 These slides are based on Database System Concepts 6th edition book and are a modified version

More information

NORMAL FORMS. CS121: Relational Databases Fall 2017 Lecture 18

NORMAL FORMS. CS121: Relational Databases Fall 2017 Lecture 18 NORMAL FORMS CS121: Relational Databases Fall 2017 Lecture 18 Equivalent Schemas 2 Many different schemas can represent a set of data Which one is best? What does best even mean? Main goals: Representation

More information

Introduction to Databases CSE 414. Lecture 2: Data Models

Introduction to Databases CSE 414. Lecture 2: Data Models Introduction to Databases CSE 414 Lecture 2: Data Models CSE 414 - Autumn 2018 1 Class Overview Unit 1: Intro Unit 2: Relational Data Models and Query Languages Data models, SQL, Relational Algebra, Datalog

More information

CSC 261/461 Database Systems Lecture 14. Spring 2017 MW 3:25 pm 4:40 pm January 18 May 3 Dewey 1101

CSC 261/461 Database Systems Lecture 14. Spring 2017 MW 3:25 pm 4:40 pm January 18 May 3 Dewey 1101 CSC 261/461 Database Systems Lecture 14 Spring 2017 MW 3:25 pm 4:40 pm January 18 May 3 Dewey 1101 Announcement Midterm on this Wednesday Please arrive 5 minutes early; We will start at 3:25 sharp I may

More information

Lecture 4. Database design IV. INDs and 4NF Design wrapup

Lecture 4. Database design IV. INDs and 4NF Design wrapup Lecture 4 Database design IV INDs and 4NF Design wrapup Problem description We want a database that we can use for scheduling courses and lectures. This is how it s supposed to work: code name Course dept

More information

Functional Dependencies and Finding a Minimal Cover

Functional Dependencies and Finding a Minimal Cover Functional Dependencies and Finding a Minimal Cover Robert Soulé 1 Normalization An anomaly occurs in a database when you can update, insert, or delete data, and get undesired side-effects. These side

More information

COSC Dr. Ramon Lawrence. Emp Relation

COSC Dr. Ramon Lawrence. Emp Relation COSC 304 Introduction to Database Systems Normalization Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Normalization Normalization is a technique for producing relations

More information

CSIT5300: Advanced Database Systems

CSIT5300: Advanced Database Systems CSIT5300: Advanced Database Systems L06: Relational Database Design BCNF Dr. Kenneth LEUNG Department of Computer Science and Engineering The Hong Kong University of Science and Technology Hong Kong SAR,

More information

Functional dependency theory

Functional dependency theory Functional dependency theory Introduction to Database Design 2012, Lecture 8 Course evaluation Recalling normal forms Functional dependency theory Computing closures of attribute sets BCNF decomposition

More information

CSE 444 Midterm Test

CSE 444 Midterm Test CSE 444 Midterm Test Spring 2007 Name: Total time: 50 Question 1 /40 Question 2 /30 Question 3 /30 Total /100 1 1 SQL [40 points] Consider a database of social groups that allows people to become members

More information

Database design III. Quiz time! Using FDs to detect anomalies. Decomposition. Decomposition. Boyce-Codd Normal Form 11/4/16

Database design III. Quiz time! Using FDs to detect anomalies. Decomposition. Decomposition. Boyce-Codd Normal Form 11/4/16 Lecture 3 Quiz time! Database design III Functional dependencies cont. BCNF and 3NF What s wrong with this schema? {(, 2, Databases, Steven Van Acker ), (, 4, Databases, Rogardt Heldal )} Redundancy! Using

More information

Lecture 2: Introduction to SQL

Lecture 2: Introduction to SQL Lecture 2: Introduction to SQL Lecture 2 Announcements! 1. If you still have Jupyter trouble, let us know! 2. Enroll to Piazza!!! 3. People are looking for groups. Team up! 4. Enrollment should be finalized

More information

Schema Refinement: Dependencies and Normal Forms

Schema Refinement: Dependencies and Normal Forms Schema Refinement: Dependencies and Normal Forms Grant Weddell Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Spring 2016 CS 348 (Intro to DB Mgmt)

More information

The Entity-Relationship Model (ER Model) - Part 2

The Entity-Relationship Model (ER Model) - Part 2 Lecture 4 The Entity-Relationship Model (ER Model) - Part 2 By Michael Hahsler Based on slides for CS145 Introduction to Databases (Stanford) Lecture 4 > Section 2 What you will learn about in this section

More information

Introduction to SQL Part 1 By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford)

Introduction to SQL Part 1 By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford) Introduction to SQL Part 1 By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford) Lecture 2 Lecture Overview 1. SQL introduction & schema definitions 2. Basic single-table queries

More information

Schema Refinement and Normal Forms

Schema Refinement and Normal Forms Schema Refinement and Normal Forms Chapter 19 Quiz #2 Next Wednesday Comp 521 Files and Databases Fall 2010 1 The Evils of Redundancy Redundancy is at the root of several problems associated with relational

More information

Chapter 8: Relational Database Design

Chapter 8: Relational Database Design Chapter 8: Relational Database Design Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 8: Relational Database Design Features of Good Relational Design Atomic Domains

More information

Database Systems. Basics of the Relational Data Model

Database Systems. Basics of the Relational Data Model Database Systems Relational Design Theory Jens Otten University of Oslo Jens Otten (UiO) Database Systems Relational Design Theory INF3100 Spring 18 1 / 30 Basics of the Relational Data Model title year

More information

Unit 3 : Relational Database Design

Unit 3 : Relational Database Design Unit 3 : Relational Database Design Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Content Relational Model: Basic concepts, Attributes and Domains, CODD's Rules, Relational

More information

DS Introduction to SQL Part 1 Single-Table Queries. By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford)

DS Introduction to SQL Part 1 Single-Table Queries. By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford) DS 1300 - Introduction to SQL Part 1 Single-Table Queries By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford) Overview 1. SQL introduction & schema definitions 2. Basic single-table

More information

Schema Refinement: Dependencies and Normal Forms

Schema Refinement: Dependencies and Normal Forms Schema Refinement: Dependencies and Normal Forms Grant Weddell David R. Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Spring 2012 CS 348 (Intro to

More information

Part II: Using FD Theory to do Database Design

Part II: Using FD Theory to do Database Design Part II: Using FD Theory to do Database Design 32 Recall that poorly designed table? part manufacturer manaddress seller selleraddress price 1983 Hammers R Us 99 Pinecrest ABC 1229 Bloor W 5.59 8624 Lee

More information

Administrivia. Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications. Relational Model: Keys. Correction: Implied FDs

Administrivia. Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications. Relational Model: Keys. Correction: Implied FDs Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Administrivia HW6 is due Tuesday March 24 th. C. Faloutsos A. Pavlo Lecture#17: Schema Refinement & Normalization Faloutsos/Pavlo

More information

Lecture 9: Database Design. Wednesday, February 18, 2015

Lecture 9: Database Design. Wednesday, February 18, 2015 Lecture 9: Database Design Wednesday, February 18, 2015 Agenda Review HW #2 Discuss Normalization Theory Take Quiz #3 Normal Forms 1st Normal Form (1NF): will discuss briefly 2nd Normal Form (2NF): will

More information

Introduction to Database Systems. The Relational Data Model

Introduction to Database Systems. The Relational Data Model Introduction to Database Systems The Relational Data Model Werner Nutt 1 4. The Relational Data Model 4.1 Schemas 1. Schemas 2. Instances 3. Integrity Constraints 2 Different Schemas are Based on Different

More information

Introduction to Database Systems. The Relational Data Model. Werner Nutt

Introduction to Database Systems. The Relational Data Model. Werner Nutt Introduction to Database Systems The Relational Data Model Werner Nutt 1 4. The Relational Data Model 4.1 Schemas 1. Schemas 2. Instances 3. Integrity Constraints 2 Different Schemas are Based on Different

More information

Schema Refinement: Dependencies and Normal Forms

Schema Refinement: Dependencies and Normal Forms Schema Refinement: Dependencies and Normal Forms M. Tamer Özsu David R. Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Fall 2012 CS 348 Schema Refinement

More information

Databases The theory of relational database design Lectures for m

Databases The theory of relational database design Lectures for m Databases The theory of relational database design Lectures for mathematics students April 2, 2017 General introduction Look; that s why there s rules, understand? So that you think before you break em.

More information

UNIT 3 DATABASE DESIGN

UNIT 3 DATABASE DESIGN UNIT 3 DATABASE DESIGN Objective To study design guidelines for relational databases. To know about Functional dependencies. To have an understanding on First, Second, Third Normal forms To study about

More information

customer = (customer_id, _ customer_name, customer_street,

customer = (customer_id, _ customer_name, customer_street, Relational Database Design COMPILED BY: RITURAJ JAIN The Banking Schema branch = (branch_name, branch_city, assets) customer = (customer_id, _ customer_name, customer_street, customer_city) account = (account_number,

More information

CS 338 Functional Dependencies

CS 338 Functional Dependencies CS 338 Functional Dependencies Bojana Bislimovska Winter 2016 Outline Design Guidelines for Relation Schemas Functional Dependency Set and Attribute Closure Schema Decomposition Boyce-Codd Normal Form

More information

Normal Forms. Winter Lecture 19

Normal Forms. Winter Lecture 19 Normal Forms Winter 2006-2007 Lecture 19 Equivalent Schemas Many schemas can represent a set of data Which one is best? What does best even mean? Main goals: Representation must be complete Data should

More information

Relational Design 1 / 34

Relational Design 1 / 34 Relational Design 1 / 34 Relational Design Basic design approaches. What makes a good design better than a bad design? How do we tell we have a "good" design? How to we go about creating a good design?

More information

Desired properties of decompositions

Desired properties of decompositions Desired properties of decompositions We expect that after decomposition No anomalies and redundancies We can recover the original relation from the tuples in its decompositions We can ensure that after

More information

Introduction to Database Systems. Announcements CSE 444. Review: Closure, Key, Superkey. Decomposition: Schema Design using FD

Introduction to Database Systems. Announcements CSE 444. Review: Closure, Key, Superkey. Decomposition: Schema Design using FD Introduction to Database Systems CSE 444 Lecture #9 Jan 29 2001 Announcements Mid Term on Monday (in class) Material in lectures Textbook Chapter 1.1, Chapter 2 (except 2.1 and ODL), Chapter 3 (except

More information

Database Management System Prof. Partha Pratim Das Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Database Management System Prof. Partha Pratim Das Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Database Management System Prof. Partha Pratim Das Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Lecture - 19 Relational Database Design (Contd.) Welcome to module

More information

Functional Dependencies and Normalization

Functional Dependencies and Normalization Functional Dependencies and Normalization Jose M. Peña jose.m.pena@liu.se Overview Real world Databases DBMS Model Physical database Queries Processing of queries and updates Access to stored data Answers

More information

5 Normalization:Quality of relational designs

5 Normalization:Quality of relational designs 5 Normalization:Quality of relational designs 5.1 Functional Dependencies 5.1.1 Design quality 5.1.2 Update anomalies 5.1.3 Functional Dependencies: definition 5.1.4 Properties of Functional Dependencies

More information

SCHEMA REFINEMENT AND NORMAL FORMS

SCHEMA REFINEMENT AND NORMAL FORMS 19 SCHEMA REFINEMENT AND NORMAL FORMS Exercise 19.1 Briefly answer the following questions: 1. Define the term functional dependency. 2. Why are some functional dependencies called trivial? 3. Give a set

More information

Normalization 03. CSE3421 notes

Normalization 03. CSE3421 notes Normalization 03 CSE3421 notes 1 Example F: A B (1) ABCD E (2) EF G (3) EF H (4) ACDF EG (5) Calculate the minimal cover of F. 2 Step 1: Put F in standard form FDs (1) (4) are already in standard form.

More information

Database Management

Database Management Database Management - 2013 Model Answers 1. a. A cyclic relationship type (also called recursive) is a relationship type between two occurrences of the same entity type. With each entity type in a cyclic

More information

Relational Database Design (II)

Relational Database Design (II) Relational Database Design (II) 1 Roadmap of This Lecture Algorithms for Functional Dependencies (cont d) Decomposition Using Multi-valued Dependencies More Normal Form Database-Design Process Modeling

More information

Introduction to Databases, Fall 2003 IT University of Copenhagen. Lecture 4: Normalization. September 16, Lecturer: Rasmus Pagh

Introduction to Databases, Fall 2003 IT University of Copenhagen. Lecture 4: Normalization. September 16, Lecturer: Rasmus Pagh Introduction to Databases, Fall 2003 IT University of Copenhagen Lecture 4: Normalization September 16, 2003 Lecturer: Rasmus Pagh Today s lecture What you should remember from previously. Anomalies in

More information

CSE 344 JANUARY 5 TH INTRO TO THE RELATIONAL DATABASE

CSE 344 JANUARY 5 TH INTRO TO THE RELATIONAL DATABASE CSE 344 JANUARY 5 TH INTRO TO THE RELATIONAL DATABASE ADMINISTRATIVE MINUTIAE Midterm Exam: February 9 th : 3:30-4:20 Final Exam: March 15 th : 2:30 4:20 ADMINISTRATIVE MINUTIAE Midterm Exam: February

More information

Database Management System

Database Management System Database Management System Lecture 4 Database Design Normalization and View * Some materials adapted from R. Ramakrishnan, J. Gehrke and Shawn Bowers Today s Agenda Normalization View Database Management

More information

Relational Database Design Theory. Introduction to Databases CompSci 316 Fall 2017

Relational Database Design Theory. Introduction to Databases CompSci 316 Fall 2017 Relational Database Design Theory Introduction to Databases CompSci 316 Fall 2017 2 Announcements (Thu. Sep. 14) Homework #1 due next Tuesday (11:59pm) Course project description posted Read it! Mixer

More information

INF 212 ANALYSIS OF PROG. LANGS SQL AND SPREADSHEETS. Instructors: Crista Lopes Copyright Instructors.

INF 212 ANALYSIS OF PROG. LANGS SQL AND SPREADSHEETS. Instructors: Crista Lopes Copyright Instructors. INF 212 ANALYSIS OF PROG. LANGS SQL AND SPREADSHEETS Instructors: Crista Lopes Copyright Instructors. Data-Centric Programming Focus on data Interactive data: SQL Dataflow: Spreadsheets Dataflow: Iterators,

More information

Big Data Processing Technologies. Chentao Wu Associate Professor Dept. of Computer Science and Engineering

Big Data Processing Technologies. Chentao Wu Associate Professor Dept. of Computer Science and Engineering Big Data Processing Technologies Chentao Wu Associate Professor Dept. of Computer Science and Engineering wuct@cs.sjtu.edu.cn Schedule (1) Storage system part (first eight weeks) lec1: Introduction on

More information

Informal Design Guidelines for Relational Databases

Informal Design Guidelines for Relational Databases Outline Informal Design Guidelines for Relational Databases Semantics of the Relation Attributes Redundant Information in Tuples and Update Anomalies Null Values in Tuples Spurious Tuples Functional Dependencies

More information

Relational Design: Characteristics of Well-designed DB

Relational Design: Characteristics of Well-designed DB 1. Minimal duplication Relational Design: Characteristics of Well-designed DB Consider table newfaculty (Result of F aculty T each Course) Id Lname Off Bldg Phone Salary Numb Dept Lvl MaxSz 20000 Cotts

More information

Databases Lecture 7. Timothy G. Griffin. Computer Laboratory University of Cambridge, UK. Databases, Lent 2009

Databases Lecture 7. Timothy G. Griffin. Computer Laboratory University of Cambridge, UK. Databases, Lent 2009 Databases Lecture 7 Timothy G. Griffin Computer Laboratory University of Cambridge, UK Databases, Lent 2009 T. Griffin (cl.cam.ac.uk) Databases Lecture 7 DB 2009 1 / 17 Lecture 07: Decomposition to Normal

More information

Concepts from

Concepts from 1 Concepts from 3.1-3.2 Functional dependencies Keys & superkeys of a relation Reasoning about FDs Closure of a set of attributes Closure of a set of FDs Minimal basis for a set of FDs 2 Plan How can we

More information

Entity/Relationship Modelling

Entity/Relationship Modelling Entity/Relationship Modelling Lecture 4 1 Outline E/R model (Chapter 5) From E/R diagrams to relational schemas (Chapter 5) Constraints in SQL (Chapter 4) 2 1. Database Design Modelling Decide which part

More information

Relational Design Theory

Relational Design Theory OpenStax-CNX module: m28252 1 Relational Design Theory Nguyen Kim Anh This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 3.0 Abstract One important theory

More information

DS Introduction to SQL Part 2 Multi-table Queries. By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford)

DS Introduction to SQL Part 2 Multi-table Queries. By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford) DS 1300 - Introduction to SQL Part 2 Multi-table Queries By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford) What you will learn about in this section 1. Foreign key constraints

More information

Chapter 7: Relational Database Design

Chapter 7: Relational Database Design Chapter 7: Relational Database Design Database System Concepts, 5th Ed. See www.db-book.com for conditions on re-use Chapter 7: Relational Database Design Features of Good Relational Design Atomic Domains

More information

CS 2451 Database Systems: Database and Schema Design

CS 2451 Database Systems: Database and Schema Design CS 2451 Database Systems: Database and Schema Design http://www.seas.gwu.edu/~bhagiweb/cs2541 Spring 2018 Instructor: Dr. Bhagi Narahari Relational Model: Definitions Review Relations/tables, Attributes/Columns,

More information

Normalization. Anomalies Functional Dependencies Closures Key Computation Projecting Relations BCNF Reconstructing Information Other Normal Forms

Normalization. Anomalies Functional Dependencies Closures Key Computation Projecting Relations BCNF Reconstructing Information Other Normal Forms Anomalies Functional Dependencies Closures Key Computation Projecting Relations BCNF Reconstructing Information Other Normal Forms Normalization Niklas Fors (niklas.fors@cs.lth.se) Normalization 1 / 45

More information

Functional Dependencies & Normalization for Relational DBs. Truong Tuan Anh CSE-HCMUT

Functional Dependencies & Normalization for Relational DBs. Truong Tuan Anh CSE-HCMUT Functional Dependencies & Normalization for Relational DBs Truong Tuan Anh CSE-HCMUT 1 2 Contents 1 Introduction 2 Functional dependencies (FDs) 3 Normalization 4 Relational database schema design algorithms

More information

The Relational Data Model. Functional Dependencies. Example. Functional Dependencies

The Relational Data Model. Functional Dependencies. Example. Functional Dependencies The Relational Data Model Functional Dependencies 1 Functional Dependencies X -> A is an assertion about a relation R that whenever two tuples of R agree on all the attributes of X, then they must also

More information

Functional Dependencies and Normalization for Relational Databases Design & Analysis of Database Systems

Functional Dependencies and Normalization for Relational Databases Design & Analysis of Database Systems Functional Dependencies and Normalization for Relational Databases 406.426 Design & Analysis of Database Systems Jonghun Park jonghun@snu.ac.kr Dept. of Industrial Engineering Seoul National University

More information

Introduction to Data Management CSE 344

Introduction to Data Management CSE 344 Introduction to Data Management CSE 344 Lecture 17: E/R Diagrams and Constraints CSE 344 - Fall 2015 1 Database Design Why do we need it? Need a way to model real world entities in terms of relations Not

More information

V. Database Design CS448/ How to obtain a good relational database schema

V. Database Design CS448/ How to obtain a good relational database schema V. How to obtain a good relational database schema Deriving new relational schema from ER-diagrams Normal forms: use of constraints in evaluating existing relational schema CS448/648 1 Translating an E-R

More information

Sample Exam for CSE 480 (2017) KEY

Sample Exam for CSE 480 (2017) KEY Sample Exam for CSE 480 (2017) KEY Answer the questions in the spaces provided on the page. If you run out of room for an answer, continue on the back of that page. Instructions: DO NOT START THE EXAM

More information

Introduction to Data Management CSE 344

Introduction to Data Management CSE 344 Introduction to Data Management CSE 344 Lecture 17: E/R Diagrams and Constraints CSE 344 - Winter 2016 1 Announcements HW5 due this Friday Please note minor update to the instructions WQ6 due next Wednesday

More information

CSCI 403: Databases 13 - Functional Dependencies and Normalization

CSCI 403: Databases 13 - Functional Dependencies and Normalization CSCI 403: Databases 13 - Functional Dependencies and Normalization Introduction The point of this lecture material is to discuss some objective measures of the goodness of a database schema. The method

More information

Database Design Principles

Database Design Principles Database Design Principles CPS352: Database Systems Simon Miner Gordon College Last Revised: 2/11/15 Agenda Check-in Design Project ERD Presentations Database Design Principles Decomposition Functional

More information

CSE 344 MAY 11 TH ENTITIES

CSE 344 MAY 11 TH ENTITIES CSE 344 MAY 11 TH ENTITIES ADMINISTRIVIA HW6 Due next Wednesday (May 16) Section 7 slides very helpful HW7 Out Wednesday Due May 23 rd HW8 Out May 23 rd Due last day of class, Jun 1 Exam Graded and on

More information

LOGICAL DATABASE DESIGN Part #2/2

LOGICAL DATABASE DESIGN Part #2/2 NOTE, the decomposition algorithms (2NF in p. 10-11, 3NF in p. 14-16, and BCNF in P. 18) have been modified. Read the algorithms very carefully. LOGICAL DATABASE DESIGN Part #2/2 Relational Database Design

More information

Database Management System 15

Database Management System 15 Database Management System 15 Trivial and Non-Trivial Canonical /Minimal School of Computer Engineering, KIIT University 15.1 First characterize fully the data requirements of the prospective database

More information

Homework 6: FDs, NFs and XML (due April 13 th, 2016, 4:00pm, hard-copy in-class please)

Homework 6: FDs, NFs and XML (due April 13 th, 2016, 4:00pm, hard-copy in-class please) Virginia Tech. Computer Science CS 4604 Introduction to DBMS Spring 2016, Prakash Homework 6: FDs, NFs and XML (due April 13 th, 2016, 4:00pm, hard-copy in-class please) Reminders: a. Out of 100 points.

More information

Chapter 10. Normalization. Chapter Outline. Chapter Outline(contd.)

Chapter 10. Normalization. Chapter Outline. Chapter Outline(contd.) Chapter 10 Normalization Chapter Outline 1 Informal Design Guidelines for Relational Databases 1.1Semantics of the Relation Attributes 1.2 Redundant Information in Tuples and Update Anomalies 1.3 Null

More information

Draw A Relational Schema And Diagram The Functional Dependencies In The Relation >>>CLICK HERE<<<

Draw A Relational Schema And Diagram The Functional Dependencies In The Relation >>>CLICK HERE<<< Draw A Relational Schema And Diagram The Functional Dependencies In The Relation I need to draw relational schema and dependency diagram showing transitive and partial Functional dependency and normalization

More information

Relational Database Design. Announcements. Database (schema) design. CPS 216 Advanced Database Systems. DB2 accounts have been set up

Relational Database Design. Announcements. Database (schema) design. CPS 216 Advanced Database Systems. DB2 accounts have been set up Relational Database Design CPS 216 Advanced Database Systems Announcements 2 DB2 accounts have been set up Let me know if you have not received an email from me regarding your account Recitation session

More information