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

Size: px
Start display at page:

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

Transcription

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

2 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 need left outer joins in aggregate queries? 2

3 Review Question: Expressive Power of SQL From HW1: Acted together table: A(id1, id2) This is a graph Pairs of actors connected by a path of length 2 How many joins? Pairs of actors connected by a path of length 5 How many joins? Pairs of actors connected by a path of any length How many joins? 3

4 Review Question: ACID From the reading assignment SQL for Web Nerds: What does ACID mean? 4

5 Discussion of Project/Phase 1 Task 1: Schema design Task 2: Import sample data Task 3: Modify starter code 5

6 Task 1: Schema Design Official requirement Read the project description Design a good database schema 6

7 Task 1: Schema Design What you should do: Read description AND look inside the starter code App_code/Provided/ Read the classes, determine the fields 7

8 Task 1: Schema Design Optional: draw an E/R diagram Create a file: Create a second file: (why?) CREATE TABLE Customer ((...)) CREATE TABLE Invoice ((...))... DROP TABLE Customer DROP TABLE Invoice... 8

9 Task 1: Schema Design Things to worry about: Keys/foreign keys: note table order matters! Make sure you represent all the data Null-able or not (don t worry too muchh) Things not to worry about: fname or FirstName or PersonFirstName? varchar(20) or char(200) or varchar(120)? 9

10 Task 2: Import Sample Data Create a file: You may need to run this: INSERT INTO Customer ((...)) VALUES ( John,.) INSERT INTO Customer ((...)) VALUES ( Sue,.)... (why?) DROP TABLE Customer DROP TABLE Invoice... 10

11 Task 3: Modify Starter Code The starter code: C# ASP.NET (you do not need to understand it) It provides a Website for accessing your online store BUT it misses the fragments of code that get the data from the database See Phase1_Example/ 11

12 C# - Crash Course Hello World Properties (getters/setters) Enums Partial classes Dataset: DataTable, DataRow Connecting to a database 12

13 C# - Highlights C# = C++.Sytnax + Java.Semantics It is a safe language (like Java) Can be embedded in Webpages Can access a database Complex, but you should see the predecessors! 13

14 Hello World using System; class Hello { static void Main() { Console.WriteLine("Hello world"); } } 14

15 Properties: Getters and Setters public class Point { private int x; x; private string c; c; public int position { get { return x; x; } set { x = value; c = red ; } } public string color { get { return c; c; } set { c = value; x++; } } Point uvw = new Point(); uvw.position = 55; uvw.color = green ; uvw.position = uvw.position * 2; 2; if if (uvw.color == green ) 15

16 public class Stuff { private int x[]; Indexers Getters and setters with [ ] public int this[int i] i] { get {x[2*i+1]=0; return x[2*i]; } set { x[2*i] = value; x[2*i+1]=1; } } Stuff uvw = new Stuff(); uvw[12] = 55; uvw[99] = uvw[12]*7 + 2; uvw[99] = uvw[12]* ;

17 Enum enum Color: byte { Red = 1, Green = 2, Blue = 4, Black = 0, White = Red Green Blue, } 17

18 Partial Classes Some fields defined in file 1 Other fields defined in file 2 Why? Nguyen creates file 1, you create file 2 18

19 Dataset This is an important class that allows you to interact with a database Dataset = a mini database in main memory DataTable DataRow 19

20 DataSet DataSet mylocaldb = new DataSet(); /* /* create inside a table called books */ */....../* /*(this is is shown on a following slide) */ */ /* /* now use books */ */ DataTable x = mylocaldb.tables[ books ] foreach (DataRow y in in x.rows) { if if (y[ title ] == Harry Potter ) y[ price ]++;; } 20

21 Connecting to a Database Create or edit web.config file Specify iisqlsrv, user, password Give a name Create a SqlConnection refer to name Create a SqlDataAdaptor embed SQL query string Execute the Fill( ) method to run query and store answers in a datarow 21

22 Connecting to a Database /* /* create inside a table called books */ */ SqlConnection c = new SqlConnection(... name...);.); string q = select title, price year from products where price < 100 ; SQL = a string!!! impedance mismatch SqlDataAdapter a = new SqlDataAdapter(q, c); DataSet mylocaldb = new DataSet(); a.fill(mylocaldb, books ); 22

