# Boyce-Codd Normal Form

Save this PDF as:

Size: px
Start display at page:

## Transcription

1 Boyce-Codd Normal Form We say a relation R is in BCNF if whenever X Y is a nontrivial FD that holds in R, X is a superkey Remember: nontrivial means Y is not contained in X Remember, a superkey is any superset of a key (not necessarily a proper superset) 1

2 Example Drinkers(name, addr, beersliked, manf, favbeer) FD s: name addr favbeer, beersliked manf Only key is {name, beersliked} In each FD, the left side is not a superkey Any one of these FD s shows Drinkers is not in BCNF 2

3 Another Example Beers(name, manf, manfaddr) FD s: name manf, manf manfaddr Only key is {name} Name manf does not violate BCNF, but manf manfaddr does 3

4 Decomposition into BCNF Given: relation R with FD s F Look among the given FD s for a BCNF violation X Y If any FD following from F violates BCNF, then there will surely be an FD in F itself that violates BCNF Compute X + Not all attributes, or else X is a superkey 4

5 Decompose R Using X Y Replace R by relations with schemas: 1. R 1 = X + 2. R 2 = R (X + X ) Project given FD s F onto the two new relations 5

6 Decomposition Picture R 1 R-X + X X + -X R 2 R 6

7 Example: BCNF Decomposition Drinkers(name, addr, beersliked, manf, favbeer) F = name addr, name favbeers beersliked manf Pick BCNF violation name addr Close the left side: {name} + = {name, addr, favbeer} Decomposed relations: 1. Drinkers1(name, addr, favbeer) 2. Drinkers2(name, beersliked, manf) 7

8 Example: BCNF Decomposition We are not done; we need to check Drinkers1 and Drinkers2 for BCNF Projecting FD s is easy here For Drinkers1(name, addr, favbeer), relevant FD s are name addr and name favbeer Thus, {name} is the only key and Drinkers1 is in BCNF 8

9 Example: BCNF Decomposition For Drinkers2(name, beersliked, manf), the only FD is beersliked manf, and the only key is {name, beersliked} Violation of BCNF beersliked + = {beersliked, manf}, so we decompose Drinkers2 into: 1. Drinkers3(beersLiked, manf) 2. Drinkers4(name, beersliked) 9

10 Example: BCNF Decomposition The resulting decomposition of Drinkers: 1. Drinkers1(name, addr, favbeer) 2. Drinkers3(beersLiked, manf) 3. Drinkers4(name, beersliked) Notice: Drinkers1 tells us about drinkers, Drinkers3 tells us about beers, and Drinkers4 tells us the relationship between drinkers and the beers they like Compare with running example: 1. Drinkers(name, addr, phone) 2. Beers(name, manf) 3. Likes(drinker,beer) 10

11 Third Normal Form Motivation There is one structure of FD s that causes trouble when we decompose AB C and C B Example: A = street address, B = city, C = post code There are two keys, {A,B } and {A,C } C B is a BCNF violation, so we must decompose into AC, BC 11

12 We Cannot Enforce FD s The problem is that if we use AC and BC as our database schema, we cannot enforce the FD AB C by checking FD s in these decomposed relations Example with A = street, B = city, and C = post code on the next slide 12

13 An Unenforceable FD street post Campusvej 5230 Vestergade 5000 city post Odense 5230 Odense 5000 Join tuples with equal post codes street city post Campusvej Odense 5230 Vestergade Odense 5000 No FD s were violated in the decomposed relations and FD street city post holds for the database as a whole 13

14 An Unenforceable FD street post Hjallesevej 5230 Hjallesevej 5000 city post Odense 5230 Odense 5000 Join tuples with equal post codes street city post Hjallesevej Odense 5230 Hjallesevej Odense 5000 Although no FD s were violated in the decomposed relations, FD street city post is violated by the database as a whole 14

15 Another Unenforcable FD Departures(time, track, train) time track train and train track Two keys, {time,track} and {time,train} train track is a BCNF violation, so we must decompose into Departures1(time, train) Departures2(track,train) 15

16 Another Unenforceable FD time train 19:08 ICL54 19:16 IC852 track train 4 ICL54 3 IC852 Join tuples with equal train code time track train 19:08 4 ICL54 19:16 3 IC852 No FD s were violated in the decomposed relations, FD time track train holds for the database as a whole 16

17 Another Unenforceable FD time train 19:08 ICL54 19:08 IC 42 track train 4 ICL54 4 IC 42 Join tuples with equal train code time track train 19:08 4 ICL54 19:08 4 IC 42 Although no FD s were violated in the decomposed relations, FD time track train is violated by the database as a whole 17

18 3NF Let s Us Avoid This Problem 3 rd Normal Form (3NF) modifies the BCNF condition so we do not have to decompose in this problem situation An attribute is prime if it is a member of any key X A violates 3NF if and only if X is not a superkey, and also A is not prime 18

19 Example: 3NF In our problem situation with FD s AB C and C B, we have keys AB and AC Thus A, B, and C are each prime Although C B violates BCNF, it does not violate 3NF 19

20 What 3NF and BCNF Give You There are two important properties of a decomposition: 1. Lossless Join: it should be possible to project the original relations onto the decomposed schema, and then reconstruct the original 2. Dependency Preservation: it should be possible to check in the projected relations whether all the given FD s are satisfied 20

21 3NF and BCNF Continued We can get (1) with a BCNF decomposition We can get both (1) and (2) with a 3NF decomposition But we can t always get (1) and (2) with a BCNF decomposition street-city-post is an example time-track-train is another example 21

22 Testing for a Lossless Join If we project R onto R 1, R 2,, R k, can we recover R by rejoining? Any tuple in R can be recovered from its projected fragments So the only question is: when we rejoin, do we ever get back something we didn t have originally? 22

23 The Chase Test Suppose tuple t comes back in the join Then t is the join of projections of some tuples of R, one for each R i of the decomposition Can we use the given FD s to show that one of these tuples must be t? 23

