QAch06

Share Embed Donate


Short Description

Download QAch06...

Description

CHAPTER 6: QUESTIONS AND ANSWERS 1. What does it mean to say that constructing an ERD is an iterative process? Ans: In constructing an ERD, you construct a preliminary data model and then refine it many times. 2. Why decompose a compound attribute into smaller attributes? Ans: Because a compound attribute contains multiple items of data, decomposing a compound attribute can facilitate a search of the embedded data. 3. When is it appropriate to transform an attribute into an entity type? Ans: When the database should contain more than just the identifier of an entity. 4. Why transform an entity type into two entity types and a relationship? Ans: To record a finer level of detail about an entity. 5. Why transform a weak entity to a strong entity? Ans: This transformation can be useful to make it easier to reference an entity type after conversion to a table design. After conversion, a reference to a weak entity will involve a combined foreign key with more than one column. This transformation is most useful for associative entity types especially associative entity types representing M-way relationships. 6. Why transform an entity type into a generalization hierarchy? Ans: If there are attributes and relationships that do not apply to all entities and there is an accepted classification of entities, transformation to a generalization hierarchy may be useful. 7. Why add history to an attribute or relationship? Ans: Historical details may be necessary for legal requirements as well as strategic reporting requirements. 8. What data model changes are involved in transforming an attribute to an entity type? Ans: This transformation involves the addition of an entity type and a 1-M relationship. 9. What data model changes are involved in splitting a compound attribute? Ans: This transformation involves replacing an attribute with a collection of attributes. 10. What data model changes are involved in expanding an entity type? Ans: This transformation involves adding an entity type and 1-M relationship. The new entity type may be weak or strong depending on the database requirements. 11. What data model changes are involved in transforming a weak entity to a strong entity?

Ans: This transformation involves changing a weak entity into a strong entity and changing the associated identifying relationships into non identifying relationships. It may be necessary to add a new primary key attribute to the new strong entity. 12. What data model changes are involved in adding history to an attribute or a relationship? Ans: When applied to an attribute, the transformation involves adding a new entity type and a relationship. The new entity type should contain a change date attribute. When applied to a relationship, the transformation involves changing the cardinality of the relationship from 1-M to M-N. The M-N relationship should contain a change date attribute. When applied to a M-N relationship, this transformation involves converting the M-N relationship into an associative entity type along with the addition of a change date attribute that becomes part of the primary key of the associative entity type. 13. What data model changes are involved in adding a generalization hierarchy? Ans: This transformation involves the addition of a supertype and a generalization relationship along with redistributing attributes and relationships to the subtypes of the generalization hierarchy. 14. What should you document about an ERD? Ans: You should include justification for design decisions involving multiple feasible choices and explanations of subtle design choices. You should also provide a description for each attribute especially where an attribute’s name does not indicate its purpose. As an ERD is developed, you should document incompleteness and inconsistency in the database requirements. 15. What should you omit in ERD documentation? Ans: You should not use documentation just to repeat the details contained in the ERD. 16. Why are design errors more difficult to detect and resolve than diagram errors? Ans: Design errors are more difficult to detect and resolve because they involve the meaning of the items on a diagram, not just a diagram’s appearance. 17. What is a misplaced relationship and how is it resolved? Ans: A misplaced relationship involves connection of the wrong entity types on an ERD. You can use entity type clusters to avoid misplaced relationships. 18. What is an incorrect cardinality and how is it resolved? Ans: An incorrect cardinality typically involves a M-N relationship recorded as a 1-M relationship. To avoid an incorrect cardinality, you should not make inferences beyond the requirements. 19. What is a missing relationship and how is it resolved? Ans: A missing relationship involves entity types that should be connected directly to support the requirements. To avoid a missing relationship, you should examine implications of the requirements.

20. What is overuse of a generalization hierarchy and how is it resolved? Ans: Generalization hierarchies are specialized modeling tools that should be used sparingly. You should not use a generalization hierarchy just because an entity can exist in multiple states. You should use a generalization hierarchy when an accepted classification exists and subtypes have specialized attributes and relationships. 21. What is a relationship cycle? Ans: A relationship cycle involves a collection of relationships arranged in a loop starting and ending with the same entity type. 22. What is a redundant relationship and how is it resolved? Ans: A redundant relationship can be derived from other relationships. You should examine relationship cycles to see if a relationship can be derived from other relationships. 23. How is an M-N relationship converted to the Relational Model? Ans: Each M-N relationship becomes a separate table. The primary key of the table is a combined key consisting of the primary keys of the entity types participating in the M-N relationship. 24. How is a 1-M relationship converted to the Relational Model? Ans: Each 1-M relationship becomes a foreign key in the table corresponding to the child entity type. If the minimum cardinality is one, the foreign key cannot accept null values. 25. What is the difference between the 1-M relationship rule and the optional 1-M relationship rule? Ans: Using the 1-M relationship rule results in null values when converting optional 1-M relationships. For the optional 1-M relationship rule, each 1-M relationship with a minimum cardinality of 0 and maximum cardinality of 1 becomes a new table. The primary key of the new table is the primary key of the entity type on the many side of the relationship. The primary key of the other entity type becomes a foreign key in the new table. However, usage of the optional 1-M relationship results in more tables. 26. How is a weak entity type converted to the Relational Model? Ans: Each identifying relationship adds a column to a primary key. The primary key of the table corresponding to the weak entity type consists of (i) the underlined local key (if any) in the weak entity type and (ii) the primary key(s) of the entity type(s) connected by the identifying relationship(s). 27. How is a generalization hierarchy converted to the Relational Model? Ans: Each entity type of a generalization hierarchy becomes a table. The columns of a table are the attributes of the corresponding entity type plus the primary key of the parent entity type. For each table representing a subtype, define a foreign key constraint that references the table corresponding to the parent entity type.

28. How is a 1-1 relationship converted to the Relational Model? Ans: A 1-1 relationship is converted into two foreign keys. If the relationship is optional with respect to one of the entity types, the corresponding foreign key may be dropped to eliminate null values. 29. List some symbol differences in ERD notation that you may experience in your career. Ans: Students' responses may vary. The Chen notation uses a diamond to represent the relationship, while the Crow’s foot notation has the name on the line. For minimum and maximum cardinality, the Chen notation presents 0, 1, and N in parentheses. Some notations reverse the position of the cardinalities. Some notations display names for both directions of a relationship. Other symbol variations are visual representations for certain kinds of entity types. In some notations, weak entities and M-N relationships have special representations. Weak entities are sometimes enclosed in double rectangles. Identifying relationships are sometimes enclosed in double diamonds. M-N relationships with attributes are sometimes shown as a rectangle with a diamond inside denoting the dual qualities (both relationship and entity type). 30. List some diagram rule differences in ERD notation that you may experience in your career. Ans: Students' responses may vary. Some notations do not support M-way relationships, M-N relationships, relationships with attributes, and self-referencing (unary) relationships. Some notations support relationships to be connected to other relationships and attributes to have more than one value (multi-valued attributes). 31. What is the Unified Modeling Language (UML)? Ans: The Unified Modeling Language is the standard notation for object-oriented modeling. The UML contains class diagrams, interface diagrams, and interaction diagrams to support object-oriented modeling. The class diagram notation provides an alternative to the ERD notations presented in this chapter. 32. What are the modeling elements in a UML class diagram? Ans: Class diagrams can contain classes (collections of objects), associations (binary relationships) among classes, and object features (attributes and operations). In addition, class diagrams can include generalization hierarchies and composition relationships. 33. What are the criteria for choosing a primary key? Ans: Ideally, primary keys should be stable and single purpose. Stable means that a primary key should never change after it has been assigned to an entity. Single purpose means that a primary key attribute should have no purpose other than entity identification. 34. What should you do if a proposed primary key does not meet the criteria? Ans: If the proposed primary key does not meet either criterion, you probably should reject it as a primary key. If the proposed primary key only meets one criterion, you