23 Task 3: Modify Starter Code What you have to do: App_Code/Phase1/Billing and Shipping/ Public partial class Customer { /* /* add your own fields, like: */ */ private int id, Procedure List<invoice> GetInvoices() { /* /* your GetInvoices code goes here */ */ } 23

24 Task 3: Modify Starter Code /* /* your GetInvoices code goes here */ */ string s = SELECT FROM. WHERE x.customerid = {0}, id); Substitutes id for {0} Defined in Provided StoreContext store = StoreContext.current; DataSet ds ds = new DataSet( ); ); DataTable invoices = store.getdatatable(s, ds, invoices ); /* /* continued on next slide. */ */ 24

25 Task 3: Modify Starter Code /* /* continued from previous slide */ */ List<Invoice> invoicelist new List<Invoice> ( ); ); foreach(datarow r in in invoices.rows) { invoicelist.add(new Invoice( r )); } return invoicelist; } Now you need to implement this 25

26 Task 3: Modify Starter Code public partial class Invoice { public Invoice(DataRow invoicedata) { /* /* here goes your code, something like that: */ */ init(invoicedata); /* /* may need it it in in several places */ */ }..... private void init(datarow invoicedata) { invoiceid = (int) invoicedata[ invoiceid ]; orderdate = (DateTime) invoicedata[ date ]; In Provided In you SQL 26

27 Time Estimate Task 1: about 9 tables or so, 2 hours or more Task 2: try 2 tuples per table, 1 hour Task 3: finding out what to do, errors, 7-8 hours 27

28 E/R Diagrams E/R diagrams: Chapter 2 Functional Dependencies and Normal Forms: Chapter 19 28

29 Database Design 1. Requirements Analysis: e.g. Phase 1 of the project 2. Conceptual Database Design: E/R diagrams 3. Logical Database Design: from E/R to relations 4. Schema Refinement: Normal Forms 5. Physical Database Design: indexes, etc 6. Application and security: not covered in this course 29

30 Conceptual Design = Entity / Relationship Diagrams Objects entities Classes entity sets Attributes are like in ODL. Product address Relationships: like in ODL except buys - first class citizens (not associated with classes) - not necessarily binary 30

31 name category name price Product makes Company stockprice buys Person employs address name ssn 31

32 Keys in E/R Diagrams Every entity set must have a key name category price Product 32

33 What is a Relation? A mathematical definition: if A, B are sets, then a relation R is a subset of A B 1 A={1,2,3}, B={a,b,c,d}, A B = {(1,a),(1,b),..., (3,d)} 2 A= R = {(1,a), (1,c), (3,b)} - makes is a subset of Product Company: 3 B= a b c d Product makes Company 33

34 Multiplicity of E/R Relations one-one: many-one many-many a b c d a b c d a b c d Note: book places arrow differently 34

35 name category name price Product makes Company buys What does this say? employs stockprice Person address name ssn 35

36 Multi-way Relationships How do we model a purchase relationship between buyers, products and stores? Product Purchase Store Person Can still model as a mathematical set (how?) 36

37 Q: what does the arrow mean? Arrows in Multiway Relationships Product Purchase Store Person A: a given person buys a given product from at most one store 37

38 Q: what does the arrow mean? Arrows in Multiway Relationships Product Purchase Store Person A: a given person buys a given product from at most one store AND every store sells to every person at most one product 38

39 Arrows in Multiway Relationships Q: How do we say that every person shops at at most one store? Product Purchase Store Person A: cannot. This is the best approximation. (Why only approximation?) 39

40 Converting Multi-way Relationships to Binary date ProductOf Product Purchase StoreOf Store BuyerOf Person 40

41 3. Design Principles What s wrong? Product Purchase Person Country President Person Moral: be faithful! 41

42 Design Principles: What s Wrong? Product date Purchase Store personaddr personname Moral: pick the right kind of entities. 42

43 Design Principles: What s Wrong? Dates date Product Purchase Store Moral: don t complicate life more than it already is. Person 43

44 Logical Database Design = E/R Relations Entity set relation Relationship relation 44

45 Entity Set to Relation name category price Product Product(name, category, price) name category price gizmo gadgets $

46 Relationships to Relations price name category Start Year name Product makes Company Stock price Makes(product-name, product-category, company-name, year) Product-name Product-Category Company-name Starting-year gizmo gadgets gizmoworks 1963 (watch out for attribute name conflicts) 46

47 Relationships to Relations price name category Start Year name Product makes Company No need for Makes. Modify Product: Stock price name category price StartYear companyname gizmo gadgets gizmoworks 47

48 Multi-way Relationships to Relations Product name address name price Purchase Store Purchase(prodName,stName,ssn) Person ssn name 48

49 Modeling Subclasses Some objects in a class may be special define a new class better: define a subclass Products Software products Educational products So --- we define subclasses in E/R 49

50 Subclasses name category price Product isa isa Software Product Educational Product platforms 50 Age Group

51 Understanding Subclasses Think in terms of records: Product SoftwareProduct EducationalProduct field1 field2 field1 field2 field3 field1 field2 field4 field5 51

52 Subclasses to Relations Product Name Price Category Gizmo 99 gadget name category Camera 49 photo price Toy 39 gadget Product Sw.Product Name platforms isa isa Ed.Product Gizmo unix Software Product Educational Product Name Age Group platforms Age Group Gizmo todler Toy retired 52

53 Difference between OO and E/R inheritance OO: classes are disjoint (same for Java, C++) Product sp1 SoftwareProduct sp2 p1 p2 p3 ep1 ep3 ep2 EducationalProduct 53

54 Difference between OO and E/R inheritance E/R: entity sets overlap Product SoftwareProduct sp1 sp2 p1 p2 p3 ep1 EducationalProduct ep2 ep3 54

55 No need for multiple inheritance in E/R Product SoftwareProduct sp1 sp2 p1 p2 p3 esp1 esp2 ep1 EducationalProduct ep2 ep3 We have three entity sets, but four different kinds of objects. 55

56 Modeling UnionTypes With Subclasses FurniturePiece Person Company Say: each piece of furniture is owned either by a person, or by a company 56

57 Modeling Union Types with Subclasses Say: each piece of furniture is owned either by a person, or by a company Solution 1. Acceptable, imperfect (What s wrong?) Person FurniturePiece Company ownedbyperson ownedbyperson 57

58 Modeling Union Types with Subclasses Solution 2: better, more laborious Owner isa isa Person ownedby Company FurniturePiece 58

59 Constraints in E/R Diagrams Finding constraints is part of the modeling process. Commonly used constraints: Keys: social security number uniquely identifies a person. Single-value constraints: a person can have only one father. Referential integrity constraints: if you work for a company, it must exist in the database. Other constraints: peoples ages are between 0 and

60 Keys in E/R Diagrams Underline: name category price No formal way to specify multiple keys in E/R diagrams Product Person address name ssn 60

61 Single Value Constraints makes v. s. makes 61

62 Referential Integrity Constraints Product makes Company Each product made by at most one company. Some products made by no company Product makes Company Each product made by exactly one company. 62

63 Other Constraints Product <100 makes Company What does this mean? 63

64 Weak Entity Sets Entity sets are weak when their key comes from other classes to which they are related. Team affiliation University sport number name Notice: we encountered this when converting multiway relationships to binary relationships (last lecture) 64

65 Handling Weak Entity Sets Team affiliation University sport number name Convert to a relational schema (in class) 65

66 Schema Refinements = Normal Forms 1st Normal Form = all tables are flat 2nd Normal Form = obsolete Boyce Codd Normal Form = will study 3rd Normal Form = see book 66

67 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 67

68 Relational Schema Design Conceptual Model: name Product buys Person price name ssn Relational Model: plus FD s Normalization: Eliminates anomalies 68

69 Data Anomalies When a database is poorly designed we get anomalies: Redundancy: data is repeated Updated anomalies: need to change in several places Delete anomalies: may lose data when we don t want 69

70 Relational Schema Design Recall set attributes (persons with several phones): Name SSN PhoneNumber City Fred Seattle Fred Seattle Joe Westfield One person may have multiple phones, but lives in only one city Anomalies: Redundancy = repeat data Update anomalies = Fred moves to Bellevue Deletion anomalies = Joe deletes his phone number: what is his city? 70

71 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

72 Relational Schema Design Main idea: (or Logical Design) Start with some relational schema Find out its functional dependencies Use them to design a better relational schema 72

73 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 73

74 Functional Dependencies Definition: If two tuples agree on the attributes A 11,, A 22,,, A nn then they must also agree on the attributes Formally: B 11,, B 22,,, B m A 1, 1, A 2, 2,, A n n B 1, 1, B 2, 2,, B m 74

75 When Does an FD Hold Definition: A 1,..., A m B 1,..., B n holds in R if: t, t R, (t.a 1 =t.a 1... t.a m =t.a m t.b 1 =t.b 1... t.b n =t.b n ) R A 1... A m B 1... B m t t if t, t agree here then t, t agree here 75

76 Examples An FD holds, or does not hold on an instance: EmpID Name Phone Position E0045 Smith 1234 Clerk E3542 Mike 9876 Salesrep E1111 Smith 9876 Salesrep E9999 Mary 1234 Lawyer EmpID Name, Phone, Position Position Phone but not Phone Position 76

77 Example EmpID Name Phone Position E0045 Smith 1234 Clerk E3542 Mike 9876 Salesrep E1111 Smith 9876 Salesrep E9999 Mary 1234 Lawyer Position Phone 77

78 Example EmpID Name Phone Position E0045 Smith 1234 Clerk E3542 Mike 9876 Salesrep E1111 Smith 9876 Salesrep E9999 Mary 1234 Lawyer but not Phone Position 78

79 Example FD s are constraints: 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? 79

80 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? 80

81 An Interesting Observation If all these FDs are true: name color category department color, category price Then this FD also holds: name, category price Why?? 81

82 Goal: Find ALL Functional Dependencies Anomalies occur when certain bad FDs hold We know some of the FDs Need to find all FDs, then look for the bad ones 82

83 Armstrong s Rules (1/3) A 11,, A 22,,, A nn B 11,, B 22,,, B m Is equivalent to Splitting rule and Combing rule A 11,, A 22,,, A nn B 11 A1... Am B1... Bm A 11,, A 22,,, A nn B A 11,, A 22,,, A nn B m 83

84 Armstrong s Rules (1/3) A 11,, A 22,,, A nn A ii Trivial Rule where i = 1, 2,..., n Why? A 1 A m 84

85 Armstrong s Rules (1/3) Transitive Closure Rule If A 11,, A 22,,, A nn B 11,, B 22,,, B m and B 11,, B 22,,, B m C 11,, C 22,,, C pp then A 11,, A 22,,, A nn C 11,, C 22,,, C pp Why? 85

86 A 1 A m B 1 B m C 1... C p 86

87 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 name color category department color, category price Which Rule did we apply? 87

88 Example (continued) Answers: name color category department 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, 7 THIS IS TOO HARD! Let s see an easier way. 88

89 Closure of a set of Attributes Given a set of of attributes A 1,,, A n The closure, {A 1,,, A n } + = the set of 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} 89

90 Closure Algorithm X={A1,, An}. Repeat until X doesn t change do: if if B 11,,, B nn C is is a FD and B 11,,, B nn are are all all in in X then add C to to X. X. Example: name color category department color, category price {name, category} + = { name, category, color, department, price } Hence: name, category color, department, price 90

91 Example In class: R(A,B,C,D,E,F) A, A, B C A, A, D E B D A, A, F B Compute {A,B} + X = {A, B, } Compute {A, F} + X = {A, F, } 91

92 Why Do We Need Closure With closure we can find all FD s easily To check if X A Compute X + Check if A X + 92

93 Using Closure to Infer ALL FDs Example: A, A, B C A, A, D B B D Step 1: Compute X +, for every X: A+ = A, A, B+ B+ = BD, C+ C+ = C, C, D+ = D AB+ =ABCD, AC+=AC, AD+=ABCD, BC+=BCD, BD+=BD, CD+=CD ABC+ = ABD+ = ACD + = ABCD (no need to to compute why?)?) BCD + = BCD, ABCD+ = ABCD Step 2: Enumerate all FD s X Y, s.t. Y X + and X Y = : 93 AB CD, AD BC, ABC D, D, ABD C, C, ACD B

