ICE WholeFoodsERD Soln

2
 1 Solution to In-Class Exercise: Conceptual Entity-Rel ationship Diagram for Whole Foods Cashier PK Cas hierNum Name (...) Position/Role Store PK St or eNum Address(...) Phone Item PK It emID Description UnitPrice UnitOfMeasure TaxableStatus SaleTransaction PK TxnNum PK TxnDat e TxnTime [NumOfItems] [Subtotal] [Total] RegNum Payment PK Pmt Number PmtType PmtAmount AcctNum ApprovalCode CreditCardType Is hired by Occurs at Records Has TransactionLine PK Lin eNu mbe r UnitSalePrice AmtSold [LineTotal] contains Appears on TaxType TaxName TaxPercentage SalesTax [TaxAmt] Is used to calculate Is applied to Notes:  This is one solution; there are many variations on this that would be acceptable, depending on the assumptions you made.  Shaded entity types are either associative, weak, or both.  Green, bold lines are identifying relationships for weak entity types.  

Transcript of ICE WholeFoodsERD Soln

Page 1: ICE WholeFoodsERD Soln

8/2/2019 ICE WholeFoodsERD Soln

http://slidepdf.com/reader/full/ice-wholefoodserd-soln 1/2

  1

Solution to In-Class Exercise:

Conceptual Entity-Relationship Diagram for Whole Foods

Cashier

PK CashierNum

Name (...)Position/Role

Store

PK StoreNum

Address(...)Phone

Item

PK ItemID

DescriptionUnitPriceUnitOfMeasureTaxableStatus

SaleTransaction

PK TxnNumPK TxnDate

TxnTime[NumOfItems][Subtotal][Total]RegNum

Payment

PK PmtNumber

PmtTypePmtAmountAcctNumApprovalCodeCreditCardType

Is hired by

Occurs atRecords

Has

TransactionLine

PK LineNumber

UnitSalePriceAmtSold[LineTotal]

contains

Appears on

TaxType

TaxName

TaxPercentage

SalesTax

[TaxAmt]

Is used to calculate

Is applied to

Notes:•  This is one solution; there are many variations on this that would be acceptable, depending on the

assumptions you made.

•  Shaded entity types are either associative, weak, or both.

•  Green, bold lines are identifying relationships for weak entity types. 

Page 2: ICE WholeFoodsERD Soln

8/2/2019 ICE WholeFoodsERD Soln

http://slidepdf.com/reader/full/ice-wholefoodserd-soln 2/2

  2

Assumptions:•  CashierNum is unique only within a particular store (which is why Cashier is weak and partially

identified by its relationship to Store).

•  TxnNum represents a sale transaction that occurred at a particular store on a particular date (which iswhy SaleTransaction is weak and partially identified by its relationship to Store).

•  Some items are taxed at different rates than others, and some items are not taxed at all (which is why Ihave an optional TaxableStatus attribute in Item).

•  One sale transaction may have multiple payments, such as paying partly with a gift card and partly withcredit card. The PmtNumber is just a sequential number (e.g., 1, 2) to represent whether a particularpayment is the 1

stor 2

ndpayment for a particular sale (which is why Payment is weak and partially

identified by its relationship to SaleTransaction).

•  The UnitPrice attribute in Item may change over time (e.g., to reflect a temporary sale price). (This iswhy I added UnitSalePrice to TransactionLine – because the LineTotal can only be derived from theprice of the item at the time of the sale.)

Business Rules:•  For each instance of SaleTransaction: 

o  the number of items is derived by summing the number of instances of TransactionLine that are

related to that transaction.o  the subtotal is derived by summing the LineTotal for each related instance of TransactionLine.

o  the Total is derived by adding the subtotal to all of the tax amounts on related instances of SalesTax.

•  For each instance of TransactionLine, the LineTotal is:o  the same as the UnitSalePrice if the AmtSold is nullo  the result of multiplying the UnitSalePrice by the AmtSold if AmtSold is not null.

•  When a new instance of TransactionLine is created, its UnitSalePrice is equal to the UnitPrice of theassociated item. The UnitSalePrice does not change once the SaleTransaction is saved, but the item’sUnitPrice may change over time.

•  In Payment, the AcctNum, ApprovalCode, and ApprovedAmt attributes must have values if the

PmtType = credit card.

Outstanding Issues:•  Need to learn more about the different types of sales tax that may be applicable to grocery stores, and to

what items each type of tax is applied. For now, the model shows that there are different types of tax(e.g., Larimer county sales tax, Boulder city sales tax, state sales tax), each with its own rate. And themodel shows that these tax types or categories are applied to many transactions, and that there is aspecific TaxAmt for each type of tax that is applied to a sale transaction. Presumably, these tax amountscan be derived by applying certain rules to items with certain taxable status values, on sales that occur incertain store locations, but it may be more involved than that.

•  What is the relevance of the “barista” note on one of the receipts? Is it to indicate a role that the

employee was filling at the time of the sale, or the “department” where the sale occurred?•  Need to learn more about pricing promotions (like the 2/$5.00 burritos) and how that information should

be recorded in the database.