should explore other attributes for the primary key. Sometimes, industry or organizational practices may dictate the choice of a primary key even if the choice is not ideal.

II. PROBLEM SOLUTIONS The problems are divided between data modeling problems and conversion problems. Additional conversion problems are found in Chapter 7, where conversion is followed by normalization. Besides the problems presented here, the case study in Chapter 13 provides practice on a larger problem. Data Modeling Problems 1.

Define an ERD for the following narrative. The database should track homes and owners. A home has a unique home identifier, a street address, a city, a state, a zip, a number of bedrooms, a number of bathrooms, and square feet. A home is either owner occupied or rented. An owner has a social security number, a name, an optional spouse name, a profession, and an optional spouse profession. An owner can possess one or more homes. Each home has only one owner.

Ans: hom e h o m e id s tre e t c ity s ta te z ip n o b e d rm s n o b a th s s q ft o w n o c c u p ie d

2.

ow ner ow ns

ssn ow nnam e spousenam e p r o f e s s io n s p o u s e p ro fe s s

Refine the ERD from problem 1 by adding an agent entity type. Agents represent owners in the sale of a home. An agent can list many homes but only one agent can list a home. An agent has a unique agent identifier, a name, an office identifier, and a phone number. When an owner agrees to list a home with an agent, a commission (percentage of the sales price) and a selling price are determined.

Ans:

hom e h o m e id s tre e t c ity s ta te z ip n o b e d rm s n o b a th s s q ft o w n o c c u p ie d c o m m is s io n s a le s p ric e

ow ner ssn ow nnam e spousenam e p r o f e s s io n s p o u s e p ro fe s s

ow ns

l is t s

agent a a o p

3.

g e n tid g e n tn a m e ffic e id hone

In the ERD from problem 2, transform the attribute, office identifier, into an entity type. Data about an office include the phone number, the manager name, and the address.

Ans: hom e h o m e id s tre e t c ity s ta te z ip n o b e d rm s n o b a th s s q ft o w n o c c u p ie d c o m m is s i o n s a le s p r ic e

ow ner ow ns

ssn ow nnam e spousenam e p r o fe s s io n s p o u s e p r o fe s s

l is t s o ffic e agent a g e n tid a g e n tn a m e phone

w o rk s a t

o ffic e id a d d re s s m g rn a m e phone

4.

In the ERD from problem 3, add a buyer entity type. A buyer entity type has a social security number, a name, a phone, preferences for the number of bedrooms and bathrooms, and a price range. An agent can work with many buyers, but a buyer works with only one agent.

Ans: hom e h o m e id s tre e t c ity s ta te z ip n o b e d rm s n o b a th s s q ft o w n o c c u p ie d c o m m is s i o n s a le s p r ic e

ow ner ow ns

ssn ow nnam e spousenam e p r o fe s s io n s p o u s e p r o fe s s

buyer ssn b u y e rn a m e a d d re s s b d rm s b th rm s m in p r i c e m a x p r ic e

w o r k s w ith

l is t s o ffic e agent a g e n tid a g e n tn a m e phone

5.

w o rk s a t

o ffic e id a d d re s s m g rn a m e phone

Refine the ERD from problem 4 with a generalization hierarchy to depict similarities between buyers and owners.

Ans: perso n ssn nam e phone

D ,C

hom e h o m e id s tre e t c ity s ta te z ip n o b e d rm s n o b a th s s q ft o w n o c c u p ie d c o m m is s i o n s a le s p r ic e

ow ner ow ns

ssn spousenam e p r o fe s s io n s p o u s e p r o fe s s

buyer ssn a d d re s s m in p r ic e b d rm s b th rm s m a x p r ic e

w o r k s w ith

l is t s o ffic e agent a g e n tid a g e n tn a m e phone

6.

w o rk s a t

o f fic e id a d d re s s m g rn a m e phone

Revise the ERD from problem 5 by adding an offer entity type. A buyer makes an offer on a home for a specified sales price. The offer starts on the submission date and time and expires on the specified date and time. A unique offer number identifies an offer. A buyer may submit multiple offers for the same home.

Ans: o ffe r

m a d e fo r

O ffe r N o e x p d a te p r ic e c o u n te r o ffe r S u b m itD a te

p e rs o n ssn nam e phone

hom e

D ,C

h o m e id s tre e t c ity s ta te z ip n o b e d rm s n o b a th s s q ft o w n o c c u p ie d c o m m is s io n s a le s p r ic e

m akes ow ner ow ns

ssn spousenam e p r o fe s s io n s p o u s e p ro fe s s

buyer ssn a d d re s s m in p r ic e b d rm s b th rm s m a x p r ic e

w o r k s w ith

lis ts o ffic e agent a g e n t id a g e n tn a m e phone

7.

w o rk s a t

o ffic e id a d d re s s m g rn a m e phone

Construct an ERD to represent accounts in a database for personal financial software. The software supports checking accounts, credit cards, and two kinds of investments (mutual funds and stocks). No other kinds of accounts are supported and every account must fall into one of these account types. For each kind of account, the software provides a separate data entry screen. The following list describes the fields on the data entry screens for each kind of account.  For all accounts, the software requires the unique account identifier, the account name, date established, and the balance.  For checking accounts, the software supports attributes for the bank name, the bank the address, the checking account number, and the routing number.  For credit cards, the software supports attributes for the credit card number, the expiration date, and the credit card limit.  For stocks, the software supports attributes for the stock symbol, the stock type (common or preferred), the last dividend amount, the last dividend date, the exchange, the last closing price, and the number of shares (a whole number).  For mutual funds, the software supports attributes for the mutual fund symbol, the share balance (a real number), the fund type (stock, bond, or mixed), the last closing price, the region (domestic, international, or global), and the tax exempt status (yes or no).

