Page 28 - AIS access_chang_ingraham
P. 28
26 CHAPTER 2 DATA MODELS AND RELATIONAL DATABASES
Purchase Table (Purchase #, Purchase Date, Purchase Amount)
Cash Disbursement Table (Check #, Check Date, Payment Amount)
Artist Table (Artist ID, Artist Name, Artist Address, Artist phone #, Artist Email)
Customer Table (Customer ID, Customer Name, Customer Address, Customer
City, Customer State, Customer ZIP Code, Customer Phone #,
Customer Email)
Purchase-Cash Disbursement Table (Purchase #, Check #)
Step 5: Implement relationships using foreign keys.
The last step is to link tables using foreign keys. In our table structure, we use a single
underline to indicate a foreign key. If there are necessary tables with a one-to-one rela-
tionship (those that should not be collapsed into one table), it does not matter which table's
primary key becomes the foreign key in the other table but do not post both primary keys
as foreign keys.
However, the primary key of the table with a one-to-many relationship always
becomes the foreign key in the (1,1) entity's table. That way, we can make sure that each
attribute of a record is single-valued for both tables. For example, to link the Artist
Table with the Purchase Table, we add Artist ID to the Purchase Table as a foreign key,
since each purchase transaction involves only one artist. The revised table structure of
the Purchase Table is as follows: Purchase Table (Purchase #, Purchase Date, Purchase
Amount, Artist ID). After determining the proper foreign keys, other revised table struc-
tures are listed as follows:
Inventory Table (Item #, Inventory Description, Inventory Cost, Purchase #, Sale #)
Sale Table (Sale #, Sale Date, Sale Amount, Payment Type, Customer ill, Account #)
Cash Disbursement Table (Check #, Disbursement Date, Payment Amount,
Artist ID, Account #)
The revised REA diagram, with table structures, is presented in Figure 2-6.
Purchase Inventory
Artist/Seller Sale
Cash
(Bank Account)
FIGURE 2-6 Cherokee's Revised REA Data Model

