CHAPTER 3
DATA MODELING
AND
DATABASE DESIGN
09/23/22
Learning Objectives
2
Discuss the steps for designing and
implementing a database system.
Use the REA data model to design an AIS
database.
Draw an Entity-Relationship (E-R)
diagram of an AIS database.
Build a set of tables to implement an REA
model of an AIS in a relational database.
Read an E-R diagram and explain what it
reveals about the business activities and
policies of the organization being modeled.
09/23/22
Designing and Implementing a Database System
3
Six basic steps in designing and
implementing a database system:
1. Initial planning to determine the need for and
feasibility of developing a new system
(planning stage).
2. Identifying user needs (requirements analysis
stage).
3. Developing the contextual-, external-and
internal- level schemas (design stage).
09/23/22
Designing and Implementing a Database System
4
4. Translating the internal-level schema into the actual
database structures that will be implemented in the new
system (coding stage).
5. Transferring all data from the existing system to the new
database (implementation stage).
6. Using and maintaining the new system (operation and
maintenance stage).
09/23/22
The REA Data Model
5
Data modeling is the process of defining
a database so that it faithfully represents
all aspects of the organization, including
its interactions with the external
environment.
The REA (Resources, Events, Agents)
data model is a conceptual modeling tool
that focuses on the business semantics
underlying an organization’s value chain
activities.
09/23/22
The REA Data Model
6
Data Modeling in the database Design Process
Operation and
Planning
maintenance
Requirements
Data Implementation
modelin analysis
g occurs
here
Design Coding
09/23/22
The REA Data Model
7
The REA data model provides structure in
two ways:
1 By identifying what entities should be
included in the AIS database
2 By prescribing how to structure
relationships among the entities in the
AIS database
09/23/22
Types of Entities
8
An entity is any class of objects about which data is
collected.
The REA data model classifies entities into three
distinct categories:
1 Resources acquired and used by an organization
2 Events engaged in by the organization
3 Agents participating in these events
09/23/22
Types of Entities
9
Resources are defined as those things that have
economic value to the organization.
What are some examples?
cash
inventory
equipment
09/23/22
Types of Entities
10
Events are the various business activities about
which management wants to collect information for
planning or control purposes.
What are some examples?
sales events
taking customer orders
09/23/22
Types of Entities
11
Agents are the third type of entity in the REA model.
Agents are the people and organizations that
participate in events and about whom information is
desired.
What are some examples?
employees
customers
09/23/22
Developing an REA Diagram
12
Developing an REA diagram for a specific
transaction cycle consists of four steps:
1 Identify the pair of events that represent the basic
give-to-get economic duality relationship in that
cycle.
2 Identify the resources affected by each event and the
agents who participate in those events.
09/23/22
Developing an REA Diagram
13
Four steps (continued):
3. Analyze each economic exchange event to
determine whether it should be decomposed
into a combination of one or more
commitment events and an economic exchange
event. If necessary, replace the original
economic exchange event with the resulting set
of commitment and economic exchange events.
4. Determine the cardinalities of each
relationship.
09/23/22
Basic REA template
14
Resource A GET
Inflow Participant Internal Agent
Resource A
Participant External Agent
Economic
Duality
Participant External Agent
GIVE
Resource B Outflow Participant Internal Agent
Resource B
09/23/22
Sample REA diagram
15
Inventory Stock-flow Sales Participant Salesperson
Participant
Economic
Customer
Duality
Participant
Cash
Cash Stock-flow Participant Cashier
Receipts
09/23/22
REA Diagram, Step 1:
Identify Economic Exchange Events
16
In drawing an REA diagram for an individual cycle,
it is useful to divide the paper into three columns,
one for each type of entity.
Left column should be used for resources.
Middle column should be used for events.
Right column should be used for agents.
09/23/22
REA Diagram, Step 1:
Identify Economic Exchange Events
17
The basic economic exchange in the revenue cycle
involves the sale of goods or services and the
subsequent receipt of cash in payment for those
sales.
The REA diagram for revenue cycle shows the
drawing of sales and cash receipts events entities as
rectangles and the relationship between them as a
diamond.
09/23/22
REA Diagram, Step 2:
Identify Resources and Agents
18
Once the events of interest have been specified, the
resources that are affected by those events need to be
identified.
The sales event involves the disposal of inventory.
The cash receipts event involves the acquisition of
cash.
09/23/22
REA Diagram, Step 2:
Identify Resources and Agents
19
After specifying the resources affected by each event,
the next step is to identify the agents who participate
in those events.
There will always be at least one internal agent
(employee) and, in most cases, an external agent
(customer).
09/23/22
REA Diagram, Step 3:
Include Commitment Events
20
The third step in drawing an REA diagram is
analyzing each economic exchange event to
determine whether it can be decomposed into a
combination of one or more commitment exchange
events.
Example: The sales event may be decomposed into
the “take order” commitment event and the
“deliver order” economic exchange event
09/23/22
Decomposing Sales into Orders and Sales
21
Customer
Inventory- (1,N) (1,1) Participant (0,N) Customer
Orders
Orders
(0,N) (1,1)
(0,1) Participant
(0,N)
Inventory- Leads to
Inventory (0,N) Salesperson
Sales (0,N)
(0,1)
(1,N)
Participant
(1,1)
Sales
(1,1) Participant (0,N) Customer
09/23/22
REA Diagram, Step 4:
Determine Cardinalities
22
Cardinalities indicate how many instance of one
entity can be linked to one specific instance of
another entity.
Cardinalities are often expressed as a pair of
numbers.
The first number is the minimum, and the second
number is the maximum.
09/23/22
REA Diagram, Step 4:
Determine Cardinalities
23
The minimum cardinality of a relationship
indicates whether each row in that entity MUST be
linked to a row in the entity on the other side of the
relationship.
Minimum cardinalities can be either 0 or 1.
A minimum cardinality of zero means that a new
row can be added to that table without being linked
to any rows in the other table.
A minimum cardinality of 1 means that each row in
that table MUST be linked to at least one row in the
other table
09/23/22
REA Diagram, Step 4:
Determine Cardinalities
24
The minimum cardinality of zero in the (0, N)
cardinality pair to the left of the customer entity in
the customer-sales relationship indicates that a new
customer may be added to the database without
being linked to any sales events.
(0, N)
Sales Made to Customer
09/23/22
REA Diagram, Step 4:
Determine Cardinalities
25
The minimum cardinality of 1 in the (1, 1) cardinality
pair to the right of the sales entity in the customer-
sales relationship indicates that a new sales
transaction CAN ONLY be added if it is linked to a
customer.
(1,1) (0, N)
Sales Made to Customer
09/23/22
REA Diagram, Step 4:
Determine Cardinalities
26
The maximum cardinality of a relationship
indicates whether each row in that entity CAN be
linked to more than one row in the entity on the
other side of the relationship.
Maximum cardinalities can be either 1 or N.
Maximum cardinality of 1 means that each row in
that table can be linked to at most only 1 row in the
other table.
A maximum cardinality of N means that each row
in that table MAY be linked to more than one row
in the other table.
09/23/22
REA Diagram, Step 4:
Determine Cardinalities
27
The maximum cardinality of N in the (0, N)
cardinality pair to the left of the customer entity in
the customer-sales relationship indicates that a given
customer MAY be linked to many sales events.
(0, N)
Sales Made to Customer
09/23/22
REA Diagram, Step 4:
Determine Cardinalities
28
The maximum cardinality of 1 in the
(1, 1) cardinality pair to the right of the sales entity in
the customer-sales relationship indicates that a given
sales transaction can only be linked to one customer.
(1,1) (0, N)
Sales Made to Customer
09/23/22
REA Diagram, Step 4:
Determine Cardinalities
29
Cardinalities are not arbitrarily chosen by the
database designer.
They reflect facts about the organization being
modeled and its business practices obtained during
the requirements analysis stage of the database
design process.
09/23/22
Relationships
between Entities
30
Three basic types of relationships between entities
are possible, depending on the maximum
cardinality associated with each entity. They are:
1. A one-to-one relationship (1:1)
2. A one-to-many relationship (1:N)
3. A many-to-many relationship (M:N)
09/23/22
Different types of relationships
31
Panel A: One-to-One (1:1) Relationship
Cash
Sales (0,1) (1,1)
Receipts
09/23/22
Different types of relationships
32
Panel B: One-to-Many (1:N) Relationship
Cash
Sales (0,N) (1,1)
Receipts
09/23/22
Different types of relationships
33
Panel C: One-to-Many (1:N) Relationship
Cash
Sales (0,1) (1,N)
Receipts
09/23/22
Different types of relationships
34
Panel D: Many-to-Many (M:N) Relationship
Cash
Sales (0,N) (1,N)
Receipts
09/23/22
Entity-Relationship Diagram
35
An Entity-Relationship (E-R) diagram is one
method for portraying a database schema.
It is called an E-R diagram because it shows the
various entities being modeled and the important
relationships among them.
In an E-R diagram, entities appear as rectangles,
and relationships between entities are represented
as diamonds.
09/23/22
Sample E-R Diagrams
36
Managed
Employers By
Supervisors
Part of
Manages
Departments
Customer Part of Cash
Orders
Sales Part of
Receipts
Players Part of Teams Part of League
09/23/22
Sample E-R Diagram based on REA model
37
Inventory Inventory- Buyer
(0,N) (1,N) Purchases (1,1) Participant (0,N)
Purchases (Purchasing Agent)
(0,N) (1,1)
Participant
(0,N)
Purchases-
Cash Vendor
Disbursements
Participant (0,N)
(1,N) (1,1)
Cash
Cash (0,N) Stockflow (1,1) (1,1) Participant (0,N) Cashier
Disbursement
09/23/22
Implementing an
38 REA Diagram in a
Relational Database
An REA diagram can be used to design a
well-structured relational database.
A well-structured relational database is
one that is not subject to update, insert,
and delete anomaly problems.
09/23/22
Implementing an REA Diagram in a
Relational Database
39
Implementing an REA diagram in a
relational database is a three-step
process:
1. Create a table for each distinct entity and for each many-to
many relationship
2. Assign attributes to appropriate tables
3. Use foreign keys to implement one-to-one and one-to-
many relationships
09/23/22
Implementing an REA model
40
Inventory Inventory- Buyer
(0,N) (1,N) Purchases (1,1) Participant (0,N)
Purchases (Purchasing Agent)
(0,N) (1,1)
Participant
(0,N)
Purchases-
Cash Vendor
Disbursements
Participant (0,N)
(1,N) (1,1)
Cash
Cash (0,N) Stockflow (1,1) (1,1) Participant (0,N) Cashier
Disbursement
09/23/22
Create Tables
41
From the previously discussed REA diagram, nine
tables would be created: one for each of the seven
entities and one for each of the 2 many-to-many
relationships.
1. Inventory 6. Cash
disbursements
2. Purchases
7. Cash
3. Employees
8. Purchases-
4. Vendors inventory
5. Cashier 9. Purchases-cash
disbursements
09/23/22
Assign Attributes
for Each Table
42
Primary keys: Usually, the primary key of a table
representing an entity is a single attribute.
Other Attributes: Additional attributes are included
in each table to satisfy transaction processing
requirements.
09/23/22
Implement One-to-One and One-to-Many
Relationships
43
One-to-One Relationships: In a relational database,
one-to-one relationships between entities can be
implemented by including the primary key of one
entity as a foreign key in the table representing the
other entity.
09/23/22
Implement One-to-One and One-to-Many
Relationships
44
One-to-Many Relationships: In a relational
database, one-to-many relationships can be also
implemented in relation to databases by means of
foreign keys.
The primary key of the entity with the maximum
cardinality of N becomes a foreign key in the entity
with a maximum cardinality of 1
Examples: Employee number and vendor number
are foreign keys in the purchases event and in the
cash disbursement event
09/23/22
Documentation of
Business Practices
45
REA diagrams are especially useful for documenting
an advanced AIS built using databases.
REA diagrams provide information about the
organization’s business practices
09/23/22
Documentation of
Business Practices
46
The zero minimum for the sales event indicates that
credit sales are made
The N maximum for the sales event means that
customers may make installment payments
Cash Sales-
(1, N) Cash Receipts (0, N) Sales
Receipts
09/23/22
Documentation of
Business Practices
47
The one minimum for the cash receipts
event indicates that cash is not received
prior to delivering the merchandise
The N maximum for the cash receipts
event means that customers may pay for
several sales with one check
Cash Sales-
(1, N) Cash Receipts (0, N) Sales
Receipts
09/23/22
Organization Specificity
of REA Diagrams
48
Due to the fact that company sells mass-produced
goods, its REA diagram models the relationship
between sales and inventory as being many-to-many.
An REA diagram for a rare art dealer would depict
the relationship between sales and inventory as
being one-to-many.
09/23/22
Extracting Information
From the AIS
49
A complete REA diagram serves as a useful guide for
querying an AIS database.
Queries can be used to generate journals and ledgers
from a relational database built on the REA model.
09/23/22
Extracting Information
From the AIS
50
(0, 1) (1, N) Cash
Sales collections
Each sales transaction is paid in full by a cash
collection event.
Each customer payment may be for more than
one sale.
What is the query logic?
Total accounts receivable is the sum of all
sales for which there is no remittance number.
09/23/22
Extracting Information
From the AIS
51
(0, N) (1, 1) Cash
Sales collections
Each sales transaction can be paid in
installments.
Each customer payment is for just one sale.
What is the query logic?
(1) sum all sales; (2) sum cash collections;
then A/R = (1)-(2)
09/23/22
Extracting Information
From the AIS
52
(0, 1) (1, 1) Cash
Sales collections
Each sales transaction is paid in full by a cash
collection event.
Each customer payment is for one sale.
What is the query logic?
Total accounts receivable is the sum of all
sales for which there is no remittance number.
09/23/22
Extracting Information
From the AIS
53
(0, N) (1, N) Cash
Sales collections
Each sales transaction may be paid for in
installments.
Each customer payment may be for more than
one sale.
What is the query logic?
(1) Sum all sales; (2) Sum all cash collections;
Then A/R = (1)-(2)
09/23/22
54
THE END OF
CHAPTER 3
09/23/22