Ans: The following solution uses a two level generalization hierarchy. The investment entity type was added because mutual funds and stocks share two attributes. The share balance is not shared because the balance for stocks is a whole number (no partial shares) but a real number of mutual funds (fractional shares). The set constraints (disjoint and complete) are used because the financial software does not permit other kinds of accounts to be defined. These constraints may not hold in other financial software databases. Account AcctID AcctName Balance DateEst

D,C Investment Symbol LastClosePrice

Checking CheckAcctNo BankName RouteNo

CreditCard CardNo ExpDate Limit

D,C Stock Shares Exchange LastDivAmt LastDivDate

MutualFund TaxExempt Region FundType ShareBalance

8.

Construct an ERD to represent categories in a database for personal financial software. A category has a unique category identifier, a name, a type (expense, asset, liability, or revenue), and a balance. Categories are organized hierarchically so that a category can have a parent category and one or more subcategories. For example, the category ‘household’ can have subcategories for ‘cleaning’ and ‘maintenance.’ A category can have any number of levels of subcategories. Make an instance diagram to depict the relationships among categories.

9.

Design an ERD for a parts and relationships among parts. A part has a unique part identifier, a name, and a color. A part can have multiple subparts and multiple parts that use it. The quantity of each subpart should be recorded. Make an instance diagram to depict relationships among parts.

Ans: 8 and 9 respectively. 8) category hierarchy

9) part hierarchy Qty

Category

decomposed

CatID CatName Balance CatType

part

contains

partno partdesc partcolor

8 ) d e c o m p o s e d in s t a n c e d ia g r a m

9 ) c o n t a in s in s t a n c e d ia g r a m

C 1

P 1 P 2

C 2

C 3

P 3 C 4

P 4

C 5 P 5

10. Design an ERD to represent a credit card statement. The statement has two parts: a heading containing the unique statement number, the account number of the credit card holder, and the statement date; and a detail section containing a list of zero or more transactions for which the balance is due. Each detail line contains a line number, a transaction date, a merchant name, and the amount of the transaction. The line number is unique within a statement. Ans: s tm tlin e s ta te m e n t s tm tn o d a te a c c tn o

c o n t a in s

li n e n o tr a n s d a te m e rc h n a m e am t

11. Modify your ERD form problem 10. Everything is the same except that each detail line contains a unique transaction number in place of the line number. Transaction numbers are unique across statements. Ans:

s tm tlin e s ta te m e n t s tm tn o d a te a c c tn o

tr a n s n o tr a n s d a t e m e rc h n a m e am t

c o n ta in s

12. Using the ERD in Figure 6.P1, transform the ProvNo attribute into an entity type (Provider) and a 1-M relationship (Treats). A provider has a unique provider number, a first name, a last name, a phone, a specialty, a hospital name in which the provide practices, an email address, a certification, a pay grade, and a title. A provider is required for a visit. New providers do not have associated visits. Patient PatNo PatFirstName PatLastName PatCity PatState PatZip PatHealthPlan

Visit Treats

VisitNo VisitDate VisitPayMethod VisitCharge ProvNo

Figure 6.P1: ERD for Problem 12 Ans: Provider ProvNo ProvFirstName ProvLastName ProvPhone ProvEMail ProvSpecialty ProvHospital ProvCertification ProvPayGrade ProvTitle

Treats Patient PatNo PatFirstName PatLastName PatCity PatState PatZip PatHealthPlan

Visit Attends

VisitNo VisitDate VisitPayMethod VisitCharge

13. In the result of problem 12, expand the Visit entity type to record details about a visit. A visit detail includes a detail number, a detail charge, an optional provider number, an item number. The combination of the visit number and visit detail number is unique for a visit detail. An item includes a unique item number, an item description, an item price, and an item type. An item can be related to multiple visits. New items may not be related to any visit details. A provider can be related to multiple visit details. Some provides may not be associated to any visit details. Ans: Provider ProvNo ProvFirstName ProvLastName ProvPhone ProvSpecialty ProvEMail ProvSpecialty ProvHospital ProvCertification ProvTitle ProvPayGrade

Provides

Treats Patient PatNo PatFirstName PatLastName PatCity PatState PatZip PatHealthPlan

Visit Attends

VisitNo VisitDate VisitPayMethod VisitCharge

VisitDetail Contains

VisitDetailNo DetailCharge

UsedIn

Item ItemNo ItemDesc ItemType ItemPrice

14. In the result of problem 13, add a generalization hierarchy to distinguish between nurse and physician providers. A nurse has a pay grade and a title. A physician has a residence hospital, email address, and a certification. The other attributes of provider apply to both physicians and nurses. A visit involves a physician provider while a visit detail may involve a nurse provider.

Ans: Provider ProvNo ProvFirstName ProvLastName ProvPhone ProvSpecialty

D,C

Physician

Nurse

PhyEMail PhyHospital PhyCertification

NursePayGrade NurseTitle

Treats

Provides

Patient PatNo PatFirstName PatLastName PatCity PatState PatZip PatHealthPlan

Visit Attends

VisitNo VisitDate VisitPayMethod VisitCharge

VisitDetail Contains

VisitDetailNo DetailCharge

UsedIn

Item ItemNo ItemDesc ItemType ItemPrice

15. In the result of problem 14, transform VisitDetail into a strong entity with VisitDetailNo as the primary key.

Ans: Provider ProvNo ProvFirstName ProvLastName ProvPhone ProvSpecialty

D,C

Physician

Nurse

PhyEMail PhyHospital PhyCertification

NursePayGrade NurseTitle

Treats

Provides

Patient PatNo PatFirstName PatLastName PatCity PatState PatZip PatHealthPlan

Visit Attends

VisitNo VisitDate VisitPayMethod VisitCharge

VisitDetail Contains

VisitDetailNo DetailCharge

UsedIn

Item ItemNo ItemDesc ItemType ItemPrice

16. In the result of problem 15, add a history of item prices. Your solution should support the current price along with the two most recent prices. Include change dates for each item price.

Ans: Provider ProvNo ProvFirstName ProvLastName ProvPhone ProvSpecialty

D,C

Physician

Nurse

PhyEMail PhyHospital PhyCertification

NursePayGrade NurseTitle

Treats

Provides

Patient PatNo PatFirstName PatLastName PatCity PatState PatZip PatHealthPlan

Visit Attends

VisitNo VisitDate VisitPayMethod VisitCharge

VisitDetail Contains

VisitDetailNo DetailCharge

UsedIn

Item ItemNo ItemDesc ItemType ItemCurrPrice ItemCurrPriceDate ItemPrev1Price ItemPrev1PriceDate ItemPrev2Price ItemPrev2PriceDate

17. In the result of problem 15, add a history of item prices. Your solution should support an unlimited number of prices and change dates.

Ans: Provider ProvNo ProvFirstName ProvLastName ProvPhone ProvSpecialty

D,C

Physician

Nurse

PhyEMail PhyHospital PhyCertification

