CSIS 115 Database Design and Applications for Business Dr. Meg Fryling “Dr. Meg” Fall 2012 @SienaDrMeg #csis115
Agenda Homework (see next slide) Recursive relationships Review data modeling Finish Hockey League data model Data constraints
Homework Chapter 3 (skip 127-130) Chapter 6 Project – Part II Posted on Blackboard Due Weds, 10/17 by start of class Notice: Next Quiz is Weds, 10/17 May bring a “cheat sheet” 8.5x11, handwritten, both sides, must use your own!
Reminder
Review of New Terms Strong Entities Weak Entities ID-Dependent Strong Entity Patterns 1:1, 1:N, and M:N
Review of New Terms ID-Dependent (Weak) Relationships The Association Pattern Often confused with M:N Really two 1:N relationships (2 parents; 1 child) The Multivalued Pattern Repeating attribute (e.g. phone, address, email) 1:N between strong (parent) and weak (child) entity The Archetype/Instance Pattern Weak entity is a manifestation of its parent (e.g. Class: Section)
Recursive Relationships A recursive relationship occurs when an entity has a relationship to itself. 1:1 1:N N:M KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall
Recursive Patterns: 1:1 Recursive Relationship This assumes there is one 1 engine – otherwise, we would need another recursive relationship for the ENGINE entity. The min card on the BOXCAR recursive relationship is optional because the existence of a boxcar ahead and/or a boxcar behind are optional (i.e. there is only 1 boxcar). In addition, the relationship between ENGINE and boxcar is optional in case we just have an ENGINE. We can also have a BOXCAR record with no related ENGINE. KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall
Recursive Patterns: 1:N Recursive Relationship A manager may manage more than one employee. The relationship is optional to optional because some employees (e.g. the president) have no manager and because some employees manage no one. KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall
Recursive Patterns: N:M Recursive Relationship KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall
Draw an ER Diagram To keep track of students To keep things simple, just keep track of the students’s name and admission term. Some students are mentors of other students All students must have a student mentor Mentors can mentor multiple students
Conceptual Database Design Data Modeling In-Class Activity Open Hockey League Activity Word doc from Blackboard Part 4 Only
Which of the following is considered to be a weak entity? A) ID-dependent entity B) multivalued entity C) association entity D) instance/archetype entity All of them are weak!
Strong Entity Patterns: N:M Strong Entity Relationships SalesPrice is what we retail the part for but what if different suppliers (companies) charged us different prices for the parts? Where do I store the information about the price each company is actually charging for the part? This new price is neither an attribute of COMPANY nor is it an attribute of PART! KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall
To represent an association pattern in an E-R model, ________. A) create a new ID-dependent entity with a 1:1 relationship to one other entity B) create a new weak, but not ID-dependent entity with a 1:1 relationship to one other entity C) create a new strong entity with a 1:1 relationship to one other entity D) create a new ID-dependent entity with a 1:N relationship to one of two parent entities E) create a new weak, but not ID-dependent entity with a 1:N relationship to one of two parent entities Answer: D) is really the best answer but this really could be accomplished with E) as well.
Strong Entity Patterns: N:M Strong Entity Relationships SalesPrice is what we retail the part for but what if different suppliers (companies) charged us different prices for the parts? Once we have an attribute that belongs to the relationship not just one of the participating entities, we need a weak entity to store this info. It is no longer a N:M strong entity relationship but an association relationship. This new price is neither an attribute of COMPANY nor is it an attribute of PART! KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall
ID-Dependent Relationships: The Association Pattern QUOTATION weak (both PART and COMPANY parent instances must exist first) Identifying relationships (identifiers from PART and COMPANY exist in QUOTATION identifier) COURSE (strong) and STUDENT (strong) ENROLLMENT (weak) with Grade attribute KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall
To represent a multivalued attribute in an E-R model, ________. A) create a new ID-dependent entity with a 1:N relationship B) create a new weak, but not ID-dependent entity with a 1:N relationship C) create a new strong entity with a 1:1 relationship D) create a new ID-dependent entity with a 1:1 relationship E) create a new weak, but not ID-dependent entity with a 1:1 relationship Answer: A) is really the best answer but this really could be accomplished with B) as well. Page Ref: 175-177
ID-Dependent Relationships: The Multivalued Attribute Pattern KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall
ID-Dependent Relationships: The Multivalued Attribute Pattern Can have multiple multivalued attributes. In this design, phone and contact are independent. Phone number is the phone number of the company and not necessarily a particular contact at that company. We need to change the design if we want the phone number to be associated with a specific company contact. KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall
ID-Dependent Relationships: Composite Multivalued Attributes We needed to change the design in order to associate each company phone number with a specific company contact. KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall
To represent an archetype/instance pattern in an E-R model, ________. A) create a new ID-dependent entity with a 1:N relationship B) create a new weak, but not ID-dependent entity with a 1:N relationship C) create a new strong entity with a 1:1 relationship D) create a new ID-dependent entity with a 1:1 relationship E) create a new weak, but not ID-dependent entity with a 1:1 relationship Page Ref: 175-177 Answer: A) is really the best answer but this really could be accomplished with B) as well.
The Archetype/Instance Pattern KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall
The Archetype/Instance Pattern Implemented with non-ID-dependent weak entities KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall
When an entity has a relationship to itself, we have a(n) ________. A) association relationship B) archetype/instance relationship C) recursive relationship D) multivalued relationship E) None of the above Answer: C
Recursive relationships can have which of the following maximum cardinalities? B) 1:N C) N:M D) A or B E) A, B or C Answer: E Page Ref: 183-185
Recursive Patterns The relationship is optional to optional because some employees (e.g. the president) have no manager and because some employees manage no one. KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall
Constraints Relationships impose data constraints An employee must have a manager A coach can only coach at most 1 team We have other ways to impose constraints too!
Constraints
Assignments > In-Class Activities > 4 – Data Constraints Let’s look at a hockey league database example and explore its constraints Blackboard Assignments > In-Class Activities > 4 – Data Constraints
Hockey League Relationships