94 Another Example Enrollment(student, major, course, room, time) student major major, course room course time What else can we infer? [in class, or at home] 94

95 Keys A superkey is a set of attributes A 1,..., A n s.t. for any other attribute B, we have A 1,..., A n B A key is a minimal superkey I.e. set of attributes which is a superkey and for which no subset is a superkey 95

96 Computing (Super)Keys Compute X + for all sets X If X + = all attributes, then X is a key List only the minimal X s 96

97 Example Product(name, price, category, color) name, category price category color What is the key? 97

98 Example Product(name, price, category, color) name, category price category color What is the key? (name, category) + = name, category, price, color Hence (name, category) is a key 98

99 Examples of Keys Enrollment(student, address, course, room, time) student address room, time course student, course room, time (find keys at home) 99

100 Eliminating Anomalies Main idea: X A is OK if X is a (super)key X A is not OK otherwise 100

101 Example Name SSN PhoneNumber City Fred Seattle Fred Seattle Joe Westfield Joe Westfield SSN Name, City What the key? {SSN, PhoneNumber} Hence SSN Name, City is a bad dependency 101

102 Key or Keys? Can we have more than one key? Given R(A,B,C) define FD s s.t. there are two or more keys 102

103 Key or Keys? Can we have more than one key? Given R(A,B,C) define FD s s.t. there are two or more keys AB C BC A or A BC B AC what are the keys here? Can you design FDs such that there are three keys? 103