NursePayGrade NurseTitle

Treats

Provides

Patient PatNo PatFirstName PatLastName PatCity PatState PatZip PatHealthPlan

Visit Attends

VisitNo VisitDate VisitPayMethod VisitCharge

VisitDetail Contains

VisitDetailNo DetailCharge

UsedIn

ItemPriceHistory ItemChangeDate ItemPrice

Item PriceHist

ItemNo ItemDesc ItemType

18. Design an ERD with entity types for projects, specialties, and contractors. Add relationships and/or entity types as indicated in the following description. Each contractor has exactly one specialty, but many contractors can provide the same specialty. A contractor can provide the same specialty on multiple projects. A project can use many specialties, and a specialty can be used on many projects. Each combination of project and specialty should have at least two contractors.

Ans: p r o j e c t

p r o j e c t n h

a

e e d s

s

f u

p

r o

v i d

e

d

b

s p

e c i a l t y

l f i l l s

y

2 c o n t r a c t o r

s u

p

p

l i e

s

This solution enforces the constraint that a contractor can have only 1 specialty (supplies relationship). In the providedby relationship, a contractor can be related to many combinations of project-specialty combinations. There is no constraint ensuring that the specialty is the same in all related project-specialty combinations. This solution also enforces the constraint that that a combination of project and specialty is related to a minimum of two contractors. The number 2 by the min cardinality means that a contractor must be related to at least two projectneeds entities. ERD tools (such as Visio Professional) may not support this cardinality specification. p ro je c t

s p e c ia lty needs

c o n tr a c to r uses

s u p p li e s

This solution enforces the constraint that a contractor can have only 1 specialty (supplies relationship). This solution does not enforce the constraint that that a combination of project and specialty is related to a minimum of 2 contractors. 19. For the following problem, define an ERD for the initial requirements and then revise the ERD for the new requirements. Your solution should have an initial ERD, a revised ERD, and a list of design decisions for each ERD. In performing the problem, you may want to follow the approach presented in Section 6.1. The database supports the placement office of a leading graduate school of business. The primary purpose of the database is to schedule interviews and facilitate searches by students and companies. Consider the following requirements in your initial ERD:

• Student data include a unique student identifier, a name, a phone number, an email address, a web address, a major, a minor, and a GPA. • The placement office maintains a standard list of positions based on the Labor Department’s list of occupations. Position data include a unique position identifier and a position description. • Company data include a unique company identifier, a company name, and a list of positions and interviewers. Each company must map its positions into the position list maintained by the placement office. For each available position, the company lists the cities in which positions are available. • Interviewer data include a unique interviewer identifier, a name, a phone, an email address, and a web address. Each interviewer works for one company. • An interview includes a unique interview identifier, a date, a time, a location (building and room), an interviewer, and a student. After reviewing your initial design, the placement office decides to revise the requirements. Make a separate ERD to show your refinements. Refine your original ERD to support the following new requirements: • Allow companies to use their own language to describe positions. The placement office will not maintain a list of standard positions. • Allow companies to reserve blocks of interview time. The interview blocks will not specify times for individual interviews. Rather a company will request a block of X hours during a specified week. Companies reserve interview blocks before the placement office schedules individual interviews. Thus the placement office needs to store interviews as well as interview blocks. • Allow students to submit bids for interview blocks. Students receive a set amount of bid dollars that they can allocate among bids. The bid mechanism is a pseudo market approach to allocating interviews, a scarce resource. A bid contains a unique bid identifier, a bid amount, and a company. A student can submit many bids and an interview block can receive many bids. Ans:

p o s i t i o n

s t u d e n t s n p e w m m g a a

t d i d a m e h o n e m a i l e b a j o r i n o r p a d v i s e d v i s e

p n

i n t e r v i e w a

1

r n r n

o a

t t e

m

e

n

i d d t b r r

n t e r v i e w i d s a t e i m e l d g n a m e o o m n o o o m t y p e

o a

s i d m e

a

v a

i l a

c o m

b

l e

p p o s

c i t y s t a t e c o

n

d

u

c t s o

i n t e r v i e w i n t e r v i e n a m e p h o n e e m a i l

w

e

f f e

r s

e r c o m

r i d w

o

r k s f o

cr o c o

m m

p a n y p p

i d n a

1. An interview may be initially setup without knowing the student or interviewer. Transformations: see ERD below • Remove the position entity type so that positions are not standardized across companies. Add attributes to the comppos entity type for the position name and number of openings (optional attribute not explicitly derived from the problem statement). To reduce the number of attributes in the combined primary key of comppos, a unique identifier could be added. In this case, the compid, city, and state attributes would no longer be part of the primary key. • Add an entity type (interviewblock) and relationships between interviewblock and interview and between interviewblock and company. The new entity type and relationships allow companies to schedule blocks of time. An interview block will contain a collection of interviews with the same company. • Add an entity type for bids. The bid entity type should be connected to student and interviewblock.

m

e

b id b id n o b id a m t b id p r io r it y

s u b m its

s tu d e n t s t d id nam e phone e m a il web m a jo r m in o r gpa a d v is e r n o a d v is e r n a m e

in t e r v ie w a tte n d s

in t e r v ie w id d a te t im e b ld g n a m e ro o m n o ro o m ty p e

m a d e fo r

p a rto f

in t e r v ie w b lo c k

com ppos

in t b lo c k n o b lo c k s t a r t t im e b lo c k e n d t im e d u r a tio n

c it y s ta te posnam e N u m O p e n in g s

c o n d u c ts o ffe rs

in t e r v ie w e r in t e r v ie w e r id nam e phone e m a il

re q u e s ts w o rk s fo r

com pany c o m p id com pnam e

20. For the following problem, define an ERD for the initial requirements and then revise the ERD for the new requirements. Your solution should have an initial ERD, a revised ERD, and a list of design decisions for each ERD. In performing the problem, you may want to follow the approach presented in Section 6.1. Design a database for managing the task assignments on a work order. A work order records the set of tasks requested by a customer at a specified location. • A customer has a unique customer identifier, a name, and a billing address (street, city, state, zip). • A work order has a unique work order number, creation date, date required, a completion date, an optional supervising employee, a work address (street, city, state, zip), and a set of tasks. • Each task has a unique task identifier, a task name, an hourly rate, and estimated hours. Tasks are standardized across work orders so that the same task may be performed on many work orders. • Each task on a work order has a status (not started, in progress, or completed), actual hours, and a completion date. The completion date is not entered until the status changes to complete. After reviewing your initial design, the company decides to revise the requirements. Make a separate ERD to show your refinements. Refine your original ERD to support the following new requirements: • The company wants to maintain a list of materials. The data about materials include a unique material identifier, a name, and an estimated cost.

• Each work order also has a collection of material requirements. A material requirement includes a material, an estimated quantity of the material, and the actual quantity of the material used. • The estimated number of hours for a task depends on the work order and task, not on the task alone. Each task of a work order includes an estimated number of hours. Ans: c u s t o m C u C u A d C i t S t a Z i p e m w e

