Professional Documents
Culture Documents
Once each single cycle REA diagram is correct, the data modeler can combine them using the rules explained in chapters 17 and 18. This combination process can be done without the involvement of any employees. The integrated diagram, however, needs to be discussed with management to verify accuracy and completeness. 18.3 Building separate tables for every relationship (1:1, 1:N, and M:N) does not violate any of the rules for building a well-structured database. Why then do you think that REA data modelers recommend building separate tables only for M:N relationships and using foreign keys to implement 1:1 and 1:N relationships? To reduce the number of tables. It is more efficient to use foreign keys for relationships than to build separate tables. This also simplifies queries because fewer tables are needed to retrieve information. Consider the task of generating a list of payments received from a particular customer. If the 1:N relationship between customers and the Receive Cash event is implemented using foreign keys, all the information needed can be found in the Receive Cash and Customer tables. The Receive Cash table would identify the date and amount of payments received from each customer; the customer table would be referenced in order to restrict the query to retrieving only those rows for which the foreign key value for customer number in the Receive Cash table matched the primary key value of a customer with a specific name in the Customer table. However, if the 1:N relationship were implemented as a separate table, then the query would also have to access the 1:N relationship table. 18.4 Assume that there exists a 1:1 relationship between the Receive Inventory and Disburse Cash events. How does the manner in which the relationship between the two events is implemented (i.e., in which table a foreign key is placed) affect the process used to record payments made to suppliers? If the primary key of the Receive Inventory table was included as a foreign key in the Disburse Cash table, then recording payments to suppliers would involve adding a new row to the Disburse Cash table. If, however, the primary key of the Disburse Cash table was included as a foreign key in the Receive Inventory table, then recording a payment to a supplier would involve not only creating a new row in the Disburse Cash table, but also updating the value of the check number (foreign key) column in the appropriate row of the Receive Inventory table.
18-2
2011 Pearson Education, Inc. Publishing as Prentice Hall
18.5
Refer to Figure 18-4 and Table 18-1. How would you determine the amount of cash that Freds Train Shop has at any point in time? To calculate the amount of cash that Freds Train Shop has at a particular point in time, you would need to query three tables: Cash, Disburse Cash, and Receive Cash. The Cash table would include the cash on hand at the beginning of the current fiscal year. The Disburse Cash table includes an attribute for the amount of each disbursement made during the current fiscal year; summing this column would yield total cash outflows. Similarly, the Receive Cash table includes an attribute showing the amount of each cash receipt during the current fiscal year; summing this column would yield total cash inflows. Thus, cash on hand at particular point in time equals beginning cash on hand plus the sum of all receipts minus the sum of all disbursements.
18.6
Why does Figure 18-4 show only one cash disbursement entity if Freds Train Shop uses a general operating checking account for purchases of inventory, supplies, and operating expenses such as rent but also uses a separate checking account for payroll? REA models do not represent actual physical accounts but types of accounts. Thus, even though Freds Train Shop uses two checking accounts, the REA displays a single entity for cash. This entity contains information about all of Freds individual checking accounts. Each row in the cash table for Freds train shop would provide information about a specific checking account. Each account would have its own primary key. Then, when there is a cash disbursement it would be linked to the specific record or row in the cash table that represented which of the two checking accounts for Freds Train Shop was used to make a particular disbursement. This linking would involve using the primary key of the appropriate checking account as a foreign key in that row in the Disburse Cash event table.
18-3
2011 Pearson Education, Inc. Publishing as Prentice Hall
18.7
Examine Figure 18-4 and Table 18-1. Why do the Inventory, Customers, and Suppliers tables all have an attribute that contains data about the balance at the beginning of the current fiscal period? The reason that all three entities contain an attribute that stores the beginning balance is that the related event tables typically contain information for only the current year. Thus, the beginning balance attribute represents information about prior years events. This information about beginning balances is needed in order to calculate current balances at any point in time. For example, the Inventory table would show the quantity on hand for each inventory item at the beginning of the current fiscal year. The M:N table linking the Receive Inventory and Inventory tables includes an attribute for the quantity received of a specific inventory item. The M:N table linking the Inventory and Sales tables includes an attribute for the quantity sold of a particular item. Thus, the quantity on hand at a particular point in time equals the beginning quantity on hand plus the sum of all receipts of that inventory item minus the sum of all sales of that item. The Customer and Supplier tables contain information about the beginning balances of Accounts Receivable and Accounts Payable for specific customers and suppliers, respectively. Current balances can then be computed by adding the sum of all sales to a customer (purchases from a supplier) and subtracting the sum of all payments from a customer (payments to a supplier) during the current fiscal year.
18-4
2011 Pearson Education, Inc. Publishing as Prentice Hall
SUGGESTED ANSWERS TO THE PROBLEMS 18.1 Refer to Problems 17.1 and 17.2 for information about the revenue and expenditure cycle activities for Joes ice-cream shop in order to draw an integrated REA diagram of both cycles.
Employees
Order Inventory
Inventory
Sales
Employee
Employees
Vendors
Disburse Cash
Cash
Receive Cash
Employee
18-5
2011 Pearson Education, Inc. Publishing as Prentice Hall
18.2
Develop a set of tables to implement the integrated REA diagram you developed in Problem 18.1 for Joes ice-cream shop in a relational database. Specify a primary key for each table, and suggest at least one other attribute that should be included in each table. Table Primary key Employee# Vendor# Purchase Order# Receiving Report# Check# Item# GLAccount# Invoice# Remittance# Item# PurchaseOrder#, Item# Other attributes foreign keys in italics Name, date hired, salary, position Name, address, beginning account balance Date, vendor#, employee# Date, vendor#, employee#, purchase order#, check# Employee#, Vendor#, GLAccount#, amount Description, beginning quantity on hand, list price Account Name, beginning balance Date, customer#, employee#, amount Date, customer#, employee#, invoice#, GLAccount# Description, quantity on hand, reorder quantity, reorder point Quantity, UnitCost Quantity, condition Quantity, UnitPrice
Employees Vendors Order Inventory Receive Inventory Disburse Cash Inventory Cash Sales Receive Cash Inventory Order InventoryInventory
18-6
2011 Pearson Education, Inc. Publishing as Prentice Hall
18.3
Refer to Problems 17.3 and 17.4 for information about Sues Gallerys revenue and expenditure cycle activities in order to draw an integrated REA diagram of both cycles.
Employees
Purchases
Inventory
Sales
Employee
Vendors
Customer
Employees
Disburse Cash
Cash
Receive Cash
Employee
18-7
2011 Pearson Education, Inc. Publishing as Prentice Hall
18.4
Develop a set of tables to implement the integrated REA diagram you developed in Problem 18.3 for Sues Gallery in a relational database. Specify a primary key for each table, and suggest at least one other attribute that should be included in each table. Table Vendor Employees Purchases Disburse Cash Inventory Cash Sales Receive Cash Customer Primary key Vendor# Employee# Purchase Order# Check# Item# GLAccount# Invoice# Remittance# Customer# Other attributes foreign keys in italics Name, address, phone, contact, account balance Name, date hired, salary, date of birth, position Date, employee#, vendor# GLAccount#, employee#, vendor#, purchase order#, date, amount Purchase order#, invoice#, cost, sales price, description Account name, beginning balance Customer#, employee#, date Date, amount, employee#, customer#, invoice#, GLAccount# Name, address, beginning balance
Note: The cost and sales price are attributes of the inventory table because each unique item is only purchased once and sold once.
18-8
2011 Pearson Education, Inc. Publishing as Prentice Hall
18.5
The following tables and attributes exist in a relational database: Table Vendor Purchases Inventory Receipts Cash Disbursed Inventory Receipts Cash Disbursed Attributes Vendor#, name, street address, city, state P.O.#, date, amount, vendor#, purchasing agent# Receiving report#, date, receiving clerk#, remarks, P.O.# Check#, date, amount Check#, receiving report#, amount applied to invoice
Draw an REA diagram for this database. State any additional assumptions you need to make about cardinalities. The solution appears on the following page. Students should be able to suggest adding the entities connected by dotted lines, even though they are not listed in the problem. Key assumptions about cardinalities include the following: Vendors do not make partial shipments. If you assume otherwise, then the cardinality from Purchases to Inventory Receipts should be adjusted. Note that the presence of P.O. number as an attribute in the Receive Inventory table rules out the possibility that this is an M:N relationship. The inventory in question is not unique one-of-a-kind items. If it were, the maximum cardinality from Inventory to both events would be 1. The existence of an Inventory Receipts Cash Disbursed table with an attribute in it suggests that this is a M:N relationship: the company can make installment payments on purchases and also runs a tab, paying periodically for all purchases made during a specified time. The amount-applied attribute informs the seller how to apply the payment.
18-9
2011 Pearson Education, Inc. Publishing as Prentice Hall
Inventory
Purchases
Employee
Inventory Receipts
Vendor
Employee
Cash
Cash Disbursed
Vendor
18-10
2011 Pearson Education, Inc. Publishing as Prentice Hall
18.6
Refer to Problems 17.8 and 17.9 for information about the revenue and expenditure cycles for the Computer Warehouse and use that information to draw an integrated REA diagram for both cycles.
Employee
Order Inventory
Inventory
Sales
Employee
Customer
Employee
Vendor
Disburse Cash
Cash
Receive Cash
Employee
18-11
2011 Pearson Education, Inc. Publishing as Prentice Hall
18.7
Develop a set of tables to implement the integrated REA diagram you developed in Problem 17.6 for the Computer Warehouse in a relational database. Specify a primary key for each table, and suggest at least one other attribute that should be included in each table. Table Vendor Employees Order Inventory Receive Inventory Disburse Cash Inventory Cash Sales Receive Cash Customers Order InventoryInventory Sales-Inventory Primary key Vendor# Employee# Purchase Order# Receiving Report# Check# Item# GLaccount# Invoice# Remittance# Customer# Purchase Order#, Item# Invoice#, Item# Other attributes (foreign keys in italics) Name, address, phone, contact Name, date hired, salary, date of birth, position Date, vendor#, employee# Date, vendor#, employee#, check#, purchase order# Date, amount, vendor#, employee#, GLaccount# Description, beginning quantity on hand, reorder quantity, reorder point Account name, beginning balance Date, employee#, customer#, remittance# Date, amount, employee#, customer#, GLaccount# Name, address, beginning balance Quantity, unit cost Quantity, unit price Quantity, condition
18-12
2011 Pearson Education, Inc. Publishing as Prentice Hall
18.8
Explain how to calculate the total amount of Accounts Payable: Total Accounts Payable can be calculated in five steps, as follows: Step 1: Normally, only orders actually received are considered purchases for purposes of calculating accounts payable. Therefore, begin with a query of the Receive Inventory table (or M:N relationship table linking the Order Inventory and Receive Inventory events) to determine which orders have been received this fiscal period. Step 2: Query the Order Inventory Inventory table to determine the total amount purchased this fiscal period by summing the product of quantity ordered by its unit cost for those purchase orders for which there is a corresponding receipt of inventory (from step 1). Step 3: Retrieve the total beginning balance of Accounts Payable by querying the Suppliers table and summing the beginning balance column. Step 4: Query the Disburse Cash table to calculate the total amount paid to suppliers this fiscal period by summing the amount column for every row in which the supplier number is not null. It is important to exclude rows where the supplier number is null, as those represent other types of payments (e.g., payroll). Step 5: Total Accounts Payable = Answer to Query 2 + Answer to Query 3 Answer to Query 4.
18-13
2011 Pearson Education, Inc. Publishing as Prentice Hall
18.9
Refer to Figure 18.4 and Table 18-1 to write the query logic needed to answer the following questions. (Optional: If requested by your instructor, write your queries in SQL or a Query-By-Example graphical interface.) Some answers may require more than one querytry to write the most efficient queries possible. a. Accounts payable for all suppliers in Arizona Step 1: Normally, only orders actually received are considered purchases for purposes of calculating accounts payable. Therefore, begin with a query of the Receive Inventory table (or M:N relationship table linking the Order Inventory and Receive Inventory events) and the Supplier table to determine which orders have been received this fiscal period. The supplier table is needed in order to restrict the result to only those suppliers located in Arizona. Step 2: Query the Order Inventory Inventory table to determine the total amount purchased this fiscal period by summing the product of quantity ordered by its unit cost for those purchase orders for which there is a corresponding receipt of inventory (from step 1). Step 3: Retrieve the total beginning balance of Accounts Payable by querying the Suppliers table and summing the beginning balance column, restricting the sum operation to only those suppliers located in Arizona. Step 4: Query the Disburse Cash and Supplier tables to calculate the total amount paid to suppliers located in Arizona this fiscal period by summing the amount column for every row in the Disburse Cash table for which the supplier number equals the primary key of a row in the Supplier table that has a value of Arizona in its address column. Step 5: Total Accounts Payable to Arizona Suppliers = Answer to Query 2 + Answer to Query 3 Answer to Query 4.
b. Total amount of sales to a customer named Smith Step 1: Identify all sales to Smith by writing a query that joins the Sales and Customer tables, where the value of the customer# in the Sales table equals the primary key in the row of the Customer table where the name = Smith. Step 2: Sum the product of quantity sold times unit price in the M:N Sales-Inventory table for only those rows with sales invoice numbers identified in step 1.
18-14
2011 Pearson Education, Inc. Publishing as Prentice Hall
c. Total wage expense Pay rates are likely to differ across employees. Therefore, calculate total wage expense by summing the wage expense for each employ, as follows: Step 1: Query the Time Worked table to sum the total hours worked, grouped by employee number. Step 2: Query the table produced in step 1 and the Employee table to calculate the total wages earned by each employee (by multiplying total hours worked times that employees pay rate). Step 3: Sum the total amounts in the table produced in step 2. d. Total wages payable Total wages payable equals wages earned but not yet paid. Thus, use the same procedure as used to calculate total wage expense, except restrict step 1 to only those rows in the Time Worked table for which the paycheck# column is null. e. Net increase (decrease) in quantity-on-hand for a particular inventory item Step 1: Write a query to sum the quantity received in the M:N relationship table linking the Receive Inventory event and the Inventory table for only those rows with a particular value in the item# column. Step 2: Write a query to sum the quantity sold in the M:N Sales-Inventory relationship table for only those rows with the same item# as used in step 1. Step 3: Net change in quantity-on-hand for that item = Query 1 Query 2. f. The proportion of sales made to walk-in customers (i.e., no order) Step 1: Write a query to calculate total sales by summing the product of quantity sold times unit price in the Sales-Inventory M:N relationship table. Step 2: Write a query to identify all sales to walk-in customers by listing all sales invoices in the Sales table for which the order number column is null. Step 3: Repeat step 1, but restrict the calculation to only those rows in the SalesInventory table for which the sales invoice number appeared in the step 2 query. Step 4: Divide query 3 by query 1.
18-15
2011 Pearson Education, Inc. Publishing as Prentice Hall
g. The salesperson who made the largest amount of sales in October Step 1: Write a query to calculate total sales by summing the product of quantity sold times unit price in the Sales-Inventory M:N relationship table. Step 2: Write a query to identify all sales to walk-in customers by listing all sales invoices in the Sales table for which the order number column is null. Step 3: Repeat step 1, but restrict the calculation to only those rows in the SalesInventory table for which the sales invoice number appeared in the step 2 query. Step 4: Divide query 3 by query 1.
h. The salesperson who made the most sales in October Step 1: Write a query to identify all rows in the Sales table that occurred in October. Step 2: Write a query that counts the number of rows in the response to query 1, grouped by employee number. Step 3: Write a query that identifies the employee number in query 2 that has the maximum value in the count column. Step 4: Write a query that joins the result of query 3 with the employee table to display both the employee number and name.
i.
Step 1: Write a query against the M:N Sales-Inventory relationship table that sums the quantity sold column, grouped by product number. Step 2: Write a query against the table resulting from query 1, that identifies the item number with the maximum value in the total quantity sold column. Step 3: Write a query that joins the result of query 2 with the inventory table to display both the item# and its description.
18-16
2011 Pearson Education, Inc. Publishing as Prentice Hall
18.10 Refer to Problem 17.10 and develop a set of tables to implement the REA diagram you developed for Stans Southern Barbeque Supply Store. Identify the primary and foreign keys for each table, and dont forget to address any M:N relationships. Table Order Inventory Primary key Purchase Order# Receiving Report# Check# Foreign Keys Employee#, Vendor#, Receiving Report# Vendor#, Employee# Vendor#, Employee#, GLAccount# Other attributes Date
Cash Inventory
GLAccount# Item#
Balance, beginning balance Description, beginning quantity on hand, reorder quantity, reorder point Name, hire date, position, payrate Name, address, contact, beginning account balance, performance rating Quantity, unit cost Quantity, condition
Employee Vendor
Employee# Vendor#
Amount applied
18-17
2011 Pearson Education, Inc. Publishing as Prentice Hall
SUGGESTED ANSWERS TO THE CASES 18.1 The specific solution will vary depending upon the DBMS and REA data model used. Therefore, we present only the query logic here for the model depicted in Figure 18.4.
1. Calculate total Accounts Receivable. a. Calculate beginning Accounts Receivable by summing the beginning balance attribute in the Customer table. b. Calculate total new Sales this fiscal period by summing the product of quantity sold times unit price from the Sales Inventory M:N relationship table. c. Calculate total cash received from customers by summing amount received column in the Receive Cash table. d. Total Accounts Receivable = Query A + Query B Query C
2. Calculate Accounts Receivable for a specific customer. This requires a similar set of queries as used to calculate total Accounts Receivable: a. Calculate beginning Accounts Receivable by summing the beginning balance attribute in the Customer table for the customer of interest. b. Select only those rows in the Sales table that represent sales to the customer of interest (i.e., those rows in the Sales table which have a value in the Customer# foreign key column equal to the Customer# of the particular customer of interest). c. Calculate total new Sales this fiscal period by summing the product of quantity sold times unit price from the Sales Inventory M:N relationship table for only those rows which have an invoice number in the set of invoice numbers from query b. d. Calculate total cash received from customers by summing amount received column in the Receive Cash table for only those rows which have a value in the Customer# foreign key column equal to the Customer# of the particular customer of interest. e. Total Accounts Receivable = Query A + Query C Query D.
18-18
2011 Pearson Education, Inc. Publishing as Prentice Hall
3. Create a sales invoice form that references the appropriate tables and inputs data about attributes into the proper tables. The syntax for doing this will vary depending upon the DBMS used. Solutions should be tested to ensure that the form adds new rows to the following tables: Sales Sales-Inventory
It will also need to reference the Customer and Inventory tables to identify relevant information (shipping and billing addresses, item description, etc.).
4. Calculate as many financial statement items as possible from the data model you implement. Income Statement items derivable from Figure 18.4: Only Sales and Wage Expense can be definitively calculated; cost of goods sold requires making assumptions about inventory cost/valuation method (FIFO, LIFO, weighted average, specific identification). Sales
Sum the product of quantity sold times unit price for all rows in the M:N SalesInventory relationship table Wage expense
Step 1: Query the Time Worked table to sum the total hours worked, grouped by employee number. Step 2: Query the table produced in step 1 and the Employee table to calculate the total wages earned by each employee (by multiplying total hours worked times that employees pay rate). Step 3: Sum the total amounts in the table produced in step 2.
18-19
2011 Pearson Education, Inc. Publishing as Prentice Hall
Balance Sheet items derivable from Figure 18.4: Only Cash, Accounts Receivable, Accounts Payable, and Wages Payable can be definitively calculated. Inventory valuation requires an assumption about inventory method (FIFO, LIFO, weighted average, specific identification).
Cash Step 1: Calculate the beginning balance of cash by summing the amount column in the Cash table. Step 2: Calculate total cash receipts by summing the amount column in the Receive Cash table. Step 3: Calculate total cash disbursements by summing the amount column in the Disburse Cash table. Step 4: Ending Cash Balance = Answer to Query 1 + Answer to Query 2 Answer to Query 3.
Accounts Receivable a. Calculate beginning Accounts Receivable by summing the beginning balance attribute in the Customer table. b. Calculate total new Sales this fiscal period by summing the product of quantity sold times unit price from the Sales Inventory M:N relationship table. c. Calculate total cash received from customers by summing amount received column in the Receive Cash table. d. Total Accounts Receivable = Query A + Query B Query C
18-20
2011 Pearson Education, Inc. Publishing as Prentice Hall
Accounts Payable Step 1: Normally, only orders actually received are considered purchases for purposes of calculating accounts payable. Therefore, begin with a query of the Receive Inventory table (or M:N relationship table linking the Order Inventory and Receive Inventory events) to determine which orders have been received this fiscal period. Step 2: Query the Order Inventory Inventory table to determine the total amount purchased this fiscal period by summing the product of quantity ordered by its unit cost for those purchase orders for which there is a corresponding receipt of inventory (from step 1). Step 3: Retrieve the total beginning balance of Accounts Payable by querying the Suppliers table and summing the beginning balance column. Step 4: Query the Disburse Cash table to calculate the total amount paid to suppliers this fiscal period by summing the amount column for every row in which the supplier number is not null. It is important to exclude rows where the supplier number is null, as those represent other types of payments (e.g., payroll). Step 5: Total Accounts Payable = Answer to Query 2 + Answer to Query 3 Answer to Query 4.
Wages Payable Step 1: Query the Time Worked table to sum the total hours worked, grouped by employee number, restricted to only those rows for which the check number column is null. Step 2: Query the table produced in step 1 and the Employee table to calculate the total wages earned by each employee (by multiplying total hours worked times that employees pay rate). Step 3: Sum the total amounts column in the table produced in step 2.
18-21
2011 Pearson Education, Inc. Publishing as Prentice Hall
5. Design appropriate input controls for the sales invoice form created in step 3. The syntax required will vary depending upon the DBMS used. Students should be encouraged to review material from chapter 10 to identify appropriate input controls. Solutions should include the following: 1. Auto-number the sales invoice to prevent creating duplicate or null primary keys. 2. Validity check on item numbers. 3. Sign check on quantity sold and price fields. 4. Completeness checks on customer information (billing and shipping address) this information should ideally be automatically populated upon entering the customer number. 5. Completeness checks on inventory information (description, list price, etc.) this information should ideally be automatically populated upon entering the item number. 6. Validity check on sales date (check against the current system date).
18-22
2011 Pearson Education, Inc. Publishing as Prentice Hall