24 The Chase (2) Start by assuming t = abc. For each i, there is a tuple s i of R that has a, b, c, in the attributes of R i s i can have any values in other attributes We ll use the same letter as in t, but with a subscript, for these components 24

25 Example: The Chase Let R = ABCD, and the decomposition be AB, BC, and CD Let the given FD s be C D and B A Suppose the tuple t = abcd is the join of tuples projected onto AB, BC, CD 25

26 The tuples of R projected onto AB, BC, CD The Tableau A B C D a b c 1 d 1 a 2 a b c d 2 a 3 b 3 c d Use B A Use C D We ve proved the second tuple must be t 26

27 Summary of the Chase 1. If two rows agree in the left side of a FD, make their right sides agree too 2. Always replace a subscripted symbol by the corresponding unsubscripted one, if possible 3. If we ever get an unsubscripted row, we know any tuple in the project-join is in the original (the join is lossless) 4. Otherwise, the final tableau is a counterexample 27

28 Example: Lossy Join Same relation R = ABCD and same decomposition. But with only the FD C D 28

29 These projections rejoin to form abcd The Tableau A B C D a b c 1 d 1 a 2 b c d 2 a 3 b 3 c d These three tuples are an example Use C D R that shows the join lossy abcd is not in R, but we can project and rejoin to get abcd 29

30 3NF Synthesis Algorithm We can always construct a decomposition into 3NF relations with a lossless join and dependency preservation Need minimal basis for the FD s: 1. Right sides are single attributes 2. No FD can be removed 3. No attribute can be removed from a left side 30

31 Constructing a Minimal Basis 1. Split right sides 2. Repeatedly try to remove an FD and see if the remaining FD s are equivalent to the original 3. Repeatedly try to remove an attribute from a left side and see if the resulting FD s are equivalent to the original 31

32 3NF Synthesis (2) One relation for each FD in the minimal basis Schema is the union of the left and right sides If no key is contained in an FD, then add one relation whose schema is some key 32

33 Example: 3NF Synthesis Relation R = ABCD FD s A B and A C Decomposition: AB and AC from the FD s, plus AD for a key 33

34 Why It Works Preserves dependencies: each FD from a minimal basis is contained in a relation, thus preserved Lossless Join: use the chase to show that the row for the relation that contains a key can be made allunsubscripted variables 3NF: hard part a property of minimal bases 34

35 Summary 5 More things you should know: Functional Dependency Key, Superkey Update Anomaly, Deletion Anomaly BCNF, Closure, Decomposition Chase Algorithm 3rd Normal Form 35

36 Entity-Relationship Model 36

37 Purpose of E/R Model The E/R model allows us to sketch database schema designs Includes some constraints, but not operations Designs are pictures called entityrelationship diagrams Later: convert E/R designs to relational DB designs 37

38 Framework for E/R Design is a serious business The boss knows they want a database, but they don t know what they want in it Sketching the key components is an efficient way to develop a working database 38

39 Entity Sets Entity = thing or object Entity set = collection of similar entities Similar to a class in object-oriented languages Attribute = property of (the entities of) an entity set Attributes are simple values, e.g. integers or character strings, not structs, sets, etc. 39

40 E/R Diagrams In an entity-relationship diagram: Entity set = rectangle Attribute = oval, with a line to the rectangle representing its entity set 40

41 Example: name manf Beers Entity set Beers has two attributes, name and manf (manufacturer) Each Beers entity has values for these two attributes, e.g. (Odense Classic, Albani) 41

42 Relationships A relationship connects two or more entity sets It is represented by a diamond, with lines to each of the entity sets involved 42

43 Example: Relationships name addr name manf Bars Sells Beers Bars sell some beers license Note: license = beer, full, none Frequents name Drinkers Likes addr Drinkers like some beers Drinkers frequent some bars 43

44 Relationship Set The current value of an entity set is the set of entities that belong to it Example: the set of all bars in our database The value of a relationship is a relationship set, a set of tuples with one component for each related entity set 44

45 Example: Relationship Set For the relationship Sells, we might have a relationship set like: Bar Beer C.Ch. Od.Cl. C.Ch. Erd.Wei. C.Bio. Od.Cl. Brygg. Pilsener C4 Erd.Wei. 45

46 Multiway Relationships Sometimes, we need a relationship that connects more than two entity sets Suppose that drinkers will only drink certain beers at certain bars Our three binary relationships Likes, Sells, and Frequents do not allow us to make this distinction But a 3-way relationship would 46

48 A Typical Relationship Set Bar Drinker Beer C.Ch. Peter Erd.Wei. C.Ch. Lars Od.Cl. C.Bio. Peter Od.Cl. Brygg. Peter Pilsener C4 Peter Erd.Wei. C.Bio. Lars Tuborg Brygg. Lars Ale 48

49 Many-Many Relationships Focus: binary relationships, such as Sells between Bars and Beers In a many-many relationship, an entity of either set can be connected to many entities of the other set E.g., a bar sells many beers; a beer is sold by many bars 49

50 In Pictures: many-many 50

51 Many-One Relationships Some binary relationships are many - one from one entity set to another Each entity of the first set is connected to at most one entity of the second set But an entity of the second set can be connected to zero, one, or many entities of the first set 51

52 In Pictures: many-one 52

53 Example: Many-One Relationship Favorite, from Drinkers to Beers is many-one A drinker has at most one favorite beer But a beer can be the favorite of any number of drinkers, including zero 53

54 One-One Relationships In a one-one relationship, each entity of either entity set is related to at most one entity of the other set Example: Relationship Best-seller between entity sets Manfs (manufacturer) and Beers A beer cannot be made by more than one manufacturer, and no manufacturer can have more than one best-seller (assume no ties) 54

55 In Pictures: one-one 55

56 Representing Multiplicity Show a many-one relationship by an arrow entering the one side Remember: Like a functional dependency Show a one-one relationship by arrows entering both entity sets Rounded arrow = exactly one, i.e., each entity of the first set is related to exactly one entity of the target set 56

57 Example: Many-One Relationship Drinkers Likes Beers Favorite Notice: two relationships connect the same entity sets, but are different 57

