Presentation is loading. Please wait.

Presentation is loading. Please wait.

Announcements Reading for Friday Homework 2 - Due 9/24

Similar presentations


Presentation on theme: "Announcements Reading for Friday Homework 2 - Due 9/24"— Presentation transcript:

1 Announcements Reading for Friday Homework 2 - Due 9/24
4.1 – 4.5 Homework 2 - Due 9/24 Homework 3 – Due 10/1 Select paper topic and me your choice

2 The Entity-Relationship Model: Relationships, etc.
Lecture 6

3 Relationships Relationship type – Relationship set –
Relationship instances – Relationship can have descriptive attributes Represented by diamond on E-R diagram Connections or interactions between entity instances Represented by diamond on E-R diagram Relationship type – category of relationships Relationship set – collection of relationships of same type Relationship instances – relationships that exist at a given moment Relationship can have descriptive attributes

4 Degree of relationship
Binary – Ternary – N-ary – Binary – links two entity sets; set of ordered pairs Ternary – links three entity sets; ordered triples N-ary – links n entity sets; ordered n-tuples

5 Cardinality of Relationships
One-to-one: Number of entity instances to which another entity set can map under the relationship One-to-one: X:Y is 1:1 is each entity in X is associated with at most one entity in Y and each entity in Y with at most one entity in X.

6 Cardinality of Relationships
One-to-many: Many-to-many: One-to-many: X:Y is 1:M is each entity in X can be associated with many entities in Y, but each entity in Y with at most one entity in X. Many-to-many: X:Y is M:M if each entity in X can be associated with many entities in Y, and each entity in Y with many entities in X (many=more than one)

7 Relationship Participation Constraints
Total participation Partial participation Total participation Every member of entity set must participate in the relationship Represented by double line from entity rectangle to relationship diamond Partial participation Not every entity instance must participate Represented by single line from entity rectangle to relationship diamond

8 Roles Role: Optional to name role of each entity, but helpful in cases of Role: function that an entity plays in a relationship Optional to name role of each entity, but helpful in cases of Recursive relationship – entity set relates to itself Multiple relationships between same entity sets

9 Existence Dependency Existence dependency:
Existence dependency: Entity Y is existence dependent on entity X is each instance of Y must have a corresponding instance of X In that case, Y must have total participation in its relationship with X

10 Weak Entities If Y does not have its own candidate key, Y is called a weak entity, and X is strong entity Use double rectangle for weak entity, with double diamond for relationship connecting it to its associated strong entity Note: not all existence dependent entities are weak – the lack of a key is essential to definition If Y does not have its own candidate key, Y is called a weak entity, and X is strong entity Weak entity may have a partial key, called a discriminator, that distinguishes instances of the weak entity that are related to the same strong entity Use double rectangle for weak entity, with double diamond for relationship connecting it to its associated strong entity Note: not all existence dependent entities are weak – the lack of a key is essential to definition

11 Problems with ER modeling: Fan Trap
Occurs when a model represents a relationship between entity types, but the pathway between certain entity occurrences is ambiguous. Can occur when 2 or more 1:N relationships fan out from the same entity Division Operates Is Allocated Branch Staff Fix

12 Problems with ER modeling: Chasm Trap
Occurs when the model suggests the existence of a relationship between entity types, but the pathway does not exist between certain entity occurrences. Can occur when an entity with partial participation forms part of a pathway between entities that are related. Staff Oversees Is Allocated Property Branch Fix

13 Complete the E-R Diagram
A dentist’s office needs to keep information about patients, the number of visits they make to the office, work that must be preformed, procedures preformed during the visit, charges and payments for the treatment, and laboratory supplies and services. Assume there is only one dentist, so there is no need to store information about the dentist in the database. There are several hundred patients. Patients make many visits, and the database should store information about the services performed during each visit, and the charges for each of the services. there is a standard list of charges, kept outside of the database. The office uses three dental laboratories that provides supplies and services, such as fabricating dentures.

14 Visit Patient Charge Work Needed Procedure Payment Supplies Laboratory

15 Complete the E-R Diagram
An interior design firm would like to have a database to represent its operations. A client (customer) requests that the firm perform a job such as decorating a new home, redecorating rooms, locating and purchasing furniture, and so forth. One of the firm’s decorators is placed in charge of each job. For each job, the firm provides an estimate of the amount of time and money required for the entire job. Some of the work for a job, such as planning furniture placement, is done by the decorator in charge of the job. In addition, the firm might hire contractors to work on a daily or hourly basis on a particular job. A job might also include several activities, such as painting, installing floor covering, fabricating draperies, wallpapering, constructing, installing cabinets, and so on. These activities are done by contractors hired by the firm .The contractor provides an estimate for each activity. An activity or job might also require materials such as paint or lumber, and the firm has to keep track of the cost of materials for each activity or job, in order to bill the client. The database should store the estimated costs of all activities and all jobs.

16

17 Complete the E-R Diagram
An automobile body repair shop needs to keep information about its operations. Customers initially bring their cars to the shop for an estimate of the repairs. A mechanic looks at the car and estimates the cost and time required for the entire job. If the customer accepts the estimate, a job number is assigned and the customer’s name and contact information; the car’s license plate number, make, model, and year; and a list of repairs needed is recorded. The customer than makes an appointment to bring in the car on a specified date. When the car is brought in for repairs, the work begins. The shop keeps track of the charges for the parts and labor as they accumulate. Only one mechanic works on the car for the entire job. A job might include several repairs (e.g., replacing the left fender, painting the passenger door). The time actually spent for each repair is recorded and used to calculate the cost of labor, using a fixed hourly rate.

18


Download ppt "Announcements Reading for Friday Homework 2 - Due 9/24"

Similar presentations


Ads by Google