Top Banner
Associative Entities A relationship cannot have attributes What happens when one or more attributes exist for a relationship? Employee – Project – Billing Rate
25

Associative Entities

Feb 08, 2016

Download

Documents

Lali

Associative Entities. A relationship cannot have attributes What happens when one or more attributes exist for a relationship? Employee – Project – Billing Rate. Associative Entities. - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Associative Entities

Associative Entities

A relationship cannot have attributesWhat happens when one or more

attributes exist for a relationship?Employee – Project – Billing Rate

Page 2: Associative Entities

Associative Entities

An associative entity is an entity type that associates the instances of more or more entity types and contains attributes that are specific to the relationship between those entity instances.

Page 3: Associative Entities

Converting a relationship to an associative entity

ExampleEmployee’s billing rate can vary by project

(employee to project, many-to-many)

Employee

ProjectBillingRate

Page 4: Associative Entities

Example:

Attribute of the relationship between property and owner is percent owned

Owner Property%Owned

Page 5: Associative Entities

Ternary Relationship

simultaneous relationship among one instance from each of exactly three entity setsAn associative entity is not required but is

typical.

Page 6: Associative Entities

Ternary Relationships – Cardinality

“one” – one instance of an entity is associated with each unique pair of the other two entities.

“many” – more than one instance of an entity is associated with each unique pair from each of the other two entities.

Page 7: Associative Entities

Example(one-to-one-to-one):

Employee is assigned a phone number for a project. A phone number is used only for that employee and project.

Page 8: Associative Entities

Example (one-to-one-to-one):

Employee

Project

PhoneNumber

Has

Note: An employee could still be assigned to multiple projects but would have a unique phone number for each project assignment.

Page 9: Associative Entities

Example(one-to-one-to-many):

Employee assigned to a project works at one location for that project but can work at different locations for different projects. At a location an employee only works on one project, but there can be many employees working on that same project.

Page 10: Associative Entities

Example(one-to-one-to-many):

Employee

Project

Location

Has

Page 11: Associative Entities

Example(one-to-many-to-many):

Employee on a project has one manager. Manager can manage several projects. Each project has one manager. Manager can manage the same employee on different projects.

Page 12: Associative Entities

Example(one-to-many-to-many):

Employee

Project

Manager

Has

Page 13: Associative Entities

Example(many-to-many-to-many):

Employees use many skills on many projects and each project has many employees with varying skills.

Page 14: Associative Entities

Example(many-to-many-to-many):

Employee

Project

Skill

Has

Page 15: Associative Entities

Ternary Relationships

Why not just make the ternary relationship an associative entity?

Employee

ProjectLocation

Page 16: Associative Entities

Good idea if possible. However,

“Business Rules”Need for separate (strong) entityWhat if location also related to other

entities?No longer valid as associative entity

If you can safely get rid of ternary (or n-ary) relationships, DO IT.However, don’t trade correctness for ease of implementation.

Page 17: Associative Entities

Example:

Employee assigned to a project works at one location and is only assigned to one project. However, projects can be at more than one location and have multiple employees working on them at each location. Multiple projects can be at the same location.

Draw the E-R Diagram.

Page 18: Associative Entities

Example:

Now, suppose employees have a billing rate that varies with both project and location.

Update your E-R Diagram.

Page 19: Associative Entities

Generalization/Specialization

Generalization: Defining a general entity type from a set of more specialized ones (bottom-up).

Specialization: Defining one or more specialized entities from a more general one based on distinguishing characteristics (top-down).

Page 20: Associative Entities

Examples:

Generalization: Bank account generalized from checking, savings, and loan.

Specialization: Property for sale divided into single family, duplex, apartment, commercial, or industrial.

Page 21: Associative Entities

Why use generalization or specialization?

clarity more fully describe situation conversion to OO (inheritance) different relationships only apply to specific subtypes

monthly charges only made to checking accounts

different relationships only apply to the supertype customer must have an account with the bank

different (additional) attributes for the subtypes

Page 22: Associative Entities

Generalization/Specialization

Applies to entities onlyTypes:

disjoint – can be only one subtypeoverlapping – can be more than one

subtype

Completeness Constraint – subtypes fully inclusive of supertype

Page 23: Associative Entities

Generalization/Specialization

Disjoint – student can be undergraduate, masters, or doctoral

Overlapping – major can be history, philosophy, or mathematics

Page 24: Associative Entities

Example

A company sells products whose price can change at most once a day. Need to be able to track the price history.

Page 25: Associative Entities

Multivalued Attribute

Product ID

Description

Effective Date

Price

Price History

Product Type

Product