58 Example: One-One Relationship Consider Best-seller between Manfs and Beers Some beers are not the best-seller of any manufacturer, so a rounded arrow to Manfs would be inappropriate. But a beer manufacturer has to have a best-seller 58

59 In the E/R Diagram Manfs Bestseller Beers A beer is the bestseller for 0 or 1 manufacturer(s) A manufacturer has exactly one best seller 59

60 Attributes on Relationships Sometimes it is useful to attach an attribute to a relationship Think of this attribute as a property of tuples in the relationship set 60

61 Example: Attribute on Relationship Bars Sells Beers price Price is a function of both the bar and the beer, not of one alone 61

62 Equivalent Diagrams Without Attributes on Relationships Create an entity set representing values of the attribute Make that entity set participate in the relationship 62

63 Example: Removing an Attribute from a Relationship Bars Sells Beers Prices price Note convention: arrow from multiway relationship = all other entity sets together determine a unique one of these 63

64 Roles Sometimes an entity set appears more than once in a relationship Label the edges between the relationship and the entity set with names called roles 64

65 Example: Roles Relationship Set Married Husband Wife Lars Lene Kim Joan husband Drinkers wife 65

66 Example: Roles Relationship Set Buddies 1 2 Drinkers Buddy1 Buddy2 Peter Lars Peter Pepe Pepe Bea Bea Rafa 66

67 Subclasses Subclass = special case = fewer entities = more properties Example: Ales are a kind of beer Not every beer is an ale, but some are Let us suppose that in addition to all the properties (attributes and relationships) of beers, ales also have the attribute color 67

68 Subclasses in E/R Diagrams Assume subclasses form a tree I.e., no multiple inheritance Isa triangles indicate the subclass relationship Point to the superclass 68

69 Example: Subclasses name Beers manf isa color Ales 69

70 E/R Vs. Object-Oriented Subclasses In OO, objects are in one class only Subclasses inherit from superclasses. In contrast, E/R entities have representatives in all subclasses to which they belong Rule: if entity e is represented in a subclass, then e is represented in the superclass (and recursively up the tree) 70

71 Example: Representatives of Entities name Beers manf isa Pete s Ale color Ales 71

72 Keys A key is a set of attributes for one entity set such that no two entities in this set agree on all the attributes of the key It is allowed for two entities to agree on some, but not all, of the key attributes We must designate a key for every entity set 72

73 Keys in E/R Diagrams Underline the key attribute(s) In an Isa hierarchy, only the root entity set has a key, and it must serve as the key for all entities in the hierarchy 73

74 Example: name is Key for Beers name Beers manf isa color Ales 74

75 Example: a Multi-attribute Key dept number hours room Courses Note that hours and room could also serve as a key, but we must select only one key 75

76 Weak Entity Sets Occasionally, entities of an entity set need help to identify them uniquely Entity set E is said to be weak if in order to identify entities of E uniquely, we need to follow one or more manyone relationships from E and include the key of the related entities from the connected entity sets 76

77 Example: Weak Entity Set name is almost a key for football players, but there might be two with the same name number is certainly not a key, since players on two teams could have the same number. But number, together with the team name related to the player by Plays-on should be unique 77

78 In E/R Diagrams name number name Players Playson Teams Note: must be rounded because each player needs a team to help with the key Double diamond for supporting many-one relationship Double rectangle for the weak entity set 78

79 Weak Entity-Set Rules A weak entity set has one or more many-one relationships to other (supporting) entity sets Not every many-one relationship from a weak entity set need be supporting But supporting relationships must have a rounded arrow (entity at the one end is guaranteed) 79

80 Weak Entity-Set Rules (2) The key for a weak entity set is its own underlined attributes and the keys for the supporting entity sets E.g., (player) number and (team) name is a key for Players in the previous example 80

81 Design Techniques 1. Avoid redundancy 2. Limit the use of weak entity sets 3. Don t use an entity set when an attribute will do 81

82 Avoiding Redundancy Redundancy = saying the same thing in two (or more) different ways Wastes space and (more importantly) encourages inconsistency Two representations of the same fact become inconsistent if we change one and forget to change the other Recall anomalies due to FD s 82

83 Example: Good name name addr Beers ManfBy Manfs This design gives the address of each manufacturer exactly once 83

84 Example: Bad name name addr Beers ManfBy Manfs manf This design states the manufacturer of a beer twice: as an attribute and as a related entity. 84

85 Example: Bad name manf manfaddr Beers This design repeats the manufacturer s address once for each beer and loses the address if there are temporarily no beers for a manufacturer 85

86 Entity Sets Versus Attributes An entity set should satisfy at least one of the following conditions: It is more than the name of something; it has at least one nonkey attribute or It is the many in a many-one or manymany relationship 86

87 Example: Good name name addr Beers ManfBy Manfs Manfs deserves to be an entity set because of the nonkey attribute addr Beers deserves to be an entity set because it is the many of the many-one relationship ManfBy 87

88 Example: Good name manf Beers There is no need to make the manufacturer an entity set, because we record nothing about manufacturers besides their name 88

89 Example: Bad name name Beers ManfBy Manfs Since the manufacturer is nothing but a name, and is not at the many end of any relationship, it should not be an entity set 89

90 Don t Overuse Weak Entity Sets Beginning database designers often doubt that anything could be a key by itself They make all entity sets weak, supported by all other entity sets to which they are linked In reality, we usually create unique ID s for entity sets Examples include CPR numbers, car s license plates, etc. 90

91 When Do We Need Weak Entity Sets? The usual reason is that there is no global authority capable of creating unique ID s Example: it is unlikely that there could be an agreement to assign unique player numbers across all football teams in the world 91

92 From E/R Diagrams to Relations Entity set relation Attributes attributes Relationships relations whose attributes are only: The keys of the connected entity sets Attributes of the relationship itself 92

93 Entity Set Relation name manf Beers Relation: Beers(name, manf) 93

94 Relationship Relation name addr name manf husband Drinkers 1 2 Likes Beers Buddies Married wife Favorite Likes(drinker, beer) Favorite(drinker, beer) Buddies(name1, name2) Married(husband, wife) 94