e r

s t o m e s t o m e d r e s s y t e a

r r

N N

o a

m

t a s k

e

t a s k n o t a s k n a e s t h r s r a t e

m

e

i l

b

r e r e

q

u

e

q

u

i r e

s

s t s

w

o r k o r d e r

W C R A

o r k O r d e r r e a t e D a t ei n e q D a t e d d r e s s

N

o

c lu

1 d

w

o r k d e t a i l

s t a

t u

s

e as c t h r s c o

m

p

l e

t e

d

a

t e

1. A workorder cannot be created unless at least 1 task is known. Transformations: • Workdetail could be a M-N relationship. • Add an entity type for material. Connect material to work order in an associative entity type or a M-N relationship. • Move esthrs from task to workdetail.

c u s to m e r ta s k

C u s to m e r N o C u s to m e r N a m e A d d re s s C it y S ta te Z ip e m a il w eb

ta s k n o ta s k n a m e ra te

re q u e s ts w o rk o rd e r

m a te ria l m a tn o m a tn a m e

W o rk O rd e r N o C re a te D a te R e q D a te A d d re s s

M a tU s e d e s tq ty

ta s k u s e d s ta tu s e s th rs

c o m p d a te a c th rs

a c tq ty

21. For the following problem, define an ERD for the initial requirements and then revise the ERD for the new requirements. Your solution should have an initial ERD, a revised ERD, and a list of design decisions for each ERD. In performing the problem, you may want to follow the approach presented in Section 6.1. Design a database to assist physical plant personnel in managing assignments of keys to employees. The primary purpose of the database is to ensure proper accounting for all keys. • An employee has a unique employee number, a name, a position, and an optional office number. • A building has a unique building number, a name, and a location within the campus. • A room has a room number, a size (physical dimensions), a capacity, a number of entrances, and a description of equipment in the room. Because each room is located in exactly one building, the identification of a room depends on the identification of a building. • Key types (also known as master keys) are designed to open one or more rooms. A room may have one or more key types that open it. A key type has a unique key type number, a date designed, and the employee authorizing the key type. A key type must be authorized before it is created. • A copy of a key type is known as a key. Keys are assigned to employees. Each key is assigned to exactly one employee, but an employee can hold multiple keys. The key type number plus a copy number uniquely identify a key. The date the copy was made should be recorded in the database. After reviewing your initial design, the physical plant supervisor decides to revise the requirements. Make a separate ERD to show your refinements. Refine your original ERD to support the following new requirements:

• The physical plant needs to know not only the current holder of a key but the past holders of a key. For past key holders, the date range that a key was held should be recorded. • The physical plant needs to know the current status of each key: in use by an employee, in storage, or reported lost. If lost, the date reported lost should be stored. Ans: b u ild in g

key

b ld g n o b ld g n a m e lo c a t io n

copyno d a te m a d e

is s u e d t o

1 e m p lo y e e

c o n t a in s

copyof

em pno em pnam e p o s i t io n O ffic e N o

2

ro o m ro o m n o s iz e n u m d o o rs e q u ip m e n t

1. 2.

k e y ty p e

opens

a u th o r iz e s

k e y ty p e n o d a te a s s ig n e d p u rp o s e

The minimum cardinality of 0 is necessary because there may be times when a key is not assigned to an employee, for example, between the time that one employee leaves an office and a new employee is assigned. The OfficeNo attribute could be replaced by a 1-M relationship to the room entity type. The problem specification does not indicate whether office number should be connected to the room entity type.

Transformations: • The issuedto relationship should be changed into an entity type and two 1-M relationships. The new entity type is identification dependent on key and employee. The dates assigned (beginning and ending) should be recorded in the new entity type. • Add additional attributes to either the key entity type or the new entity type. If the attributes are added to the key entity type, only the current status can be recorded. If added to the new entity type, past status can be recorded. The most suitable solution is probably adding the attributes to the key entity type. Past status data is partially available through the new entity type.

key b u ild in g

c d s d

b ld g n o b ld g n a m e l o c a t io n

c o n t a in s

opyno a te m a d e ta tu s a te lo s t

k e y h is to r y

usedby

useskey

copyof

ro o m ro o m n o s iz e n u m d o o rs e q u ip m e n t

e m p lo y e e

k e y ty p e

opens

k e y ty p e n o d a t e a s s ig n e d p u rp o s e

b e g d a te e n d d a te

a u th o r iz e s

em pno em pnam e p o s itio n O f f ic e N o

22. Define an ERD that supports the generation of product explosion diagrams, assembly instructions, and part lists. These documents are typically included in hardware products sold to the public. Your ERD should represent the final products as well as the parts comprising final products. The following points provide more details about the documents. • Your ERD should support the generation of product explosion diagrams as shown in Figure 6.P2 for a wheelbarrow with a hardwood handle. Your ERD should store the containment relationships along with the quantities required for each subpart. For line drawings and geometric position specifications, you can assume that image and position data types are available to store attribute values.

Figure 6.P2: Product Explosion Diagram • Your ERD should support the generation of assembly instructions. Each product can have a set of ordered steps for instruction. Table 6-P1 shows some of the assembly instructions for a wheelbarrow. The numbers in the instructions refer to the parts diagram. Table 6-P1: Sample Assembly Instructions for the Wheelbarrow Step

Instructions

1

Assembly requires a few hand tools, screw driver, box, or open wrench to fit the nuts.

2

Do NOT wrench tighten nuts until entire wheelbarrow has been assembled.

3

Set the handles (1) on two boxes or two saw horses (one at either end).

4

Place a wedge (2) on top of each handle and align the bolt holes

in the wedge with corresponding bolt holes in the handle.

• Your ERD should support the generation of a parts list for each product. Table 6P2 shows the parts list for the wheelbarrow. Table 6-P2: Partial Parts List for the Wheelbarrow Quantity

Part Description

1

Tray

2

Hardwood handle

2

Hardwood wedge

2

Leg

Ans: In the first solution, the Part entity type contains all parts and products. The PartImage attribute contains a line drawing of the part. The PartDiagram contains a line drawing showing the parts explosion diagram. The Product? attribute is true if the part is a final product. If there are other differences between parts and products, a generalization hierarchy could be used in place of the Product? attribute. The selfreferencing contains relationship represents the assembly details. The parts list is derived from the contains relationship. The InstructionStep entity is a weak entity dependent on part through the identifying assembles relationship. The references relationship shows the parts referenced in an instruction step.

c o n t a in s Q ty

P a rt P P P P P

a r tN o a r tD e s c a r tIm a g e a r tD ia g r a m r o d u c t?

r e fe r e n c e s

In s t r u c t io n S t e p S te p N o D e s c r ip tio n

a s s e m b le s