104 Boyce-Codd Normal Form A simple condition for removing anomalies from relations: A relation R is is in in BCNF if: if: If If A 11,,...,..., A nn B is is a non-trivial dependency in in R,, then {A {A 11,,...,..., A n n } is is a superkey for for R In other words: there are no bad FDs Equivalently: X, either (X + = X) or (X + = all attributes) 104

105 BCNF Decomposition Algorithm repeat choose A 11,,, A m B 11,,, B nn that violates BNCF split R into R 11 (A (A 11,,, A m,, B 11,,, B n n )) and R 22 (A (A 11,,, A m,,[others]) continue with both R 11 and R 22 until no no more violations B s A s Others Is there a 2-attribute relation that is not in BCNF? R 1 R 2 In practice, we have 105 a better algorithm (coming up)

106 Example Name SSN PhoneNumber City Fred Seattle Fred Seattle Joe Westfield Joe Westfield SSN Name, City What the key? {SSN, PhoneNumber} use SSN Name, City to split 106

107 Example Name Fred SSN City Seattle SSN Name, City Joe Westfield SSN PhoneNumber Let s check anomalies: Redundancy? Update? Delete? 107

108 Example Decomposition Person(name, SSN, age, haircolor, phonenumber) SSN name, age age haircolor Decompose in BCNF (in class): 108

109 BCNF Decomposition Algorithm BCNF_Decompose(R) find X s.t.: X X + [all attributes] if if (not found) then R is is in in BCNF let Y = X + - X let Z = [all attributes] - X + decompose R into R1(X Y) and R2(X Z) continue to to decompose recursively R1 and R2 109

110 Find X s.t.: X X + [all attributes] Example BCNF Decomposition Person(name, SSN, age, haircolor, phonenumber) SSN name, age age haircolor Iteration 1: 1: Person SSN+ = SSN, name, age, haircolor Decompose into: P(SSN, name, age, haircolor) Phone(SSN, phonenumber) Iteration 2: 2: P age+ = age, haircolor Decompose: People(SSN, name, age) Hair(age, haircolor) Phone(SSN, phonenumber) What are the keys? 110

111 R(A,B,C,D) Example A B B C R(A,B,C,D) A + = ABC ABCD R 1 (A,B,C) B + = BC ABC R 2 (A,D) R 11 (B,C) R 12 (A,B) What are the keys? What happens if in R we first pick B +? Or AB +? 111

112 Decompositions in General R(A 11,,...,..., A n n,, B 11,,...,..., B m,, C 11,,...,..., C p p )) R 11 (A (A 11,,...,..., A n n,, B 11,,...,..., B m )) R 22 (A (A 11,,...,..., A n n,, C 11,,...,..., C p 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 112

113 Theory of 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 113

114 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 114

115 Decompositions in General R(A 11,,...,..., A n n,, B 11,,...,..., B m,, C 11,,...,..., C p p )) R 11 (A (A 11,,...,..., A n n,, B 11,,...,..., B m )) R 22 (A (A 11,,...,..., A n n,, C 11,,...,..., C p p )) If A 1,..., A n B 1,..., B m Then the decomposition is lossless Note: don t need A 1,..., A n C 1,..., C p BCNF decomposition is always lossless. WHY? 115

The Relational Data Model

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

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

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

Introduction to Database Systems CSE 414

Introduction to Database Systems CSE 414 Introduction to Database Systems CSE 414 Lecture 17: E/R Diagrams CSE 414 - Spring 2013 1 Announcements HW5 (XML) due Wednesday New webquiz coming by mid-week Today: E/R diagrams (4.1-4.6) CSE 414 - Spring

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

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

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

Introduction to Data Management CSE 344

Introduction to Data Management CSE 344 Introduction to Data Management CSE 344 Lecture 15: E/R Diagrams Guest Lecturer: Sudeepa Roy CSE 344 - Fall 2013 1 Announcements WQ6 due Thursday (there is no WQ5 ) Homework 4 posted, due Friday Midterm:

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

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

Introduction to Database Systems CSE 414. Lecture 19: E/R Diagrams

Introduction to Database Systems CSE 414. Lecture 19: E/R Diagrams Introduction to Database Systems CSE 414 Lecture 19: E/R Diagrams CSE 414 - Spring 2018 1 Class Overview Unit 1: Intro Unit 2: Relational Data Models and Query Languages Unit 3: Non-relational data Unit

More information

Database Systems CSE 414

Database Systems CSE 414 Database Systems CSE 414 Lecture 17: E/R Diagrams (4.1-6) and Constraints (7.1-2) CSE 414 - Spring 2017 1 Announcements HW5 due on Thursday (was Tuesday before) WQ6 due on Sunday CSE 414 - Spring 2017

More information

Lecture 4. Lecture 4: The E/R Model

Lecture 4. Lecture 4: The E/R Model Lecture 4 Lecture 4: The E/R Model Lecture 4 Today s Lecture 1. E/R Basics: Entities & Relations ACTIVITY: Crayon time! 2. E/R Design considerations ACTIVITY: Crayon time pt. II 3. Advanced E/R Concepts

More information

CSE 344 JULY 30 TH DB DESIGN (CH 4)

CSE 344 JULY 30 TH DB DESIGN (CH 4) CSE 344 JULY 30 TH DB DESIGN (CH 4) ADMINISTRIVIA HW6 due next Thursday uses Spark API rather than MapReduce (a bit higher level) be sure to shut down your AWS cluster when not in use Still grading midterms...

More information

Announcements. Database Design. Database Design. Database Design Process. Entity / Relationship Diagrams. Introduction to Data Management CSE 344

Announcements. Database Design. Database Design. Database Design Process. Entity / Relationship Diagrams. Introduction to Data Management CSE 344 Announcements Introduction to Data Management CSE 344 HW5 due this Friday Please note minor up to the instructions WQ6 due next Wednesday Lecture 17: E/R Diagrams and Constraints 1 2 Database Design What

More information

Database Systems CSE 414

Database Systems CSE 414 Database Systems CSE 414 Lecture 22: E/R Diagrams (4.1-6) and Constraints (7.1-2) CSE 414 - Fall 2017 1 Announcements HW7 will be posted on Tuesday and due on Dec. 1 st 11pm WQ6 will be posted on Tuesday

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

Lecture 5. Lecture 5: The E/R Model

Lecture 5. Lecture 5: The E/R Model Lecture 5 Lecture 5: The E/R Model Lecture 2 Announcements! 1. PS1 due at midnight! Please go over Piazza for hints. We will post solutions tomorrow. Grades coming soon! 2. Project part 1 out today! 3.

More information

Database Design Process Entity / Relationship Diagrams

Database Design Process Entity / Relationship Diagrams Announcements Database Systems CSE 414 Lecture 22: E/R Diagrams (4.1-6) and Constraints (7.1-2) HW7 will be posted on Tuesday and due on Dec. 1 st 11pm WQ6 will be posted on Tuesday and due on Nov. 30th

More information

Announcements. Database Design. Database Design. Database Design Process. Entity / Relationship Diagrams. Database Systems CSE 414

Announcements. Database Design. Database Design. Database Design Process. Entity / Relationship Diagrams. Database Systems CSE 414 Announcements Database Systems CSE 414 HW5 due on Thursday (was Tuesday before) WQ6 due on Sunday Lecture 17: E/R Diagrams (4.1-6) and Constraints (7.1-2) 1 2 Database Design What it is: Starting from

More information

Database design and implementation CMPSCI 645. Lecture 06: Constraints and E/R model

Database design and implementation CMPSCI 645. Lecture 06: Constraints and E/R model Database design and implementation CMPSCI 645 Lecture 06: Constraints and E/R model Constraints } Constraint: a property that we want our data to sa2sfy } Enforce by taking ac2ons: } Forbid an update }