95 Combining Relations OK to combine into one relation: 1. The relation for an entity-set E 2. The relations for many-one relationships of which E is the many Example: Drinkers(name, addr) and Favorite(drinker, beer) combine to make Drinker1(name, addr, favbeer) 95

96 Risk with Many-Many Relationships Combining Drinkers with Likes would be a mistake. It leads to redundancy, as: name addr beer Peter Campusvej Od.Cl. Peter Campusvej Erd.W. Redundancy 96

97 Handling Weak Entity Sets Relation for a weak entity set must include attributes for its complete key (including those belonging to other entity sets), as well as its own, nonkey attributes A supporting relationship is redundant and yields no relation (unless it has attributes) 97

98 Example: Weak Entity Set Relation name name expiry Logins At Hosts location Hosts(hostName, location) Logins(loginName, hostname, expiry) At(loginName, hostname, hostname2) At becomes part of Logins Must be the same 98

99 Subclasses: Three Approaches 1. Object-oriented : One relation per subset of subclasses, with all relevant attributes 2. Use nulls : One relation; entities have NULL in attributes that don t belong to them 3. E/R style : One relation for each subclass: Key attribute(s) Attributes of that subclass 99

100 Example: Subclass Relations name Beers manf isa color Ales 100

101 Object-Oriented name manf Odense Classic Albani Beers name manf color HC Andersen Albani red Ales Good for queries like find the color of ales made by Albani 101

102 name manf Odense Classic Albani HC Andersen Albani Beers E/R Style name HC Andersen color red Ales Good for queries like find all beers (including ales) made by Albani 102

103 Using Nulls name manf color Odense Classic Albani NULL HC Andersen Albani red Beers Saves space unless there are lots of attributes that are usually NULL 103

104 Summary 6 More things you should know: Entities, Attributes, Entity Sets, Relationships, Multiplicity, Keys Roles, Subclasses, Weak Entity Sets Design guidelines E/R diagrams relational model 104

105 The Project 105

106 Purpose of the Project To try in practice the process of designing and creating a relational database application This process includes: development of an E/R model transfer to the relational model normalization of relations implementation in a DBMS programming of an application 106

107 Project as part of The Exam Part of the exam and grading! The project must be done individually No cooperation is allowed beyond what is explicitly stated in the description 107

108 Subject of the Project To create an electronic inventory for a computer store Keep information about complete computer systems and components System should be able to calculate prices for components and computer systems make lists of components to order from the distributor 108

109 Objects of the System component: name, kind, price kind is one of CPU, RAM, graphics card, mainboard, case CPU: socket, bus speed RAM: type, bus speed mainboard: CPU socket, RAM type, onboard graphics?, form factor case: form factor 109

110 Objects of the System computer system: catchy name, list of components requires a case, a mainboard, a CPU, RAM, optionally a graphics card sockets, bus speed, RAM type, and form factor must match if there is no on-board graphics, a graphics card must be included 110

111 Objects of the System current stock: list of components and their current amount minimum inventory: list of components, their allowed minimum amount, and their preferred amount after restocking 111

112 Intended Use of the System Print a daily price list for components and computer systems Give quotes for custom orders Print out a list of components for restocking on Saturday morning (computer store restocks his inventory every Saturday at his distributor) 112

113 Selling Price Selling price for a component is the price + 30% Selling price for a computer system is sum of the selling prices of the components rounded up to next 99 Rebate System: total price is reduced by 2% for each additional computer system ordered maximal 20% rebate 113

114 Example: Selling Price computer system for which the components are worth DKK 1984 the selling price of the components is 1984*1.3 = It would be sold for DKK 2599 Order of 3 systems: DKK 7485, i.e., DKK 2495 per system Order of 11, 23, or 42 systems: DKK 2079 per system 114

115 Functionality of the System List of all components in the system and their current amount List of all computer systems in the system and how many of each could be build from the current stock Price list including all components and their selling prices grouped by kind all computers systems that could be build from the current stock including their components and selling price 115

116 Functionality of the System Price offer given the computer system and the quantity Sell a component or a computer system by updating the current stock Restocking list including names and amounts of all components needed for restocking to the preferred level 116

117 Limitations for the Project No facilities for updating are required except for the Selling mentioned explicitly Only a simple command-line based interface for user interaction is required Choices by the user can be input by showing a numbered list of alternatives or by prompting for component names, etc. You are welcome to include update facilities or make a better user interface but this will not influence the final grade! 117

118 Tasks 1. Develop an appropriate E/R model 2. Transfer to a relational model 3. Ensure that all relations are in 3NF (decompose and refine the E/R model) 4. Implement in PostgreSQL DBMS (ensuring the constraints hold) 5. Program in Java or Python an application for the user interaction providing all functionality from above 118

119 Test Data Can be made up as you need it At least in the order of 8 computer systems and 30 components Sharing data with other participants in the course is explicitly allowed and encouraged 119

120 Formalities Printed report of approx. 10 pages design choices and reasoning structure of the final solution Must include: A diagram of your E/R model Schemas of your relations Arguments showing that these are in 3NF Central parts of your SQL code + explanation A (very) short user manual for the application Documentation of testing 120

121 Milestones There are two stages: 1. Tasks 1-3, deadline March 11 Preliminary report describing design choices, E/R model, resulting relational model (will be commented on and handed back) 2. Tasks 4-5, deadline March 25 Final report as correction and extension of the preliminary report Grade for the project will be based both on the preliminary and on the final report 121

122 Implementation Java with fx JDBC as DB interface Python with fx psycopg2 as DB interface SQL and Java/Python code handed in electronically with report in Blackboard Database for testing must be available on the PostgreSQL server Testing during grading will use your program and the data on that server 122

### Entity-Relationship Model. E/R Diagrams Weak Entity Sets Converting E/R Diagrams to Relations

Entity-Relationship Model E/R Diagrams Weak Entity Sets Converting E/R Diagrams to Relations 1 Purpose of E/R Model The E/R model allows us to sketch database schema designs. Includes some constraints,

