Chapter Four - Problems and Answers: Problem 4.3
Chapter Four - Problems and Answers: Problem 4.3
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
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.
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
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
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?
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.
Enter the tables in Table 4-15 into a relational DBMS package. Write queries to answer the
following questions.
Query
Query Result
Query
Query Result
Query
Query Result
Query
Query Result
Query
Query Result
Query
Query Result
Query
Query Result
Query
Query Result