49
Information Resources Information Resources Management Management February 6, 2001 February 6, 2001

Information Resources Management February 6, 2001

  • View
    214

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Information Resources Management February 6, 2001

Information Resources Information Resources ManagementManagement

February 6, 2001February 6, 2001

Page 2: Information Resources Management February 6, 2001

AgendaAgenda

AdministriviaAdministrivia Advanced E-R ModelingAdvanced E-R Modeling

Page 3: Information Resources Management February 6, 2001

AdministriviaAdministrivia

Homework #2Homework #2 Homework #3Homework #3

Page 4: Information Resources Management February 6, 2001

Difficulties with Previous E-R Difficulties with Previous E-R ModelingModeling employee’s billing rate may vary by employee’s billing rate may vary by

projectproject attribute of the relationship between attribute of the relationship between

property and owner is percent ownedproperty and owner is percent owned different types of bank accountsdifferent types of bank accounts customer must have at least one account customer must have at least one account

of any typeof any type tracking transactionstracking transactions

Page 5: Information Resources Management February 6, 2001

Also, Cannot Handle Also, Cannot Handle Situations LikeSituations Like different kinds of property for saledifferent kinds of property for sale

single family, duplex, apartment building, single family, duplex, apartment building, commercial, industrialcommercial, industrial

different kinds of projectsdifferent kinds of projects internal, DoD, joint venture, other govt, otherinternal, DoD, joint venture, other govt, other

employee assigned to a project has a specific employee assigned to a project has a specific location just for that projectlocation just for that project

billing rate for an employee can vary by both billing rate for an employee can vary by both project and locationproject and location

Page 6: Information Resources Management February 6, 2001

SolutionsSolutions

Associative EntitiesAssociative Entities Ternary (n-ary) relationshipsTernary (n-ary) relationships Generalization/SpecializationGeneralization/Specialization Time Dependent Data (weak entities)Time Dependent Data (weak entities)

Page 7: Information Resources Management February 6, 2001

Associative EntitiesAssociative Entities

A relationship cannot have attributesA relationship cannot have attributes What happens when one or more What happens when one or more

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

Page 8: Information Resources Management February 6, 2001

Associative EntitiesAssociative Entities

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

NOUNNOUN

Page 9: Information Resources Management February 6, 2001

Converting a relationship to an Converting a relationship to an associative entityassociative entity ExampleExample

Employee’s billing rate can vary by Employee’s billing rate can vary by project (employee to project, many-to-project (employee to project, many-to-many)many)

Employee

ProjectBillingRate

Page 10: Information Resources Management February 6, 2001

Example:Example:

Attribute of the relationship between Attribute of the relationship between property and owner is percent ownedproperty and owner is percent owned

Owner Property%Owned

Page 11: Information Resources Management February 6, 2001

Example:Example:

Students take one or more coursesStudents take one or more courses A course could be offered before any students register for A course could be offered before any students register for

itit Students are awarded mid-term and final grades for each Students are awarded mid-term and final grades for each

course for which they are registeredcourse for which they are registered Attributes for students include student ID, name, Attributes for students include student ID, name,

departmentdepartment Attributes for course include course number, name, Attributes for course include course number, name,

departmentdepartment

Draw the E-R diagramDraw the E-R diagram

Page 12: Information Resources Management February 6, 2001

Ternary RelationshipTernary Relationship

simultaneoussimultaneous relationship among one relationship among one instance from each of exactly three instance from each of exactly three entity setsentity sets An associative entity is not required An associative entity is not required

but is typical.but is typical.

Page 13: Information Resources Management February 6, 2001

Ternary Relationships – Ternary Relationships – CardinalityCardinality ““one” – one instance of an entity is one” – one instance of an entity is

associated with each unique pair of the associated with each unique pair of the other two entities.other two entities.

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

Page 14: Information Resources Management February 6, 2001

Ternary Relationships - Ternary Relationships - CardinalityCardinality For the entity in question,For the entity in question,

For one instance of the entity,For one instance of the entity, How many How many unique pairsunique pairs of the other of the other

entities can there be? entities can there be? One One More than one (many)More than one (many)

Page 15: Information Resources Management February 6, 2001

ExampleExample(one-to-one-to-one):(one-to-one-to-one):

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

Page 16: Information Resources Management February 6, 2001