In the second solution, the contains relationship is replaced with an entity type (Component) and two 1-M relationships. The Component entity type is not identification dependent on the Part entity type because a given part can occur many times as a component. Each occurrence of Component contains the geometry of the component within the part. In the first solution, the geometry of each component was not represented. The parts list is derived from the Contains and UsedIn relationships.

P a rt P P P P P

a r tN o a r tD e s c a r tIm a g e a r tD ia g r a m r o d u c t?

C o n t a in s

r e fe r e n c e s

In s t r u c t io n S t e p S te p N o D e s c r ip tio n

a s s e m b le s

U s e d In

C om ponent C o m p o n e n tN o C o m G e o m e tr y

23. For the Expense Report ERD shown in Figure 6.P3, identify and resolve errors and note incompleteness in the specifications. Note that the ERD may have both diagram and design errors. If you are using the ER Assistant, you can use the Check Diagram feature after checking the diagram rules yourself. Specifications for the ERD appear below: • The Expense Reporting database tracks users and expense reports and expense report items along with users, expense categories, status codes, and limits on expense category spending. • For each user, the database records the unique user number, the first name, the last name, the phone number, the email address, the spending limit, the organizational relationships among users, and the expense categories (at least one) available to the user. A user can manage other users but have at most one manager. For each expense category available to a user, there is a limit amount. • For each expense category, the database records the unique category number, the category description, the spending limit, and the users permitted to use the expense category. When an expense category is initially created, there may not be related users. • For each status code, the database records the unique status number, the status description, and the expense reports using the status code. • For each expense report, the database records the unique expense report number, the description, the submitted date, the status date, the status code (required), the user number (required), and the related expense items. • For each expense item, the database records the unique item number, the description, the expense date, the amount, the expense category (required), and the expense report number (required).

Manages

User UserNo UserFirstName UserLastName UserPhone UserEMail UserLimit

ExpenseCategory CatNo CatDesc CatLimitAmount

Limits

Categorizes

Expenses ExpenseItem ExpenseReport StatusType StatusNo StatusDesc

StatusOf

ERNo ERDesc ERSubmitDate ERStatusDate

Contains

ExpItemNo ExpItemDesc ExpItemDate ExpItemAmount

Figure 6.P3: ERD for the Expense Reporting Database 24. For the Intercollegiate Athletic ERD shown in Figure 6.P4, identify and resolve errors and note incompleteness in the specifications. Note that the ERD may have both diagram and design errors. If you are using the ER Assistant, you can use the Check Diagram feature after checking the diagram rules yourself. Specifications for the ERD appear below: • The Intercollegiate Athletic database supports the scheduling and the operation of events along with tracking customers, facilities, locations within facilities, employees, and resources to support events. To schedule an event, a customer initiates an event request with the Intercollegiate Athletic Department. If an event request is approved, one or more event plans are made. Typically, event plans are made for the setup, the operation, and the cleanup of an event. An event plan consists of one or more event plan lines. • For each event request, the database records the unique event number, the date held, the date requested, the date authorized, the status, an estimated cost, the estimated audience, the facility number (required), and the customer number (required). • For each event plan, the database records the unique plan number, notes about the plan, the work date, the activity (setup, operation, or cleanup), the employee number (optional), and the event number (required). • For each event plan line, the database records the line number (unique within a plan number), the plan number (required), the starting time, the ending time, the



• • • •

resource number (required), the location number (required), and the quantity of resources required. For each customer, the database records the unique customer number, the name, the address, the contact name, the phone, the email address, and the list of events requested by the customer. A customer is not stored in the database until submitting an event request. For each facility, the database records the unique facility number, the facility name, and the list of events in which the facility is requested. For each employee, the database records the unique employee number, the name, the department name, the email address, the phone number, and the list of event plans supervised by the employee. For each location, the database records the related facility number, the location number (unique within a facility), the name, and the list of event plan lines in which the location is used. For each resource, the database records the unique resource number, the name, the rental rate, and the list of event plan lines in which the resource is needed. Location LocNo LocName

Facility Contains

FacNo FacName Customer

Supports Resource

CustNo CustName CustContactName CustPhone CustEMail CustAddr

EventPlanLine LineNo EPLTimeStart EPLTimeEnd EPLQty

ResNo ResName ResRate

Submits Requires

PartOf EventRequest

Employee

EventPlan

EmpNo EmpName EmpPhone EmpEMail EmpDept

EPNo EPDate EPNotes EPActivity

Supervises

Requires

ERNo ERDateHeld ERRequestDate ERAuthDate ERStatus EREstCost EREstAudience

Figure 6.P4: ERD for the Intercollegiate Athletic Database Ans: The ERD below fixes the errors in the original ERD. The following list describes the problem resolutions.  

The Contains relationship should be identifying. The EventPlanLine table should be weak.





  



The HeldAt relationship was added from Facility to EventRequest. Without this relationship, the facility for an event request cannot be determined until an event plan line uses the facility. The Requires relationship should be from Resource to EventPlanLine, not Resource to EventPlan. Each line in an event plan can involve a different resource. The Supports relationship should be 1-M, not M-N. The minimum cardinality in the Submits relationship should be 1 not 0 (customer must be related to at least one event request). The specification is incomplete in the minimum number of event plan lines related to a resource and a location and in the minimum number of event plans supervised by an employee. The specification is also incomplete about attribute constraints such as null value allowed and data types.

Location LocNo LocName

Facility Contains

FacNo FacName Customer

Supports Resource ResNo ResName ResRate

Requires

CustNo CustName CustContactName CustPhone CustEMail CustAddr

EventPlanLine LineNo EPLTimeStart EPLTimeEnd EPLQty

HeldAt Submits

PartOf EventRequest Employee

EventPlan

EmpNo EmpName EmpPhone EmpEMail EmpDept

EPNo EPDate EPNotes EPActivity

Supervises

Requires

ERNo ERDateHeld ERRequestDate ERAuthDate ERStatus EREstCost EREstAudience

25. Define an ERD that supports the generation of television viewing guides, movie listings, sports listings, public access listings, and cable conversion charts. These documents are typically included in television magazines bundled with Sunday newspapers. In addition, these documents are available online. The following points provide more details about the documents. • A television viewing guide lists the programs available during each time slot of a day as depicted in Figure 6.P5. For each program in a channel/time slot, a viewing guide may include some or all of these attributes: a program title, a television









