0% found this document useful (0 votes)
327 views14 pages

Chapter Four - Problems and Answers: Problem 4.3

The document contains problems and suggested answers related to designing relational database tables to store business data. It proposes tables to store inventory, purchase, vendor, and employee data without anomalies. It also contains problems on normalizing an invoice table into separate tables for sales, inventory, customers to avoid data issues. Suggested SQL queries answer questions on the data like customers of a vendor, largest credit limit, sales in a month, sales by employee, items on an invoice, customers in a state, items sold and inventory levels.

Uploaded by

jin zihan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
327 views14 pages

Chapter Four - Problems and Answers: Problem 4.3

The document contains problems and suggested answers related to designing relational database tables to store business data. It proposes tables to store inventory, purchase, vendor, and employee data without anomalies. It also contains problems on normalizing an invoice table into separate tables for sales, inventory, customers to avoid data issues. Suggested SQL queries answer questions on the data like customers of a vendor, largest credit limit, sales in a month, sales by employee, items on an invoice, customers in a state, items sold and inventory levels.

Uploaded by

jin zihan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Chapter Four – Problems and answers

Problem 4.3
Ashton wants to store the following data about S&S’s purchases of inventory:
item number date of purchase
vendor number vendor address
vendor name purchase price
quantity purchased employee number
employee name purchase order number
description quantity on hand
extended amount total amount of purchase

a. Design a set of relational tables to store this data. Do all the data items need to be
stored in a table? If not, which ones do not need to be stored and why do they not
need to be stored?
b. Identify the primary key for each table.
c. Identify the foreign keys needed in the tables to implement referential integrity.

Suggested answers

(a), (b) and (c)


Table Name Primary Key Foreign Keys Other Attributes
Inventory Item Number Description
Quantity on Hand
Purchases Purchase order number Vendor number Date of purchase
Employee number Total amount of
purchase
Purchases-Inventory Combination of item Item number Quantity purchased
number and Purchase order number Unit cost (actual)
Purchase order number Extended amount
Vendor Vendor number Vendor name
Vendor address
Employees Employee number Employee name

Extended amount and Total amount of purchase do not have to be stored in the database
as they can be calculated from other values. Extended amount is Quantity purchased x
Unit cost. Total amount of purchase is the sum of all the extended amounts for all
items on a particular purchase order.

Romney, M.B. and P.J. Steinbart, Accounting Information Systems, Pearson. 1


Problem 4.8 Create relational tables that solve the update, insert, and delete anomalies in Table 4-17.

TABLE 4-17
Invoice# Date Order_ Customer_ Customer_ Item# Description Quantity
Date ID Name
52 6-19-18 5-25-18 201 Johnson 103 Trek 9000 5
52 6-19-18 5-25-18 201 Johnson 122 Nimbus 4000 8
52 6-19-18 5-25-18 201 Johnson 10 Izzod 3000 11
52 6-19-18 5-25-18 201 Johnson 71 LD Trainer 12
57 6-20-18 6-01-18 305 Henry 535 TR Standard 18
57 6-20-18 6-01-18 305 Henry 115 NT 2000 15
57 6-20-18 6-01-18 305 Henry 122 Nimbus 4000 5

Suggested answers

Before attempting this problem, students should refer to the lecture slides for the explanations of the
three file maintenance problems.
To avoid the update, insert, and delete anomalies, 4 separate relational tables are created.

SALES TABLE
Invoice# (PK) Date Order_Date Customer_ID (FK)
52 6-19-18 5-25-15 201
57 6-20-18 6-01-15 305

SALES-INVENTORY TABLE
Invoice# (PK/FK) Item# (PK/FK) Quantity
52 103 5
52 122 8
52 10 11
52 71 12
57 535 18
57 115 15
57 122 5

CUSTOMER TABLE

Customer_ID (PK) Customer_Name