More information

CSE 344 MAY 14 TH ENTITIES

CSE 344 MAY 14 TH ENTITIES CSE 344 MAY 14 TH ENTITIES EXAMS Scores Final grades Concerned? Email about meeting Final Exam 35% of grade ADMINISTRIVIA HW6 Due Wednesday OQ6 Out Wednesday HW7 Out Wednesday E/R + Normalization DATABASE

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

ENTITY-RELATIONSHIP MODEL. CS 564- Spring 2018

ENTITY-RELATIONSHIP MODEL. CS 564- Spring 2018 ENTITY-RELATIONSHIP MODEL CS 564- Spring 2018 WHAT IS THIS LECTURE ABOUT E/R Model: entity sets, attribute relation: binary, multi-way relationship roles, attributes on relationships subclasses (ISA) weak

More information

Conceptual Design with ER Model

Conceptual Design with ER Model Conceptual Design with ER Model Lecture #2 1/24/2012 Jeff Ballard CS564, Spring 2014, Database Management Systems 1 See the Moodle page Due February 7 Groups of 2-3 people Pick a team name Homework 1 is

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

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

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

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

3. Advanced E/R Concepts

3. Advanced E/R Concepts 3. Advanced E/R Concepts 75 What you will learn about in this section Subclasses & connection to OO Constraints Weak entity sets 76 Modeling Subclasses Some objects in a class may be special, i.e. worthy