content rating, a description, a rerun status (yes or no), a duration, a closed caption status (yes or no), and a starting time if a program does not begin on a half hour increment. For each movie, a guide also may include some or all of these attributes: an evaluative rating (number of stars from 1 to 4 with half star increments), a list of major actors, an optional brief description, a motion picture content rating, and a release year. Public access programs are shown in a public access guide, not in a television viewing guide. A movie listing contains all movies shown in a television guide as depicted in Figure 6.P6. For each movie, a listing may include some or all of these attributes: a title, a release year, an evaluative rating, a content rating, a channel abbreviation, a list of days of the week/time combinations, a list of major actors, and a brief description. A movie listing is organized in ascending order by movie titles. A sports listing contains all sports programming in a television guide as depicted in Figure 6.P7. A sports listing is organized by sport and day within a sport. Each item in a sports listing may include some or all of these attributes: an event title, a time, a duration, a channel, an indicator for closed-captioning, an indicator if live, and an indicator if a rerun. A public access listing shows public access programming that does not appear elsewhere in a television guide as depicted in Figure 6.P8. A public access listing contains a list of community organizations (title, area, street address, city, state, zip code, and phone number). After the listing of community organizations, a public access listing contains programming for each day/time slot. Because public access shows do not occupy all time slots and are available on one channel only, there is a list of time slots for each day, not a grid as for a complete television guide. Each public access program has a title and an optional sponsoring community organization. A cable/conversion chart shows the mapping of channels across cable systems as depicted in Figure 6.P9. For each channel, a conversion chart shows a number on

each cable system in the local geographic area.

Figure 6.P5: Sample Television Viewing Guide

Figure 6.P6: Sample Movie Listing

Figure 6.P7: Sample Sports Listing

Figure 6.P9: Sample Conversion Chart

Ans: This ERD supports the documents shown in the problem description. Design notes follow the ERD.

TimeSlot TSNo TSDate TSTime

ScheduledItem StartTime Rerun

TimeOf

Channel ChannelOf

ChannelOf

ProgramOf

TimeOf

ChannelId ChnAbbr ChnTitle

CSChannel

ScheduledPA

Program

Duration

ProgNo ProgTitle ProgDesc ProgContentRating ClosedCaptioned Duration

Number

CSOf

PAOf CableSystem

D

PublicAccess

CSId CSName

PANo PATitle

Sponsors

CommOrg OrgNo OrgArea OrgStreet OrgCity OrgState OrgZip OrgPhone

Movie

SportEvent

MVStarRating MVContentRating MVYear

SportType Live

PerformsIn

Actor ActorNo ActName

Design notes  The generalization hierarchy is not complete because regular programs are neither movies nor sporting events. Regular programs can be added as another subtype if there are attributes unique to regular programs.  A generalization hierarchy is not essential in the ERD although it is a good idea. Sporting events and movies are significant subsets of programming. Sporting events and movies have some unique attributes so a generalization hierarchy avoids null values for a significant subset of programming.  It is assumed that there is a function to compute the day of the week given a date.  The starting time for a scheduled item is null except when the item does not start on a half hour interval.  The design assumes that public access programming begins on half hour intervals.

 



The use of optional relationships in the cardinalities near the weak entities allows flexibility when adding entities to the database. The narrative is not clear about the placement of the attributes Rerun, Live, and ClosedCaption. In the solution ERD, the Rerun attribute is placed in the ScheduledItem entity type because it is assumed that the same program can be shown for the first time or as a rerun. The Live and ClosedCaption attributes are placed respectively in the SportEvent and Program entity types because these attributes are assumed to be associated with all viewings. These assumptions should be verified with the user for clarification. Primary keys for most entity types were not specified in the problem. The primary keys added meet the stable and single-purpose criteria. The choice of primary keys should be evaluated with knowledgeable users especially to see if there are any standard accepted primary keys. The industry may use bar codes to identify programs.

Conversion Problems 1.

Convert the ERD shown in Figure 6.CP1 into tables. List the conversion rules used and the resulting changes to the tables. Home HomeID Street City State Zip NoBedrms NoBaths SqFt OwnOccupied Commission SalesPrice

Owner Owns

SSN Name SpouseName Profession SpouseProfession

Lists Agent AgentID Name Phone

Office WorksAt

OfficeID MgrName Phone Address

Figure 6.CP1: ERD for Conversion Problem 1 Ans: • Entity Type Rule: generate home, owner, agent, and office tables

• 1-M Relationship Rule: foreign keys in home (agentid and ssn) and agent (officeid) Result after conversion home(homeid, agentid, ssn, street, city, state, zip, nobedrms, nobath, sqft, price, …) FOREIGN KEY(agentid) REFERENCES agent FOREIGN KEY(ssn) REFERENCES owner agent(agentid, officeid, name, phone) FOREIGN KEY(officeid) REFERENCES office owner(ssn, name, spousename, profess, spouseprofess) office(officeid, mgrname, phone, address) 2.

Convert the ERD shown in Figure 6.CP2 into tables. List the conversion rules used and the resulting changes to the tables. S ta te m e n t S tm tN o D a te A c c tN o

S tm tL in e C o n t a in s

L in e N o M e rN a m e Am t T ra n s D a te

Figure 6.CP2: ERD for Conversion Problem 2 Ans: • Entity Type Rule: generate statement and stmtline tables • 1-M Relationship Rule: foreign key in stmtline • Id Dependency Rule: make the combination of stmtno and lineno the primary key Result after conversion statement(stmtno, date, acctno) stmtline(stmtno, lineno, mername, transdate) FOREIGN KEY(stmtno) REFERENCES statement 3.

Convert the ERD shown in Figure 6.CP3 into tables. List the conversion rules used and the resulting changes to the tables.

P a rt

S u p p lie r

P ro je c t

P a rtN o P a rtN a m e

SuppN o SuppN am e

P r o jN o P r o jN a m e

S u p p -U s e s P a r t- U s e s

Uses

P r o j- U s e s

Figure 6.CP3: ERD for Conversion Problem 3 Ans: • Entity Type Rule: generate part, supplier, and project tables • M-N Relationship Rule: generate uses table Result after conversion part(partno, …) supplier(suppno, …) project(projno, …) uses(partno, suppno, projno) FOREIGN KEY(partno) REFERENCES part FOREIGN KEY(suppno) REFERENCES supplier FOREIGN KEY(projno) REFERENCES project 4.

Convert the ERD shown in Figure 6.CP4 into tables. List the conversion rules used and the resulting changes to the tables. E m p lo y e e S k ill P r o je c t Em pNo Em pNam e

S k i lN n o S k i llN a m e

P r o jN o P r o jN a m e

S k ill- U s e s E m p -U s e s

P r o v id e s

P r o j- U s e s

H rs

Figure 6.CP4: ERD for Conversion Problem 4

Ans: • Entity Type Rule: generate part, supplier, project, and usage tables • 1-M Relationship Rule: generate foreign keys in usage table • Id Dependency Rule: 3 applications make the primary key in usage Result after conversion part(partno, …) supplier(suppno, …) project(projno, …) usage(partno, suppno, projno) FOREIGN KEY(partno) REFERENCES part FOREIGN KEY(suppno) REFERENCES supplier FOREIGN KEY(projno) REFERENCES project 5.

Convert the ERD shown in Figure 6.CP5 into tables. List the conversion rules used and the resulting changes to the tables. Account

D ecom posed

