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 Dis
Trang 1CHAPTER 18 IMPLEMENTING AN REA MODEL IN A RELATIONAL DATABASE
SUGGESTED ANSWERS TO DISCUSSION QUESTIONS
18.1 How would the process of generating a cash disbursements journal from the REA
data model presented in Figure 18-4 and Table 18-1 differ from the process for creating a sales journal?
The steps required to create a cash disbursements journal would be simpler than the process used to create a sales journal A cash disbursements journal typically lists all of
an organization’s payments to its various suppliers (payroll disbursements are usually recorded separately from payments to suppliers)
The information typically recorded in a cash disbursements journal includes the date, method of payment, payment identifier (e.g., check number or EFT transaction number), payee, amount, and description of the purpose Note that all of this information can be found in the disburse cash event table
Thus, the information necessary to produce a cash disbursements journal can be found by querying only one table The query would be restricted to those rows for which the
supplier number, a foreign key, has values (null values for the supplier number would occur because the cash disbursements were for payroll)
18.2 Why take the time to develop separate REA diagrams for each business cycle if the
ultimate objective is to combine them into one integrated enterprise-wide data model? Why not just focus on the integrated model from the start?
One way to think about it is divide and conquer Modeling each business cycle
individually makes it easier to be sure to identify all the relevant resources, events, and agents for that cycle Once the resources, events, and agents have been identified, the relationships between these entities can be prepared
It is also easier to assign cardinalities to relationships in REA diagrams for a single
business cycle because the relationships directly represent the organization’s business
Trang 2Once 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
Trang 318.5 Refer to Figure 18-4 and Table 18-1 How would you determine the amount of cash
that Fred’s Train Shop has at any point in time?
To calculate the amount of cash that Fred’s 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 Fred’s 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 Fred’s Train Shop uses two checking accounts, the REA displays a single entity for cash This entity contains information about all of Fred’s individual checking
accounts Each row in the cash table for Fred’s 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 Fred’s 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
Trang 4
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
Trang 5SUGGESTED ANSWERS TO THE PROBLEMS
18.1 Refer to Problems 17.1 and 17.2 for information about the revenue and expenditure
cycle activities for Joe’s ice-cream shop in order to draw an integrated REA
diagram of both cycles
Inventory
Cash
Sales
Receive Cash
Employee
Customer
Employee
Trang 618.2 Develop a set of tables to implement the integrated REA diagram you developed in
Problem 18.1 for Joe’s 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 Other attributes foreign keys in italics
Employees Employee# Name, date hired, salary, position
Vendors Vendor# Name, address, beginning account balance Order Inventory Purchase Order# Date, vendor#, employee#
Receive Inventory Receiving Report# Date, vendor#, employee#, purchase order#,
check#
Disburse Cash Check# Employee#, Vendor#, GLAccount#, amount
Inventory Item# Description, beginning quantity on hand, list
price Cash GLAccount# Account Name, beginning balance
Sales Invoice# Date, customer#, employee#, amount
Receive Cash Remittance# Date, customer#, employee#, invoice#,
GLAccount#
Inventory Item# Description, quantity on hand, reorder
quantity, reorder point Order Inventory-
Inventory
PurchaseOrder#, Item#
Quantity, UnitCost
Receive
Inventory-Inventory
ReceivingReport#, Item#
Quantity, condition Sales-Inventory Invoice#, Item# Quantity, UnitPrice
Trang 718.3 Refer to Problems 17.3 and 17.4 for information about Sue’s Gallery’s revenue and
expenditure cycle activities in order to draw an integrated REA diagram of both cycles
Trang 818.4 Develop a set of tables to implement the integrated REA diagram you developed in
Problem 18.3 for Sue’s 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 Primary key Other attributes foreign keys in italics
Vendor Vendor# Name, address, phone, contact, account balance Employees Employee# Name, date hired, salary, date of birth, position Purchases Purchase Order# Date, employee#, vendor#
Disburse Cash Check# GLAccount#, employee#, vendor#, purchase
order#, date, amount
Inventory Item# Purchase order#, invoice#, cost, sales price,
description Cash GLAccount# Account name, beginning balance
Sales Invoice# Customer#, employee#, date
Receive Cash Remittance# Date, amount, employee#, customer#, invoice#,
GLAccount#
Customer Customer# 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
Trang 918.5 The following tables and attributes exist in a relational database:
Vendor Vendor#, name, street address, city, state
Purchases P.O.#, date, amount, vendor#, purchasing agent#
Inventory Receipts Receiving report#, date, receiving clerk#, remarks,
P.O.#
Cash Disbursed Check#, date, amount
Inventory Receipts – Cash
Disbursed
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
Trang 10Inventory Purchases Employee
Inventory
Employee
Vendor Cash
Disbursed Cash
Trang 1118.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
Inventory
Cash
Sales
Receive Cash
Employee
Customer
Employee
Trang 1218.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 Primary key Other attributes (foreign keys in italics)
Vendor Vendor# Name, address, phone, contact
Employees Employee# Name, date hired, salary, date of birth,
position Order Inventory Purchase Order# Date, vendor#, employee#
Receive Inventory Receiving Report# Date, vendor#, employee#, check#,
purchase order#
Disburse Cash Check# Date, amount, vendor#, employee#,
GLaccount#
Inventory Item# Description, beginning quantity on hand,
reorder quantity, reorder point Cash GLaccount# Account name, beginning balance
Sales Invoice# Date, employee#, customer#, remittance#
Receive Cash Remittance# Date, amount, employee#, customer#,
Quantity, unit cost Sales-Inventory Invoice#, Item# Quantity, unit price
Receive
Inventory-Inventory
Receiving Report#, Item#
Quantity, condition
Trang 1318.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
Trang 1418.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 query—try 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