### Entity-Relationship Model. Purpose of E/R Model. Entity Sets

Entity-Relationship Model Diagrams Class hierarchies Weak entity sets 1 Purpose of E/R Model The E/R model allows us to sketch the design of a database informally. Designs are pictures called entityrelationship

### CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen

CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen LECTURE 2: E/R MODEL Purpose of E/R Model The E/R model allows us to sketch database designs. Kinds of data and how they

### Constraints in ER Models. Types of Constraints. Keys. CS 317, Fall 2007

Constraints in ER Models CS 317, Fall 2007 Types of Constraints Keys are attributes or sets of attributes that uniquely identify an entity within its entity set. Single-value constraints require that a

### Introduction to Database Systems. Normalization

Introduction to Database Systems Normalization Werner Nutt 1 Normalization 1. Anomalies 1. Anomalies 2. Boyce-Codd Normal Form 3. 3 rd Normal Form 2 Anomalies The goal of relational schema design is to

### Lecturer: Jan Baumbach Term: Summer 2016

Lecturer: Jan Baumbach Term: Summer 2016 Class: Database Design and Programming Exam project Introduction The purpose of this project is to try in practice the process of designing and creating a relational

What is a Database Management System? 1. Manages very large amounts of data. 2. Supports ecient access to very large amounts of data. 3. Supports concurrent access to v.l.a.d. 4. Supports secure, atomic

### ENTITY-RELATIONSHIP MODEL. CS 564- Fall 2016

ENTITY-RELATIONSHIP MODEL CS 564- Fall 2016 HOW TO BUILD A DB APPLICATION Pick an application Figure out what to model (ER model) Output: ER diagram Transform the ER diagram to a relational schema Refine

### Administrivia. CS 235: Introduction to Databases. Examples. What is a DBMS? Relational Database Marketplace. Relational Model

1 Administrivia CS 235: Introduction to Databases Svetlozar Nestorov Three handouts today: Course info, Schedule, Slides. Latest info will always be online! Come to class! Ask questions! Give feedback!

### 2. Supports ecient access to very large amounts. Example: bank and its ATM machines. from the same account via ATM machines

What is a Database Management System? 1. Manages very large amounts of data. 2. Supports ecient access to very large amounts of data. 3. Supports concurrent access to v.l.a.d. Example: bank and its ATM

### Chapter 4 High-level Database Models

Chapter 4 High-level Database Models Entity/Relationship Models (E/R diagram) Unified Modeling Language (UML) Object Definition Language (ODL) Hot to Transfer them to a relational model 1 Other High-Level

### CS411 Database Systems

Announcements CS411 Database Systems 03: The Relational Model Kazuhiro Minami Project stage 0 is due today Grade distribution of the course project Stage 1 (Decide your application): 5% Stage 2 (ER modeling)

### Design of Relational Database Schemas

Design of Relational Database Schemas T. M. Murali October 27, November 1, 2010 Plan Till Thanksgiving What are the typical problems or anomalies in relational designs? Introduce the idea of decomposing

### Database Design and Programming

Database Design and Programming Peter Schneider-Kamp DM 505, Spring 2012, 3 rd Quarter 1 Course Organisation Literature Database Systems: The Complete Book Evaluation Project and 1-day take-home exam,

### Other High-Level Design Languages. Unified Modeling Language Object Description Language

Other High-Level Design Languages Unified Modeling Language Object Description Language 1 Object-Oriented DBMS s Standards group: ODMG = Object Data Management Group. ODL = Object Description Language,

### BİL 354 Veritabanı Sistemleri. Entity-Relationship Model

BİL 354 Veritabanı Sistemleri Entity-Relationship Model Steps in building a DB application Pick application domain Conceptual design How can I describe that data? What data do I need for my application

### 1. Given the relation schema R = (A, B, C, D, E) and the canonical cover of its set of functional dependencies

Database Design Practice Questions Solution 1. Given the relation schema R = (A, B, C, D, E) and the canonical cover of its set of functional dependencies F c = { A BC CD E B D E A } Compute a lossless

### Announcements. Relational Database Design. Entity-relationship (E/R) model. Database (schema) design. ODL (Object Definition Language) E/R example

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

### Relational Database Design

Relational Database Design Jan Chomicki University at Buffalo Jan Chomicki () Relational database design 1 / 16 Outline 1 Functional dependencies 2 Normal forms 3 Multivalued dependencies Jan Chomicki

### Lecture Notes on Database Normalization

Lecture Notes on Database Normalization Chengkai Li Department of Computer Science and Engineering The University of Texas at Arlington April 15, 2012 I decided to write this document, because many students

### Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.

Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No. # 7 ER Model to Relational Mapping Hello and welcome to the next

### CS 4604: Introduc0on to Database Management Systems. B. Aditya Prakash Lecture #5: En-ty/Rela-onal Models- - - Part 1

CS 4604: Introduc0on to Database Management Systems B. Aditya Prakash Lecture #5: En-ty/Rela-onal Models- - - Part 1 Announcements- - - Project Goal: design a database system applica-on with a web front-

### Carnegie Mellon Univ. Dept. of Computer Science 15-415 - Database Applications. Overview - detailed. Goal. Faloutsos CMU SCS 15-415

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

### Database Systems Lecture #4 FD. Guifeng Zheng School of Software, SYSU

Database Systems Lecture #4 FD Guifeng Zheng School of Software, SYSU 1 Agenda Last time: relational model This time: 1. Functional dependencies Keys and superkeys in terms of FDs Finding keys for relations

### ER Cardinality Examples

The Entity-Relationship Model Part II The Entity-Relationship Model -- 1 ER Cardinality Examples The Entity-Relationship Model -- 2 1 Textbook Notation for (1,1) cardinalities (key constraints) Person

### Schema Design and Normal Forms Sid Name Level Rating Wage Hours

Entity-Relationship Diagram Schema Design and Sid Name Level Rating Wage Hours Database Management Systems, 2 nd Edition. R. Ramakrishnan and J. Gehrke 1 Database Management Systems, 2 nd Edition. R. Ramakrishnan