More information

3. Advanced E/R Concepts

3. Advanced E/R Concepts What you will learn about in this section Subclasses & connection to OO 3. Advanced E/R Concepts Constraints Weak entity sets 75 76 Modeling Subclasses Modeling Subclasses Some objects in a class may be

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

2. E/R Design Considerations

2. E/R Design Considerations 2. E/R Design Considerations 32 What you will learn in this section Relationships cont d: multiplicity, multi-way Design considerations Conversion to SQL 33 Multiplicity of E/R Relationships Multiplicity

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

L11: ER modeling 4. CS3200 Database design (sp18 s2) 2/15/2018

L11: ER modeling 4. CS3200 Database design (sp18 s2)   2/15/2018 L11: ER modeling 4 CS3200 Database design (sp18 s2) https://course.ccs.neu.edu/cs3200sp18s2/ 2/15/2018 132 Announcements! Keep coming with your name plates Mid-course feedback for instructor - Exam: Cheat

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

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

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

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

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

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 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

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

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

Where Are We? Next Few Lectures. Integrity Constraints Motivation. Constraints in E/R Diagrams. Keys in E/R Diagrams

Where Are We? Next Few Lectures. Integrity Constraints Motivation. Constraints in E/R Diagrams. Keys in E/R Diagrams Where Are We? Introduction to Data Management CSE 344 Lecture 15: Constraints We know quite a bit about using a DBMS Start with real-world problem, design ER diagram From ER diagram to relations -> conceptual