A c c t id A c c tN a m e B a la n c e

P a rt

C o n t a in s

P a rtN o P a rtD e s c C o lo r

Figure 6.CP5: ERD for Conversion Problem 5 Ans: • Entity Type Rule: generate part and account tables • Optional 1-M Relationship Rule: generate the decomposed table • M-N Relationship Rule: generate the contains table Result after conversion part(partno, partdesc, color) account(acctid, acctname, balance) decomposed(acctid, parent_acctid) FOREIGN KEY(acctid) REFERENCES account FOREIGN KEY(parent_acctid) REFERENCES account contains(super_partno, sub_partno) FOREIGN KEY(super_partno) REFERENCES part FOREIGN KEY(sub_partno) REFERENCES part

6.

Convert the ERD shown in Figure 6.CP6 into tables. List the conversion rules used and the resulting changes to the tables. S tu d e n t S td ID N am e G ender D O B A d m itD a te

D ,C U n d S tu d e n t M ajo r M in o r C la ss

G r a d S tu d e n t A d v iso r T h e sisT itle A s s tS ta tu s

Figure 6.CP6: ERD for Conversion Problem 6 Ans: • Entity Type Rule: generate student table • Generalization Rule: generate the undstudent and gradstudent tables Result after conversion student(stdid, name, gender, dob, admitdate) undstudent(stdid, major, minor, class) CONSTRAINT FKUndStudent FOREIGN KEY(stdid) REFERENCES student gradstudent(stdid, advisor, thesistitle, asststatus) CONSTRAINT FKGradStudent FOREIGN KEY(stdid) REFERENCES student 7.

Convert the ERD shown in Figure 6.CP7 into tables. List the conversion rules used and the resulting changes to the tables. Hom e Agent Hom eNo A g e n tID L is ts A d d re s s

Nam e

C o m m is s io n

Figure 6.CP7: ERD for Conversion Problem 7

Ans: • Entity Type Rule: generate home and agent tables • Optional 1-M Relationship Rule: generate the lists table Result after conversion home(homeno, address, …) agent(agentid, name, …) lists(homeno, agentid) FOREIGN KEY(homeno) REFERENCES home FOREIGN KEY(agentid) REFERENCES agent 8.

Convert the ERD shown in Figure 6.CP8 into tables. List the conversion rules used and the resulting changes to the tables. P r o je c t P r o jN o P r o jN a m e

P r o je c tN e e d s Has

S p e c ia lty SpecN o SpecN am e

F u lF ills

P r o v id e d B y

C o n tr a c to r

S u p p lie s

C o n trN o C o n trN a m e

Figure 6.CP8: ERD for Conversion Problem 8 Ans: Result after conversion proiect(projno, …) specialty(specno, …) contractor(contrno, specno, …) FOREIGN KEY(specno) REFERENCES specialty projectneeds(projno, specno) FOREIGN KEY(projno) REFERENCES project FOREIGN KEY(specno) REFERENCES specialty providedby(contrno, projno, specno) FOREIGN KEY(projno, specno) REFERENCES projectneeds FOREIGN KEY(contrno) REFERENCES contractor

Conversion rules  Use the entity type rule to convert each entity type  Use the M-N rule to convert the providedby relationship  Use the 1-M relationship rule to convert the has, fulfills, and supplies relationships.  Use the identification dependency rule to determine the primary key of the projectneeds relationship. 9.

Convert the ERD shown in Figure 6.CP9 into tables. List the conversion rules used and the resulting changes to the tables. Manages

Employee EmpNo EmpFirstName EmpLastName EmpPhone EmpEMail EmpDeptName EmpCommRate

Takes

Customer

Order

Product

CustNo CustFirstName CustLastName CustCity CustState CustZip CustBal

OrdNo OrdDate OrdName OrdCity OrdState OrdZip

ProdNo ProdName ProdQOH ProdPrice ProdNextShipDate

Places

Contains

Qty

Figure 6.CP9: ERD for Conversion Problem 9 Ans: Result after conversion customer(custno, …) employee(empno, supempno, …) FOREIGN KEY(supempno) REFERENCES employee product(prodno, …)

order(ordno, custno, empno, …) FOREIGN KEY(custno) REFERENCES customer FOREIGN KEY(empno) REFERENCES employee contains(ordno, prodno, qty) FOREIGN KEY(ordno) REFERENCES order FOREIGN KEY(prodno) REFERENCES product Conversion rules  Use the entity type rule to convert each entity type  Use the M-N rule to convert the contains relationship  Use the 1-M relationship rule for all relationships except the contains relationship  Can use the optional 1-M relationship rule instead of the 1-M relationship rule to convert the takes and manages relationships. Using the optional 1M relationship rule, order.empno should be replaced by the takes table and employee.supempno should be replaced by the manages table. takes(ordno, empno) FOREIGN KEY(ordno) REFERENCES order FOREIGN KEY(empno) REFERENCES employee manages(empno, supempno) FOREIGN KEY(empno) REFERENCES employee FOREIGN KEY(supempno) REFERENCES employee 10. Convert the ERD shown in Figure 6.CP10 into tables. List the conversion rules used and the resulting changes to the tables.

Provider ProvNo ProvFirstName ProvLastName ProvPhone ProvSpecialty

D,C

Physician

Nurse

PhyEMail PhyHospital PhyCertification

NursePayGrade NurseTitle

Treats

Provides

Patient PatNo PatFirstName PatLastName PatCity PatState PatZip PatHealthPlan

Visit Attends

VisitNo VisitDate VisitPayMethod VisitCharge

VisitDetail Contains

VisitDetailNo DetailCharge

UsedIn

Item ItemNo ItemDesc ItemType ItemPrice

Figure 6.CP10: ERD for Conversion Problem 10 Ans: Result after conversion patient(patno, …) provider(provno, …) physician(provno, …) FOREIGN KEY(provno) REFERENCES provider ON DELETE CASCADE

nurse(provno, …) FOREIGN KEY(provno) REFERENCES provider ON DELETE CASCADE item(itemno, …) visit(visitno, patno, provno, …) FOREIGN KEY(patno) REFERENCES patient FOREIGN KEY(provno) REFERENCES physician visitdetail(visitno, visitdetailno, provno, itemno) FOREIGN KEY(visitno) REFERENCES visit FOREIGN KEY(provno) REFERENCES nurse FOREIGN KEY(itemno) REFERENCES item Conversion rules  Use the entity type rule to convert each entity type  Use the 1-M relationship rule for all relationships  Use the identification dependency rule to determine the primary key of visitdetail.  Can use the optional 1-M relationship rule instead of the 1-M relationship rule to convert the provides relationship. Using the optional 1-M relationship rule, visitdetail.provno should be replaced by the provides table. provides(visitno, visitdetailno, provno) FOREIGN KEY(visitno, visitdetailno) REFERENCES visitdetail FOREIGN KEY(provno) REFERENCES nurse

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF