Docsity

CSIS 350 Lecture 15: Understanding E-R Model & ID-Dependent Entities, Study notes of Database Management Systems (DBMS)

Toggle sidebar
bg1
CSIS 350 โ€“ Lecture 15
Announcements
CCSC conference โ€“ student volunteers!
Midterm Grades
- In class: 95 points (weight 15%)
- HW: 98 points (weight 35%)
- Exam: 100 points (weight 50%)
Read: Chapter 5: 135 โ€“ 153
Review In-class Assignment from last lecture
Chapter 5
Last time we started looking at the E-R model.
Entity:
- Name
- Identifier
- Attributes
See slide 1
Relations
- Association between entities
- Maximum cardinality (largest number of entity instances that may participate)
o1:1
o1:N
oN:M
- Minimum cardinality (smallest number of entity instances that must participate)
oO-O
oM-M
oO-M
See slides 2 and 3
Last time we used a E-R diagram style where maximum cardinality was shown in the
diamond along the relationship line and minimum cardinality was shown using little
circles and hash marks next to the entities.
Discuss IE (crows-foot) notation:
- circle, hash mark, and crow's foot are used together at each end of the relationship
lines.
pf3
pf4
pf5

Partial preview of the text

Download CSIS 350 Lecture 15: Understanding E-R Model & ID-Dependent Entities and more Study notes Database Management Systems (DBMS) in PDF only on Docsity!

CSIS 350 โ€“ Lecture 15

Announcements CCSC conference โ€“ student volunteers! Midterm Grades

  • In class: 95 points (weight 15%)
  • HW: 98 points (weight 35%)
  • Exam: 100 points (weight 50%) Read: Chapter 5: 135 โ€“ 153 Review In-class Assignment from last lecture Chapter 5 Last time we started looking at the E-R model. Entity:
  • Name
  • Identifier
  • Attributes See slide 1 Relations
  • Association between entities
  • Maximum cardinality (largest number of entity instances that may participate) o 1: o 1:N o N:M
  • Minimum cardinality (smallest number of entity instances that must participate) o O-O o M-M o O-M See slides 2 and 3 Last time we used a E-R diagram style where maximum cardinality was shown in the diamond along the relationship line and minimum cardinality was shown using little circles and hash marks next to the entities. Discuss IE (crows-foot) notation:
  • circle, hash mark, and crow's foot are used together at each end of the relationship lines.
  • circle means 0
  • hash mark means 1
  • crow's foot means many
  • circle with hash mark means 0 or 1
  • hash mark with crow's foot means 1 or more
  • all three together: 0, 1, or more See slide 4, and discuss ID-dependent entities ID-dependent entities: An entity whose identifier includes the identifier of another entity. Weak and Strong entities:
  • Weak: an entity whose existence depends on the existence of another entity
  • Strong: an entity that is not weak
  • An ID-dependent entity is weak
  • A weak entity is not necessarily ID-dependent The line-style is also important;
  • solid shows an identifying relation (for ID-dependent entities)
  • dashed shows a non-identifying relation Sub- and Super-type entities
  • Subtype is a special case of another entity
  • Contains all the same attributes as the supertype, but has some extras
  • Discriminator in supertype determines which sub-type it is.
  • Example: Patient, with Male and Female Patient subtypes
  • Reason for creating subtypes: avoiding nulls See Slide 5 Another example:
  • Starships have a name, crewSize, and launchDate. They might be freighters (with a capacity), warships (with numPhotonTorpedoes and PhaserStrength), or passengerShips (with firstClassCapacity, secondClassCapacity). Draw picture using alternate notation. Entity Patterns E-R diagrams are used to define data models. A data model is a representation of how users view their world. But, you can't just ask a user "What's the maximum cardinality between the Starship and Planet entities?" You have to determine the information in other ways:
  • from user documents such as forms and reports
  • from discussions with users
  • from observation of users' behavior

This form shows a list of departments for the company Ajax Manufacturing. So we can determine that a company has many departments. But what about the other way? How many companies does a department have? We can't tell from the form, and we don't have any reports. So, we need to think about that โ€“ we can ask the users, or we can think about what these entities mean. Does it make sense for a department to belong to more than one company? Probably not. So, this is a 1:N relationship. What about minimum cardinality? Does a company have to have a department? Does a department have to have a company? We better ask the users! Slide 9 shows situation where Department must have a Company, but a Company does not have to have any Departments. Slides 10, 11 and 12: N:M Strong Entity Relationship The form shows information about a supplier and the parts it can supply. The report lists parts and the suppliers that can provide them. We can see from these two views that (1) suppliers supply many parts, and (2) parts are available from multiple suppliers. Now, what about minimum cardinality? Does supplier have to have at least one part? Does a part have to come from at least one company? Slide 12 shows case where supplier is treated as a company. Not all companies are suppliers, so the relationship is M-O. [Note mistake: relation between Company and Part is non-identifying, so line should be dashed] Note that in two of these cases, we had a report and a form. One of them allowed us to determine the max cardinality of the relation in one direction, and the second for the opposite direction. If we only have one form, we can only determine the max cardinality for one direction. ID-Dependent Entity Patterns The Association Pattern This pattern is similar to the N:M strong entity pattern we just looked at. Let's look at the report on Slide 13. How does this differ from the report on Slide 11? There is a new Price column. What entity is this associated with? It's not an attribute of Company, and it's not an attribute of Item either. It's really an attribute of the combination of the two. See Slide 14. Slide 15 - Note that the identifier of the Quotation entity is PartNumber and CompanyName โ€“ therefore, it is ID-dependent on both Part and Company.

Minimum cardinality: since these are identifying relationships, the minimum cardinality for the parent must be 1. The minimum cardinality in the other direction is determined by business requirements. In the drawing, A Part must have a quotation, but a company doesn't have to. Let's examine slides 12 and 15 again โ€“ the difference between them is that in one of them the relationship between Company and Part has an attribute:

  • Slide 12: No attribute ๏ƒ  N:M Strong Entity Pattern
  • Slide 15: Attribute ๏ƒ  ID-dependent Association Pattern So, the question to ask yourself: "Is there a missing attribute that pertains to the combination and not just one of the entities?" The Multivalued Attribute Pattern In the E-R model, attributes have a single value. But, in reality we know that some things are duplicated โ€“ a person can have multiple phone numbers, or a company can have multiple contacts. So, we need a data model that supports this. Let's look at the form on slide 16 โ€“ it shows a company with multiple phone numbers. How do we deal with this? We can't make phone number an attribute of Company, and we don't want to set up multiple attributes either (we've seen the problems this causes). We resolve this problem by creating an ID-dependent entity Phone, as seen in Slide 17. Note that it's identifier is both of its attributes, but it is ID-dependent because part of its identifier is the identifier of Company. This can be extended to multiple attributes, as shown in the next two slides (18 and 19). Note that in this case, the phone numbers and contacts are independent. The company has multiple phone numbers and multiple contacts, but they aren't related to each other. Look at slide 20 โ€“ this form suggests that a contact has a phone number. How would we design the data model in this case? Slide 21 shows the entity that represents this composite multivalued attribute. Because the Identifier includes Contact, this means that a Contact can have only 1 phone number. What if the Identifier was PhoneNumber and CompanyName? Then each phone number could occur only once, but a contact could have multiple phone numbers. When designing the entities, make sure you understand the business rules that you are trying to capture. In Class Exercise Project Questions 5.59 and 5.60 on page 163 - 164