Example (Example (one-to-one-to-one):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 17: Information Resources Management February 6, 2001

ExampleExample(one-to-one-to-many):(one-to-one-to-many):

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

Page 18: Information Resources Management February 6, 2001

ExampleExample(one-to-one-to-many):(one-to-one-to-many):

Employee

Project

Location

Has

Page 19: Information Resources Management February 6, 2001

ExampleExample(one-to-many-to-many):(one-to-many-to-many):

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

Page 20: Information Resources Management February 6, 2001

ExampleExample(one-to-many-to-many):(one-to-many-to-many):

Employee

Project

Manager

Has

Page 21: Information Resources Management February 6, 2001

ExampleExample(many-to-many-to-many):(many-to-many-to-many):

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

Page 22: Information Resources Management February 6, 2001

ExampleExample(many-to-many-to-many):(many-to-many-to-many):

Employee

Project

Skill

Has

Page 23: Information Resources Management February 6, 2001

Ternary RelationshipsTernary Relationships

Why not just make the ternary Why not just make the ternary relationship an associative entity?relationship an associative entity?

Employee

ProjectLocation

Page 24: Information Resources Management February 6, 2001

Good idea if possible. Good idea if possible. However,However, ““Business Rules”Business Rules” Need for separate (strong) entityNeed for separate (strong) entity What if location also related to other What if location also related to other

entities?entities? No longer valid as associative entityNo longer valid as associative entity

If you can safely get rid of ternary (or n-ary) relationships, If you can safely get rid of ternary (or n-ary) relationships, DO ITDO IT..

However, don’t trade correctness for ease of implementation.However, don’t trade correctness for ease of implementation.

Page 25: Information Resources Management February 6, 2001

Example:Example:

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

Draw the E-R Diagram.Draw the E-R Diagram.

Page 26: Information Resources Management February 6, 2001

Example:Example:

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

Update your E-R Diagram.Update your E-R Diagram.

Page 27: Information Resources Management February 6, 2001

Generalization/Generalization/SpecializationSpecialization

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

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

Page 28: Information Resources Management February 6, 2001

Examples:Examples:

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

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

Page 29: Information Resources Management February 6, 2001

Why use generalization or Why use generalization or specialization?specialization? clarityclarity more fully describe situationmore fully describe situation conversion to OO (inheritance)conversion to OO (inheritance) different relationships only apply to specific subtypesdifferent relationships only apply to specific subtypes

monthly charges only made to checking accountsmonthly charges only made to checking accounts

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

different (additional) attributes for the subtypesdifferent (additional) attributes for the subtypes

Page 30: Information Resources Management February 6, 2001

Generalization/Generalization/SpecializationSpecialization Applies to entities onlyApplies to entities only Types:Types:

disjoint – can be only one subtypedisjoint – can be only one subtype overlapping – can be more than one overlapping – can be more than one

subtypesubtype

Completeness Constraint – subtypes fully Completeness Constraint – subtypes fully inclusive of supertypeinclusive of supertype

Page 31: Information Resources Management February 6, 2001

Generalization/Generalization/SpecializationSpecialization Disjoint – student can be Disjoint – student can be

undergraduate, masters, or doctoralundergraduate, masters, or doctoral

Overlapping – major can be history, Overlapping – major can be history, philosophy, or mathematicsphilosophy, or mathematics

Page 32: Information Resources Management February 6, 2001

Completeness ConstraintCompleteness Constraint Disjoint:Disjoint:

Completeness – student must be one Completeness – student must be one and only one of the threeand only one of the three

None – “at large” student is simply a None – “at large” student is simply a student and the additional student and the additional specialization isn’t neededspecialization isn’t needed

Page 33: Information Resources Management February 6, 2001

Completeness ConstraintCompleteness Constraint Overlapping:Overlapping:

Completeness – major must be at Completeness – major must be at least one of the three listedleast one of the three listed

None - other majors not individually None - other majors not individually broken out but possiblebroken out but possible

Page 34: Information Resources Management February 6, 2001

Drawing It – DisjointDrawing It – Disjoint

- subset and direction indicator

d

Page 35: Information Resources Management February 6, 2001

Drawing It – OverlappingDrawing It – Overlapping

O

Page 36: Information Resources Management February 6, 2001

Drawing It – Completeness Drawing It – Completeness ConstraintConstraintDouble lineDouble line

d O

Page 37: Information Resources Management February 6, 2001

ExamplesExamples

d

Student

underg

masters

doctor

Page 38: Information Resources Management February 6, 2001

ExamplesExamples

O

Major

history philosp

math

Page 39: Information Resources Management February 6, 2001

Time Dependent DataTime Dependent Data

keep history over timekeep history over time need to track changing attribute and need to track changing attribute and

know its past valuesknow its past values

““timestamp”timestamp” year, month, day, etc…year, month, day, etc… as precise as nanosecondsas precise as nanoseconds

Page 40: Information Resources Management February 6, 2001

Two ApproachesTwo Approaches

multivalued attributemultivalued attribute additional entity (weak)additional entity (weak)

Page 41: Information Resources Management February 6, 2001

ExampleExample

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

Page 42: Information Resources Management February 6, 2001

Multivalued AttributeMultivalued Attribute

Product ID

Description

Effective Date

Price

Price History

Product Type

Product

Page 43: Information Resources Management February 6, 2001

Additional EntityAdditional Entity

Why is price history a weak entity??

Product Has PriceHistory

Page 44: Information Resources Management February 6, 2001

Warnings for Time Dependent Warnings for Time Dependent DataData Is it necessary?Is it necessary? How long must it be kept?How long must it be kept? Will it get “cleaned up”? How? When?Will it get “cleaned up”? How? When? Do other entities have relationships to the history Do other entities have relationships to the history

information?information? What happens to sales by product type What happens to sales by product type

if the product type is changed?if the product type is changed? Exactly how much historical information needs to Exactly how much historical information needs to

be kept? What attributes have historical values?be kept? What attributes have historical values?

Page 45: Information Resources Management February 6, 2001

The Steps in E-R ModelingThe Steps in E-R Modeling

classify entities and attributesclassify entities and attributes identify generalization hierarchiesidentify generalization hierarchies define relationshipsdefine relationships

All three simultaneous and iterativeAll three simultaneous and iterative

Page 46: Information Resources Management February 6, 2001

Exercise 1Exercise 1

A real estate firm lists property for sale. The following describes this A real estate firm lists property for sale. The following describes this organization:organization:

The firm has a number of sales offices in several statesThe firm has a number of sales offices in several states Each sales office is assigned one or more employees. An employee must be Each sales office is assigned one or more employees. An employee must be

assigned to only one sales office.assigned to only one sales office. For each sales office, there is always one employee assigned to manage that For each sales office, there is always one employee assigned to manage that

office. An employee may manage only the sales office to which she is office. An employee may manage only the sales office to which she is assigned.assigned.

The firm lists property for sale.The firm lists property for sale. Each unit or property must be listed with one (and only one) of the sales Each unit or property must be listed with one (and only one) of the sales

offices. A sales office may have any number of properties listed, or may offices. A sales office may have any number of properties listed, or may have no properties listed.have no properties listed.

Each unit of property has one or more owners. An owner may own more Each unit of property has one or more owners. An owner may own more than one unit of property. An attribute of the relationship between property than one unit of property. An attribute of the relationship between property and owner is percent owned.and owner is percent owned.

Page 47: Information Resources Management February 6, 2001

Exercise 1 - NewExercise 1 - New

Property listed must be at least one of the following types: single Property listed must be at least one of the following types: single family, apartment, commercial, industrial.family, apartment, commercial, industrial.

Single family property can be a house, duplex, condo, or townhouse. Single family property can be a house, duplex, condo, or townhouse. More than one is possible (ie, condo and townhouse)More than one is possible (ie, condo and townhouse)

A history of previous listings should be kept along with the sales prices A history of previous listings should be kept along with the sales prices and selling employees.and selling employees.

In a sales office, each employee has security access to one or more In a sales office, each employee has security access to one or more PCs. Managers have access to all PCs in their office as well as other PCs. Managers have access to all PCs in their office as well as other offices. Different employees can have different levels of access. This offices. Different employees can have different levels of access. This access needs to be tracked.access needs to be tracked.

Zoning information is kept for commercial and industrial properties Zoning information is kept for commercial and industrial properties only.only.

Gifts of varying values (based on the purchase price) are given to the Gifts of varying values (based on the purchase price) are given to the purchasers of single family houses or townhouses only.purchasers of single family houses or townhouses only.

Page 48: Information Resources Management February 6, 2001

Exercise 2Exercise 2

Construct an E-R diagram for a bank Construct an E-R diagram for a bank database that shows the basic relationships database that shows the basic relationships among customers, checking accounts, among customers, checking accounts, savings accounts, loans, loan officers, and savings accounts, loans, loan officers, and the bank branches where various accounts the bank branches where various accounts and loans are taken out. You also want to and loans are taken out. You also want to keep track of transactions on accounts and keep track of transactions on accounts and loans, and maintain the current balance in loans, and maintain the current balance in each account and the balance of the loan.each account and the balance of the loan.

Page 49: Information Resources Management February 6, 2001

Exercise 2 - NewExercise 2 - New

CDs (certificates of deposit) are also offered. A CD must be CDs (certificates of deposit) are also offered. A CD must be one of four types – small, medium, large, and jumbo. The one of four types – small, medium, large, and jumbo. The interest rate and minimum term vary with the type of CD and interest rate and minimum term vary with the type of CD and customer. “Special” customers (this is indicated in the customer customer. “Special” customers (this is indicated in the customer information) receive higher interest rates or shorter terms. information) receive higher interest rates or shorter terms. Customers who open a large or jumbo CD get to choose a free Customers who open a large or jumbo CD get to choose a free gift from a list of available ones. The gifts for each type of CD gift from a list of available ones. The gifts for each type of CD are different.are different.

A loan officer may work at more than one branch. When an A loan officer may work at more than one branch. When an officer is assigned to multiple branches, she has a unique officer is assigned to multiple branches, she has a unique phone number at each branch. All other bank employees each phone number at each branch. All other bank employees each have a unique phone number.have a unique phone number.