Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
INSTRUCTOR NOTES
SECTION 3 Identifying Relationships Lesson Slide 1: Identifying Relationships Lesson Preparation The previous section introduced entities and attributes. Relationships are the third component of a data model (the R in ER modeling). This section starts by identifying relationships between entities. Then it examines the characteristics of and rules regarding relationships. What to Watch For Have students go over each of the relationships shown in the Try It / Solve It activities, and change the business rules (example: any WAITER can take any ORDER from any table). Then have them restate the relationship with the revised cardinality and/or optionality. Connections We could use a familiar example here because it has many possibilities: TEACHERS/COURSES/STUDENTS Teachers may teach courses (part-time teachers may have the term off). Are all courses taught by teachers? What about online courses? Students attend courses. Must students take a course to be considered a student? Can there be a course with no student? Slide 2: What Will I Learn? No instructor notes for this slide Slide 3: Why Learn It? Relationship: A connection or association between objects Other discussion points for why it is important to understand relationships: What is the relationship between student and library book? (What would you do if you received a fine for a book checked out by another student?) You would certainly protest because the student who checked out the book (this is the relationship) should also be responsible for any associated fines. This emphasizes the importance of clarifying relationships, especially in a business. Slide 4: Tell Me / Show Me What is the relationship between you and No instructor notes for this slide
Oracle Academy
Oracle Academy
Oracle Academy
Oracle Academy
Oracle Academy
Oracle Academy
Oracle Academy
Relationship Optionality
Try It / Solve It 1. Read the given business scenario. Name the relationships between EMPLOYEE and JOB. Include appropriate optionality and cardinality. We have a lot of employees who handle one or more different jobs. Wed like to keep track of who is working on which job. Although employees can help each other, a job is assigned to one employee and is the ultimate responsibility of that individual. All our employees have at least one job. However, there are jobs that are not yet assigned to anyone. Solution: Each EMPLOYEE must have (or handle, or be responsible for) one or more jobs. Each JOB may be the responsibility of (or assigned to) one and only one EMPLOYEE. 2. Read the given business scenario. Name the relationships between ORDER and WAITER, including the cardinality and optionality. We assign our waiters to certain areas, except for our trainees, who just observe and are not responsible for taking any orders yet. A waiter takes the orders for the tables in his/her area. All areas have one assigned waiter. A customer places an order with a waiter. If the customer has a question or wants to make a change to the order, he/she needs to request this with the assigned waiter.
Oracle Academy
Oracle Academy
Try It / Solve It 1. Read the given business scenario. Draw the entities HAIRSTYLIST and CLIENT. List the attributes associated with each entity and specify whether they are mandatory or optional. Identify the UIDs. Write out the relationship in English, including optionality and cardinality. Follow the diagramming conventions discussed. In our salon, we have a number of hairstylists. They are all salaried employees, so we keep a record of their first name, last name, address, phone number, socialsecurity number, and salary. During the course of a day, a hairstylist may see several clients. On a slow day, a hairstylist may not work on anyone at all. We have several walk-in clients, and they each get assigned to one hairstylist. We just ask for their first name. We also have customers who call to make an appointment. When they do this, we ask for their first name, last name, and phone number. We also ask if they would like a specific hairstylist. If they have no preference, we assign one for them. Of course, they are allowed to switch to another hairstylist for their next visit to the salon. We are interested in tracking the daily appointments which stylist works on which client during a given day. Solution: In some cases, there could be discussion about whether an attribute is mandatory or optional. Encourage this discussion and tell students that if it is not clear in the business scenario, they need to make assumptions. These assumptions should be documented so you can go back to the client later and confirm them. HAIRSTYLIST # id * first name * last name * address * phone number * social-security number
Oracle Academy
Oracle Academy
Oracle Academy
Try It / Solve It 1. The goal of this practice is to read a relationship. Which text corresponds to the diagram?
a. Each EMPLOYEE may be assigned to one or more DEPARTMENTs. Each DEPARTMENT must be responsible for one or more EMPLOYEEs. b. Each EMPLOYEE must be assigned to one and only one DEPARTMENT. Each DEPARTMENT must be responsible for one or more EMPLOYEEs. c. Each EMPLOYEE must be assigned to exactly one DEPARTMENT. Each DEPARTMENT may be responsible for exactly one EMPLOYEE. Solution: Option b. is the correct reading. 2. In the diagram for #1 identify the symbols for cardinality. Solution: Crows foot and single toe foot 3. In the diagram for #1 identify the symbols for optionality. Solution: Solid line (no dotted line exists)
Oracle Academy
Solution: Each camera may be used to take one or more photographs Each photograph must have been taken with one camera 5. Read each of the relationships in the model below. Write the ERD statement and your thoughts on each relationship. Use your knowledge of people and towns.
Oracle Academy
Oracle Academy
Try It / Solve It 1. Read the business scenario and review the ERD. Using the matrix diagram, make up two or more possible relationships between PHOTOGRAPH and the other entities that make sense for the business.
I am an amateur photographer. I own several cameras and am always taking pictures of different subjects. I am trying to keep track of which camera and type of film perform best under certain conditions indoor light, outdoor light, etc. So when I have my films developed, I note down which camera I used. When the pictures come back, I note the subject and conditions. Each picture always features one subject. A subject could be a view, a person or group of persons, or an object or group of objects. CAMERA CAMERA PHOTOGRAPH SUBJECT Oracle Academy 20 Database Design Copyright 2011, Oracle. All rights reserved. PHOTOGRAPH SUBJECT
Solution: The extra relationships could be Camera to Photograph A CAMERA may record one or more PHOTOGRAPHS A PHOTOGRAPH must be recorded by a CAMERA Photograph to Subject A SUBJECT may be captured in a PHOTOGRAPH A PHOTOGRAPH may capture a SUBJECT 2. Given the matrix diagram below, construct an ERD. *************** Cross Country Runner Cross Country ************** Runner City For Race Race Type City For Race Race Type
************ ***************
Solution: *************** Runner City For Race Race Type Running Event Run By ********* ********** Participates In The Location Of Used In Held In Of a *********
*********
Oracle Academy
Run by
Held in
RUNNING EVENT
of a Used in
RACE TYPE
Oracle Academy