Page 27 - AIS access_chang_ingraham
P. 27

RELATIONAL DATABASES     25




                                    information, you would include Customer ID in the table as a foreign key but since
                                    neither customer address nor phone number is a characteristic of the cash receipt
                                    event, they must not be included in the Cash Receipt Table.

                              The sequence of attributes or records in a table is of no importance.

                              Steps of Implementing an REA
                              Diagram in a Relational Database

                              We will use the same example in Chapter 1, Cherokee Art and Antique Store, to illustrate
                              how to implement an REA diagram in a relational database.

                              Step 1:   Create a table for each entity.
                              According to Cherokee's REA data model in Figure 2-2, we need to create the following
                              eight tables for the entities: Inventory Table, Cash Table, Sale Table, Cash Receipt Table,
                              Purchase Table, Cash Disbursement Table, Artist Table, and Customer Table. Note that the
                              title of each table should be the same as the name of the entity it represents, so it is easy
                              to refer back to the original data model design.
                              Step 2:   Create a table for each many-to-many relationship.
                              One relationship table is needed for the many-to-many relationship between the events
                              of "Purchase" and "Cash Disbursement" (i.e., Duality 1). To make it easy to understand,
                              we name this relationship table Purchase-Cash Disbursement. In addition, the name of
                              the relationship on the REA diagram should also be renamed as Purchase-Cash
                              Disbursement.

                              Step 3:   Examine tables with a one-to-one relationship.
                              We need to examine the entities with a one-to-one relationship carefully because they often
                              should be collapsed into one entity. Since all sales are paid for immediately in cash,
                              Cherokee has a one-to-one relationship between the events "Sales" and "Cash Receipt."
                              The sales data Cherokee might need would include a primary key (e.g., sales invoice num-
                              ber), sales date (which would be the same as cash receipt date), dollar amount, and type of
                              payment such as cash, check, or credit card. Therefore, we can collapse the two tables into
                              one table called Sales Table. When such a decision has been made, Cherokee's REA model
                              should be modified accordingly.
                              Step 4:   Identify the attributes and assign the primary key for each table.
                              There are several ways to present a table structure. The table structure adopted here is a
                              simple form in which a table's attributes are enclosed in parentheses following the table
                              name and a double underline indicates the primary key column(s).6 Based on Cherokee's
                              REA data model, its table structures are listed as follows:
                                                                     , ,
                                                                     #'''t
                                 Inventory Table (Item #, Inventory Description, Inventory Cost)
                                 Cash Table (Account #, Account Type, Balance)
                                 Sales Table (Sale #, Sale Date, Sale Amount, Payment Type)





                              6There are other conventions for indicating keys. For example, a primary key and a foreign key could be
                              identified using a single underline and an asterisk, respectively.
   22   23   24   25   26   27   28   29   30   31   32