More information

CSE 544 Data Models. Lecture #3. CSE544 - Spring,

CSE 544 Data Models. Lecture #3. CSE544 - Spring, CSE 544 Data Models Lecture #3 1 Announcements Project Form groups by Friday Start thinking about a topic (see new additions to the topic list) Next paper review: due on Monday Homework 1: due the following

More information

Database Management

Database Management Database Management - 2011 Model Answers 1. a. A data model should comprise a structural part, an integrity part and a manipulative part. The relational model provides standard definitions for all three

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

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

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

CSC 261/461 Database Systems Lecture 8. Spring 2018

CSC 261/461 Database Systems Lecture 8. Spring 2018 CSC 261/461 Database Systems Lecture 8 Spring 2018 Announcement Quiz No New Problem Set Study Chapter 5, 6, and 7 Go through the problem set Announcement Project 2 Part 1 Already out. Workshop covered

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

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

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

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

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

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

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

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

Introduction to Database Systems CSE 414

Introduction to Database Systems CSE 414 Introduction to Database Systems CSE 414 Lecture 16: Constraints CSE 414 - Spring 2015 1 Announcements Reminders: Web quiz due Monday night XML homework due Wednesday night Today: Constraints (7.1, 7.2,

More information

Introduction to Data Management CSE 344

Introduction to Data Management CSE 344 Introduction to Data Management CSE 344 Lecture 16: Constraints CSE 344 - Fall 2014 1 Announcements Sections tomorrow: XML. Quiz and next HW on XML posted soon, due next week after midterm HW 4 due tomorrow

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

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

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

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

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

BİL 354 Veritabanı Sistemleri. Relational Model (İlişkisel Veri Modeli)

BİL 354 Veritabanı Sistemleri. Relational Model (İlişkisel Veri Modeli) BİL 354 Veritabanı Sistemleri Relational Model (İlişkisel Veri Modeli) DB Modeling & Implementation Ideas Database Model (E/R, ODL) Relational Schema Physical storage Diagrams (E/R) Tables: column names:

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

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

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

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

6.830 Lecture PS1 Due Next Time (Tuesday!) Lab 1 Out end of week start early!

6.830 Lecture PS1 Due Next Time (Tuesday!) Lab 1 Out end of week start early! 6.830 Lecture 3 9.13.2017 PS1 Due Next Time (Tuesday!) Lab 1 Out end of week start early! Relational Model Continued, and Schema Design and Normalization Animals(name,age,species,cageno,keptby,feedtime)

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

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

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

CS 461: Database Systems. Final Review. Julia Stoyanovich

CS 461: Database Systems. Final Review. Julia Stoyanovich CS 461: Database Systems Final Review (stoyanovich@drexel.edu) Final exam logistics When: June 6, in class The same format as the midterm: open book, open notes 2 hours in length The exam is cumulative,

More information

Applied Databases. Sebastian Maneth. Lecture 5 ER Model, Normal Forms. University of Edinburgh - January 30 th, 2017

Applied Databases. Sebastian Maneth. Lecture 5 ER Model, Normal Forms. University of Edinburgh - January 30 th, 2017 Applied Databases Lecture 5 ER Model, Normal Forms Sebastian Maneth University of Edinburgh - January 30 th, 2017 Outline 2 1. Entity Relationship Model 2. Normal Forms From Last Lecture 3 the Lecturer

More information

CSC 261/461 Database Systems Lecture 8. Fall 2017

CSC 261/461 Database Systems Lecture 8. Fall 2017 CSC 261/461 Database Systems Lecture 8 Fall 2017 Announcement Project 2 is out. Not a group project! CSC 261, Spring 2017, UR Agenda More about ER model ER model to Relation (Table) CSC 261, Spring 2017,

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

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

Relational Design Theory

Relational Design Theory Chapter 5 Relational Design Theory Database Systems p. 211/569 Relational Design Theory A badly designed schema can cause a lot of trouble Database designers talk of anomalies and distinguish three different

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

Mapping ER Diagrams to. Relations (Cont d) Mapping ER Diagrams to. Exercise. Relations. Mapping ER Diagrams to Relations (Cont d) Exercise

Mapping ER Diagrams to. Relations (Cont d) Mapping ER Diagrams to. Exercise. Relations. Mapping ER Diagrams to Relations (Cont d) Exercise CSC 74 Database Management Systems Topic #6: Database Design Weak Entity Type E Create a relation R Include all simple attributes and simple components of composite attributes. Include the primary key

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

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

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

From Murach Chap. 9, second half. Schema Refinement and Normal Forms

From Murach Chap. 9, second half. Schema Refinement and Normal Forms From Murach Chap. 9, second half The need for normalization A table that contains repeating columns Schema Refinement and Normal Forms A table that contains redundant data (same values repeated over and

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

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

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

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

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

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

The Entity-Relationship Model (ER Model) - Part 1 Lecture 4 The Entity-Relationship Model (ER Model) - Part 1 By Michael Hahsler Based on slides for CS145 Introduction to Databases (Stanford) Lecture 4 > Section 1 Introduction to Database Design 2 Lecture

More information

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

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

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

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

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

6 February 2014 CSE-3421M Test #1 w/ answers p. 1 of 14. CSE-3421M Test #1. Design

6 February 2014 CSE-3421M Test #1 w/ answers p. 1 of 14. CSE-3421M Test #1. Design 6 February 2014 CSE-3421M Test #1 w/ answers p. 1 of 14 CSE-3421M Test #1 Design Sur / Last Name: Given / First Name: Student ID: Instructor: Parke Godfrey Exam Duration: 75 minutes Term: Winter 2014 Answer

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