### E/R model. Why E/R model? Entity-Relationship (E/R) Model. Book Chapters:

E/R model Book Chapters: 2.1-2.8 Why E/R model? We need to figure out how to represent the data for a given application. Tables are not given Good tables are not easy to come up with E/R model: more graphical,

### Databases -Normalization III. (N Spadaccini 2010 and W Liu 2012) Databases - Normalization III 1 / 31

Databases -Normalization III (N Spadaccini 2010 and W Liu 2012) Databases - Normalization III 1 / 31 This lecture This lecture describes 3rd normal form. (N Spadaccini 2010 and W Liu 2012) Databases -

### SQL DDL. DBS Database Systems Designing Relational Databases. Inclusion Constraints. Key Constraints

DBS Database Systems Designing Relational Databases Peter Buneman 12 October 2010 SQL DDL In its simplest use, SQL s Data Definition Language (DDL) provides a name and a type for each column of a table.

### COSC-3421 Midterm Test w/ answers

Winter 2005 COSC-3421 Midterm Test w/ answers p. 1 of 16 COSC-3421 Midterm Test w/ answers Family Name: Given Name: Instructor: Parke Godfrey Exam Duration: 75 minutes Term: Winter 2005 Your assignment,

### Limitations of E-R Designs. Relational Normalization Theory. Redundancy and Other Problems. Redundancy. Anomalies. Example

Limitations of E-R Designs Relational Normalization Theory Chapter 6 Provides a set of guidelines, does not result in a unique database schema Does not provide a way of evaluating alternative schemas Normalization

### COMP 378 Database Systems Notes for Chapter 7 of Database System Concepts Database Design and the Entity-Relationship Model

COMP 378 Database Systems Notes for Chapter 7 of Database System Concepts Database Design and the Entity-Relationship Model The entity-relationship (E-R) model is a a data model in which information stored

### Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.

Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No. # 8 Functional Dependencies and Normal Forms Two different kinds

### Database Design and Normalization

Database Design and Normalization CPS352: Database Systems Simon Miner Gordon College Last Revised: 9/27/12 Agenda Check-in Functional Dependencies (continued) Design Project E-R Diagram Presentations

### CS143 Notes: Normalization Theory

CS143 Notes: Normalization Theory Book Chapters (4th) Chapters 7.1-6, 7.8, 7.10 (5th) Chapters 7.1-6, 7.8 (6th) Chapters 8.1-6, 8.8 INTRODUCTION Main question How do we design good tables for a relational

### CS 377 Database Systems. Database Design Theory and Normalization. Li Xiong Department of Mathematics and Computer Science Emory University

CS 377 Database Systems Database Design Theory and Normalization Li Xiong Department of Mathematics and Computer Science Emory University 1 Relational database design So far Conceptual database design

### Databases. Chapter 14. Objectives After studying this chapter, students should be able to: Definition 14-1 INTRODUCTION

Chapter 14 Databases 14.1 Source: Foundations of Computer Science Cengage Learning Objectives After studying this chapter, students should be able to: 14.2 Define a database and a database management system

### Chapter 10, Functional Dependencies and Normalization for Relational Databases

Chapter 10, Functional Dependencies and Normalization for Relational Databases We need some formal measure of why the choice of attributes for a relation schema may be better than another. Functional dependencies

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

### Comp 5311 Database Management Systems. 5. Functional Dependencies

Comp 5311 Database Management Systems 5. Functional Dependencies 1 Functional Dependencies (FD) - Definition Let R be a relation scheme and X, Y be sets of attributes in R. A functional dependency from

### Introduction. Database Management Systems

Introduction Database Management Systems Database Management System (DBMS) Collection of interrelated data and set of programs to access the data Convenient and efficient processing of data Database Application

### The Entity-Relationship Model. Steps in Database Design

The Entity-Relationship Model Steps in Database Design 1) Requirement Analysis Identify the data that needs to be stored data requirements Identify the operations that need to be executed on the data functional

### Concepts from

1 Concepts from 3.1-3.2 Func4onal dependencies Keys & superkeys of a rela4on Reasoning about FDs Closure of a set of aaributes Closure of a set of FDs Minimal basis for a set of FDs 2 Plan How can we use

Conceptual Modelling 1 Database Design Goal: specification of database schema Methodology: Use conceptual model (ER/UML) to get a high-level graphical view of essential components of enterprise and how

### Mapping ER Diagrams to Relations

CSC 742 Database Management Systems Topic #6: Database Design Spring 2002 CSC 742: DBMS by Dr. Peng Ning Mapping ER Diagrams to Relations Regular Entity Type Create a relation R Include simple attributes

### Copyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 10-1

Slide 10-1 Chapter 10 Functional Dependencies and Normalization for Relational Databases Chapter Outline 1 Informal Design Guidelines for Relational Databases 1.1Semantics of the Relation Attributes 1.2

### Schema Refinement, Functional Dependencies, Normalization

Schema Refinement, Functional Dependencies, Normalization MSCI 346: Database Systems Güneş Aluç, University of Waterloo Spring 2015 MSCI 346: Database Systems Chapter 19 1 / 42 Outline 1 Introduction Design

### COMP5138 Relational Database Management Systems. Today s Agenda

COMP5138 Relational Database Management Systems Lecture 2: Conceptual Database Design Today s Agenda Introduction Entity Relationship Model Case Study Unified Model Language 1 Database Design Sequence

### LiTH, Tekniska högskolan vid Linköpings universitet 1(7) IDA, Institutionen för datavetenskap Juha Takkinen 2007-05-24

LiTH, Tekniska högskolan vid Linköpings universitet 1(7) IDA, Institutionen för datavetenskap Juha Takkinen 2007-05-24 1. A database schema is a. the state of the db b. a description of the db using a

### Q4. What are data model? Explain the different data model with examples. Q8. Differentiate physical and logical data independence data models.