201 Johnson
305 Henry
Romney, M.B. and P.J. Steinbart, Accounting Information Systems, Pearson. 2
INVENTORY TABLE
Item# (PK) Description
10 Izzod 3000
71 LD Trainer
103 Trek 9000
115 NT 2000
122 Nimbus 4000
535 TR Standard

Note: PK-Primary Key, FK – Foreign Key, PK/FK – Primary Key/Foreign Key

Romney, M.B. and P.J. Steinbart, Accounting Information Systems, Pearson. 3


Extra Problem: Below is a table modified from end of chapter problem.

Answer the following questions based on the above table:

1. What is the primary key in the following tables?


a. Inventory table
b. Sales-Inventory table

2. What is the foreign key in the Sales table?

3. Which table violates the entity integrity rule?

4. What is the relationship between the Inventory table and Sales-Inventory table?

5. Which relationship, if drawn between two tables, violates the referential integrity rule?

6. What is the purpose of the Sales-Inventory table?

Romney, M.B. and P.J. Steinbart, Accounting Information Systems, Pearson. 4


Suggested answers

1a. Item #
1b. Invoice Number and Item Number combined together

2 Customer Number

3. Customer table

4. One-to-many relationship

5. If drawn between Sales and Sales-Inventory tables, the relationship will violate the
referential integrity rule. The reason being there is a foreign key value Invoice Number 108
in the Sales- Inventory table but there is no corresponding primary key value in the Sales
table.
I will also treat the answer: between customer and sales tables as correct between there is
a foreign key value Customer Number 1007 in the Sales table but there is no
corresponding primary key value in the Customer table. However, the first answer is
better because in this second answer, the software will not even allow you to finish
creating the Customer table because this table violates the entity integrity rule.

6. This table shows what inventory items appear on what invoices, and the quantity sold and
dollar amount. This table is necessary for data that have many-to-many relationship. In
this problem, the data refers to invoice that have multiple inventory items and inventory
item that appears in multiple invoices.

Romney, M.B. and P.J. Steinbart, Accounting Information Systems, Pearson. 5


Extra Problem

Enter the tables in Table 4-15 into a relational DBMS package. Write queries to answer the
following questions.

a. Which customers (show their names) made purchases from Martinez?


b. Who has the largest credit limit?
c. How many sales were made in October?
d. How much did each salesperson sell?
e. What were the item numbers, price, and quantity of each item sold on invoice number
103?
f. How many customers live in Arizona?
g. How much of each item was sold? (Include the description of each item in your answer.)
h. For which items are there at least 100 units on hand?

Romney, M.B. and P.J. Steinbart, Accounting Information Systems, Pearson. 6


Suggested answers

a. Which customers (show their names) made purchases from Martinez?

Query

Query Result

Romney, M.B. and P.J. Steinbart, Accounting Information Systems, Pearson. 7


b. Who has the largest credit limit?

Query

Query Result

Romney, M.B. and P.J. Steinbart, Accounting Information Systems, Pearson. 8


c. How many sales were made in October?

Query

Query Result

Romney, M.B. and P.J. Steinbart, Accounting Information Systems, Pearson. 9


d. What were the item numbers, price, and quantity of each item sold on invoice
number 103?

Query

Query Result

Romney, M.B. and P.J. Steinbart, Accounting Information Systems, Pearson. 10


e. How much did each salesperson sell?

Query

Query Result

Romney, M.B. and P.J. Steinbart, Accounting Information Systems, Pearson. 11


f. How many customers live in Arizona?

Query

Query Result

Romney, M.B. and P.J. Steinbart, Accounting Information Systems, Pearson. 12


g. How much of each item was sold? (Include the description of each item in your answer.)

Query

Query Result

Romney, M.B. and P.J. Steinbart, Accounting Information Systems, Pearson. 15


h. For which items are there at least 100 units on hand?

Query

Query Result

Romney, M.B. and P.J. Steinbart, Accounting Information Systems, Pearson. 17

You might also like