FAQs Introduction to Database Systems and Design Module 1: Introduction Data, Database, DBMS, DBA Q2. What is a catalogue? Explain the use of it in DBMS. Q3. Differentiate File System approach and Database

### SQL DDL. Applied Databases. Inclusion Constraints. Key Constraints

Applied Databases Handout 2. Database Design. 5 October 2010 SQL DDL In its simplest use, SQL s Data Definition Language (DDL) provides a name and a type for each column of a table. CREATE TABLE Hikers

### Database Design Overview. Conceptual Design ER Model. Entities and Entity Sets. Entity Set Representation. Keys

Database Design Overview Conceptual Design. The Entity-Relationship (ER) Model CS430/630 Lecture 12 Conceptual design The Entity-Relationship (ER) Model, UML High-level, close to human thinking Semantic

### CSCI-GA.2433-001 Database Systems Lecture 7: Schema Refinement and Normalization

CSCI-GA.2433-001 Database Systems Lecture 7: Schema Refinement and Normalization Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com View 1 View 2 View 3 Conceptual Schema At that point we

### The Entity Relationship Model and Database Design

The Entity Relationship Model and Database Design CPS352: Database Systems Simon Miner Gordon College Last Revised: 9/20/12 Agenda Check-in The Entity Relationship Model Group Exercise Database Design

### normalisation Goals: Suppose we have a db scheme: is it good? define precise notions of the qualities of a relational database scheme

Goals: Suppose we have a db scheme: is it good? Suppose we have a db scheme derived from an ER diagram: is it good? define precise notions of the qualities of a relational database scheme define algorithms

### 2. Entity-Relationship Model

2. Entity-Relationship Model Entity-relationship model describes data involves in real world in terms of object and their relationships. It is widely used for initial database design. It describes overall

### Schema Refinement and Normalization

Schema Refinement and Normalization Module 5, Lectures 3 and 4 Database Management Systems, R. Ramakrishnan 1 The Evils of Redundancy Redundancy is at the root of several problems associated with relational

### Relational Database Design: FD s & BCNF

CS145 Lecture Notes #5 Relational Database Design: FD s & BCNF Motivation Automatic translation from E/R or ODL may not produce the best relational design possible Sometimes database designers like to

### Why Is This Important? Schema Refinement and Normal Forms. The Evils of Redundancy. Functional Dependencies (FDs) Example (Contd.)

Why Is This Important? Schema Refinement and Normal Forms Chapter 19 Many ways to model a given scenario in a database How do we find the best one? We will discuss objective criteria for evaluating database

### Kathleen Durant CS3200 Lecture 2

Entity Relationship Model (ERM) Kathleen Durant CS3200 Lecture 2 1 What is the goal of Modeling? Derive a logical description of our data. Understand the various ways in which the data is used. Identify

### Database Design Theory: Introduction to Normalization Using Functional and Multivalued Dependencies

Database Design Theory: Introduction to Normalization Using Functional and Multivalued Dependencies Copyright 2012 Ramez Elmasri and Shamkant B. Navathe Chapter Outline 1 Informal Design Guidelines for

### Database Design and Normal Forms

Database Design and Normal Forms Database Design coming up with a good schema is very important How do we characterize the goodness of a schema? If two or more alternative schemas are available how do

### Overview of Transaction Management 221

Overview of Transaction Management 221 1. The following schedule results in a write-read conflict: T2:R(X), T2:R(Y), T2:W(X), T1:R(X)... T1:R(X) is a dirty read here. 2. The following schedule results

### Database Design and the ER model

Database Design and the ER model 1. Database design Database design: Description of the data environment An abstraction, driven by anticipated applications Database model: A formalism for specifying database

### Relational Database Design. Relational Database Design

Relational Database Design Based on slides from the text book: Database System Concepts, 5th Ed. Relational Database Design Features of Good Relational Design Atomic Domains and First Normal Form Decomposition

### The Relational Model. Why Study the Relational Model? Relational Database: Definitions. Chapter 3

The Relational Model Chapter 3 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Why Study the Relational Model? Most widely used model. Vendors: IBM, Informix, Microsoft, Oracle, Sybase,

### 14 Databases. Source: Foundations of Computer Science Cengage Learning. Objectives After studying this chapter, the student should be able to:

14 Databases 14.1 Source: Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: Define a database and a database management system (DBMS)

### 2. Conceptual Modeling using the Entity-Relationship Model

ECS-165A WQ 11 15 Contents 2. Conceptual Modeling using the Entity-Relationship Model Basic concepts: entities and entity types, attributes and keys, relationships and relationship types Entity-Relationship

### Database Constraints and Design

Database Constraints and Design We know that databases are often required to satisfy some integrity constraints. The most common ones are functional and inclusion dependencies. We ll study properties of

### The Entity-Relationship Model

The Entity-Relationship Model 221 After completing this chapter, you should be able to explain the three phases of database design, Why are multiple phases useful? evaluate the significance of the Entity-Relationship

### Relational Database Design

Relational Database Design To generate a set of relation schemas that allows - to store information without unnecessary redundancy - to retrieve desired information easily Approach - design schema in appropriate

### Designing relational schemas Anomalies caused by data redundancies Functional Dependencies Reasoning about FDs Normal Forms

Today s Lecture Designing relational schemas Anomalies caused by data redundancies Functional Dependencies Reasoning about FDs Normal Forms Winter 2003 1 R ecom m en ded R eadi n g s Chapter 19 All sections

### CPSC 304 Introduction to Database Systems

CPSC 304 Introduction to Database Systems Conceptual Database Design The Entity-Relationship Model Textbook Reference Database Management Systems: Chapter 2 Hassan Khosravi Borrowing many slides from Rachel

### Functional Dependency. Functional Dependence. Database Design

Karlstad University Department of Information Systems Adapted for a textbook by Date C. J. An Introduction to Database Systems Pearson Addison Wesley, 2004 Database Design Remigijus GUSTAS Phone: +46-54

### Chapter 10 Functional Dependencies and Normalization for Relational Databases

Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright 2004 Pearson Education, Inc. Chapter Outline 1 Informal Design Guidelines for Relational Databases 1.1Semantics of

### Announcements. SQL is hot! Facebook. Goal. Database Design Process. IT420: Database Management and Organization. Normalization (Chapter 3)

Announcements IT0: Database Management and Organization Normalization (Chapter 3) Department coin design contest deadline - February -week exam Monday, February 1 Lab SQL SQL Server: ALTER TABLE tname

### Microsoft MTA Database Administration Fundamentals

1 Microsoft - 98-364 MTA Database Administration Fundamentals QUESTION: 1 John works as a Database Administrator for Bluewell Inc. The company has a SQL Server database. A table in the database has a candidate

### Homework 3: Normalization, Indexing SOLUTION. AB C ; D B ; AC D. Answer each question below and carefully justify your answer.

CS 461, Database Systems, Spring 2015 Problem 1 (25pts): Normalization Homework 3: Normalization, Indexing SOLUTION Consider relation R (ABCD) together with the following set of FDs: AB C ; D B ; AC D.

### Theory behind Normalization & DB Design. Satisfiability: Does an FD hold? Lecture 12

Theory behind Normalization & DB Design Lecture 12 Satisfiability: Does an FD hold? Satisfiability of FDs Given: FD X Y and relation R Output: Does R satisfy X Y? Algorithm: a.sort R on X b.do all the

### Schema Refinement & Normalization Theory

Schema Refinement & Normalization Theory Functional Dependencies Week 11-1 1 What s the Problem Consider relation obtained (call it SNLRHW) Hourly_Emps(ssn, name, lot, rating, hrly_wage, hrs_worked) What

### Relational Modelling ER diagrams

Relational Modelling ER diagrams COMS4037 Databases Dmitry Shkatov Slides courtesy of Prof. Joe Hellerstein (UC Berkeley) R & G, Ch2, Ch3 Describing Data: Data Models Data model : collection of concepts

### Chapter 8. Database Design II: Relational Normalization Theory

Chapter 8 Database Design II: Relational Normalization Theory The E-R approach is a good way to start dealing with the complexity of modeling a real-world enterprise. However, it is only a set of guidelines

### Chapter 10. Functional Dependencies and Normalization for Relational Databases

Chapter 10 Functional Dependencies and Normalization for Relational Databases Chapter Outline 1 Informal Design Guidelines for Relational Databases 1.1Semantics of the Relation Attributes 1.2 Redundant

### Introduction to Databases, Fall 2005 IT University of Copenhagen. Lecture 5: Normalization II; Database design case studies. September 26, 2005

Introduction to Databases, Fall 2005 IT University of Copenhagen Lecture 5: Normalization II; Database design case studies September 26, 2005 Lecturer: Rasmus Pagh Today s lecture Normalization II: 3rd

### CPS221 Lecture: Relational Database Creation and Design last revised November 12, 2014

Objectives: CPS221 Lecture: Relational Database Creation and Design last revised November 12, 2014 1. To introduce the anomalies that result from redundant storage of data 2. To review the notion of primary

### Introduction to database design

Introduction to database design KBL chapter 4 (cursory reading: 4.6, and UML examples) Rasmus Pagh Some figures are borrowed from the ppt slides from the book used in the course, Database systems by Kiefer,

### Database Systems Redundancy, normalization

Database Systems Redundancy, normalization Bence Molnár Problems of relational DB schema Bad example! Invalid value (no candidate key) Name FirstName Age ID IdNr Gipsz Jakab Jakab 23 1 101 Hallgató Bálint

### The Relational Model. Chapter 3. Comp 521 Files and Databases Fall

The Relational Model Chapter 3 Comp 521 Files and Databases Fall 2016 1 Why Study the Relational Model? Most widely used model by industry. IBM, Informix, Microsoft, Oracle, Sybase, etc. It is simple,

### Database Management System

Database Management System Normalization (Unit - IV) NORMALIZATION While designing a database out of an entity relationship model, the main problem existing in that raw database is redundancy. Redundancy

### 6.830 Lecture 3 9.16.2015 PS1 Due Next Time (Tuesday!) Lab 1 Out today start early! Relational Model Continued, and Schema Design and Normalization

6.830 Lecture 3 9.16.2015 PS1 Due Next Time (Tuesday!) Lab 1 Out today start early! Relational Model Continued, and Schema Design and Normalization Animals(name,age,species,cageno,keptby,feedtime) Keeper(id,name)

### Chapter 5: Logical Database Design and the Relational Model Part 2: Normalization. Introduction to Normalization. Normal Forms.

Chapter 5: Logical Database Design and the Relational Model Part 2: Normalization Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden Robert C. Nickerson ISYS

### Theory of Relational Database Design and Normalization

Theory of Relational Database Design and Normalization (Based on Chapter 14 and some part of Chapter 15 in Fundamentals of Database Systems by Elmasri and Navathe) 1 Informal Design Guidelines for Relational

### Introduction Decomposition Simple Synthesis Bernstein Synthesis and Beyond. 6. Normalization. Stéphane Bressan. January 28, 2015

6. Normalization Stéphane Bressan January 28, 2015 1 / 42 This lecture is based on material by Professor Ling Tok Wang. CS 4221: Database Design The Relational Model Ling Tok Wang National University of

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

### Reducing ER Schema to Relational Schema

Reducing ER Schema to Relational Schema Excerpt from Chapter 3, Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Logical DB Design: ER to Relational Entity sets to tables: ssn name Employees

### Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.

Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No. # 1a Conceptual Design Hello in today session we would be looking

### Relational Data Model

CS4710 Introduction to Database Systems Relational Data Model Instructor: Yi-Shin Chen Office: EECS 3201 Email: yishin@cs.nthu.edu.tw Office Hour: Tu. 1-2PM, Th. 3-4pm Why Study the Relational Model? Most

### Week 11: Normal Forms. Logical Database Design. Normal Forms and Normalization. Examples of Redundancy

Week 11: Normal Forms Database Design Database Redundancies and Anomalies Functional Dependencies Entailment, Closure and Equivalence Lossless Decompositions The Third Normal Form (3NF) The Boyce-Codd