Chap 4 AIS 44
Chap 4 AIS 44
Relational Databases
1
INTRODUCTION
• Relational databases underlie most
modern integrated AISs.
– They are the most popular type of database
used for transaction processing.
– In this chapter, we’ll define the concept of a
database first.
2
FILE VS. DATABASES
• Let’s examine some basic principles about
how data are stored in computer systems.
– An entity is anything about which the organization
wishes to store data. At your college or university,
one entity would be the student.
– Information about the attributes of an entity (e.g.,
the student’s ID number and birth date) are stored
in fields.
– All the fields containing data about one entity (e.g.,
one student) form a record.
– A set of all related records forms a file (e.g., the
student file). 3
FILE VS. DATABASES
– A set of interrelated, centrally coordinated
files forms a database.
Student Class
File File
Advisor
File
4
Cont…
• The Database Concept
Database
Management
System
5
Cont…
• The database approach treats data as an
organizational resource that should be used by
and managed for the entire organization, not
just a particular department.
• A database management system (DBMS)
serves as the interface between the database
and the various application programs.
6
Cont…
• The combination of the database, the DBMS,
and the application programs that access the
database is referred to as the database
system.
• The person responsible for the database is the
database administrator.
7
IMPORTANCE OF DATABASE SYSTEMS
• Database technology is everywhere.
– Most new AISs implement a database approach.
– Virtually all mainframe computer sites use
database technology.
– Use of databases with PCs is growing also.
8
IMPORTANCE OF DATABASE SYSTEMS
• As accountants, you are likely to audit or work for
companies that use database technology to store,
process, and report accounting transactions.
– Many accountants work directly with databases and will
enter, process, and query databases.
– Some will develop and evaluate internal controls necessary
to ensure database integrity.
– Others will be involved in the design and management of
databases.
9
ADVANTAGES OF DATABASE SYSTEMS
• Database technology provides the following
benefits to organizations:
– Data integration: Achieved by combining master files
into larger pools of data accessible by many programs.
– Data sharing: It’s easier to share data that’s
integrated
– Reporting flexibility: Reports can be revised easily
and generated as needed.
– Minimal data redundancy and inconsistencies:
Because data items are usually stored only once.
10
ADVANTAGES OF DATABASE SYSTEMS
– Data independence: Data items are independent of the
programs that use them. Consequently, a data item can
be changed without changing the program and vice
versa. Makes programming easier and simplifies data
management.
– Central management of data: Data management is
more efficient because the database administrator
is responsible for coordinating, controlling, and
managing data.
– Cross-functional analysis: Relationships can be
explicitly defined and used in the preparation of
management reports. EXAMPLE: Relationship between
selling costs and promotional campaigns. 11
RELATIONAL DATABASES
• Most new DBMSs are called relational
databases because they use the relational
data model developed by E. F. Codd in 1970.
• A data model is an abstract representation of
the contents of a database.
• The relational data model represents
everything in the database as being stored in
the forms of tables (also known as, relations).
12
Cont…
• In a Relational Table
– Each row, a tuple, contains multiple attributes
describing an instance of the entity.
• This is equivalent to a record
– Each column contains data about one
attribute of an entity.
• This is equivalent to a field
13
STUDENTS
Last First Phone
Each row is
Student ID Name Name No. called a tuple.
333-33-3333 Simpson Alice 333-3333
111-11-1111 Sanders Ned 444-4444
123-45-6789 Moore Artie 555-5555
14
STUDENTS Each row
Last First Phone contains data
Student ID Name Name No. about a specific
333-33-3333 Simpson Alice 333-3333 occurrence of
111-11-1111 Sanders Ned 444-4444
the type of
123-45-6789 Moore Artie 555-5555
entity in the
table.
15
STUDENTS Each column in
Last First Phone
Student ID Name Name No.
a table contains
333-33-3333 Simpson Alice 333-3333 information
111-11-1111 Sanders Ned 444-4444 about a specific
123-45-6789 Moore Artie 555-5555 attribute of the
entity.
16
Attributes
• Primary Key
– An attribute or combination of attributes that can be
used to uniquely identify a specific row (record) in a
table.
– For example, Student ID in the students table &
Item Number in the inventory table.
• Foreign Key
– An attribute in one table that is a primary key in
another table.
• Used to link the two tables
17
STUDENTS
Last First Phone
Student ID Name Name No.
333-33-3333 Simpson Alice 333-3333
111-11-1111 Sanders Ned 444-4444
123-45-6789 Moore Artie 555-5555
ADVISORS
Advisor No. Last Name First Name Office No.
1418 Howard Glen 420
1419 Melton Amy 316
1503 Zhang Xi 202
1506 Radowski J.D. 203
ADVISORS
Advisor No. Last Name First Name Office No.
1418 Howard Glen 420
1419 Melton Amy 316
1503 Zhang Xi 202
1506 Radowski J.D. 203
ADVISORS
Advisor No. Last Name First Name Office No.
1418 Howard Glen 420
1419 Melton Amy 316
1503 Zhang Xi 202
1506 Radowski J.D. 203
24
Cont…
• Accountants may provide the greatest value by taking
responsibility for data modeling—the process of defining
a database to faithfully represent all aspects of the
organization, including interactions with the external
environment.
– Occurs during both system analysis and conceptual
design stage.
– Two important tools to facilitate data modeling:
• Entity-relationship diagramming
• REA data model
25
ENTITY-RELATIONSHIP DIAGRAMS
• An entity-relationship (E-R) diagram is a
graphical technique for portraying
(depicting) a database schema (DB Design
in picture).
– Shows the various entities being modeled and
the important relationships among them.
26
Cont…
• An entity is anything about which the
organization wants to collect and store
information.
– Example: Your university collects and stores
information about students, courses, enrollment
activity, etc.
• In a relational database, separate tables
would be created to store information
about each distinct entity.
27
Cont…
• In an E-R diagram, entities are depicted as
rectangles.
• But there are no industry standards for other
aspects of these diagrams.
Enrollment Students
28
Cont…
• Some data modelers, tools, and authors use
diamonds to depict relationships.
Line
Enrollment Items Students
29
Cont…
• Others do not use diamonds.
Enrollment Students
30
Cont…
• Sometimes the attributes associated with each
entity are depicted as named ovals connected to
each rectangle.
Student
Enrollment Student Name
Number Enrollment ID No.
Date
Student
Address
Enrollment
Time
Enrollment Students
31
Cont…
• Sometimes these attributes are listed in a
separate table.
Enrollment Students
34
Cont…
• E-R diagrams can include many different
kinds of entities and relationships.
• An important step in designing a
database is deciding which entities need
to be modeled.
• The REA data model is useful for this
decision.
35
THE REA DATA MODEL
• The REA data model was developed
specifically for use in designing accounting
information systems.
– Focuses on business semantics underlying an
organization’s value chain activities.
– Provides guidance for:
• Identifying the entities to be included in a
database.
• Structuring the relationships among the
entities.
36
Cont…
• REA data models are usually depicted in
the form of E-R diagrams.
37
Cont…
• Three basic types of entities
– The REA data model is so named because it classifies
entities into three distinct categories:
• Resources that the organization acquires and uses.
Resources are things that have economic value to the
organization.
• Events in which the organization engages. These are the
various business activities about which management wants
to collect information for planning or control purposes.
• Agents participating in these events. Includes people and
organizations who participate in events and about whom
information is desired for planning, control, and evaluation
purposes.
38
Cont…
• Can you identify the resources in this diagram?
• Can you identify the events in this diagram?
• Can you identify the agents in this diagram?
Inventory Sales Employee
Customer
Cash Receive
Employee
Accounts Cash
39
Cont…
• Structuring relationships: The basic REA
template
– The REA data model prescribes a basic
pattern for how the three types of entities
(resources, events, and agents) should
relate to one another.
40
Cont…
• Rule 1: Each event is linked to at least one resource
that it affects.
Resource A Event A
Resource B Event B
41
Cont…
• Rule 2: Each event is linked to at least one other
event.
Resource A Event A
Resource B Event B
42
Cont…
• Rule 3: Each event is linked to at least two
agents.
Agent B
44
STEP ONE: IDENTIFY RELEVANT EVENTS
• At a minimum, every REA model must include the
two events that represent the basic “give-to-get”
economic exchange performed in that transaction
cycle.
• The give event reduces one of the organization’s
resources.
• The get event increases a resource.
• There are usually other events that management is
interested in planning, controlling, and monitoring.
These should be included in the model.
45
Cont…
47
Cont…
Take customer order Bill customer
• Taking an order requires • Printing and mailing invoices
that we set resources aside. does not directly affect an
• That information should be economic resource.
• It does not represent a
included in our model.
commitment on the part of the
company to a future exchange.
• It is an information retrieval
event and should not alter the
contents of the database.
• Does not need to be included
in the model.
48
Cont…
• In completing the first step of an REA diagram,
the event entities are typically drawn from top
to bottom in the sequence in which they
normally occur.
49
Cont…
Take Order
Sale
Receive
Cash
50
STEP TWO: IDENTIFY RESOURCES AND
AGENTS
• When the relevant events have been
diagrammed in the center of the REA diagram,
the resources that are affected by those
events need to be identified.
• Involves determining:
– The resource(s) reduced by the give event.
– The resource(s) increased by the get event.
– The resources that are affected by a commitment
event.
51
Cont…
• In order to identify the resources that are affected by the
relevant events identified above the following questions may be
raised:
– What is the give event?
Sale
– What resource is reduced by the give event?
Inventory
– What is the get event?
Receive Cash
– What resource is increased by the get event?
Cash
– Is there a commitment event?
Take Order
– What resource is affected by the commitment event?
Inventory 52
Cont…
Take Order
Inventory
Sale
Receive
Cash
Cash
53
Cont…
• The agents who participate in each event
should also be identified.
– There will always be at least one internal agent
(employee).
– In most cases, there will also be an external
agent (e.g., customer or supplier) who
participates.
54
Cont…
• In order to identify the agents who participate
in each event identified above the following
questions may be raised:
– What agents are involved in the sale?
Employee and Customer
– What agents are involved in the receipt of cash?
Employee and Customer
– What agents are involved in taking the order?
Employee and Customer
55
Cont…
Inventory
Customer
Sale
Employee
Receive
Cash Customer
Cash
56
STEP THREE: DETERMINE CARDINALITIES
OF RELATIONSHIPS
• The final step in an REA diagram for a transaction cycle is
to add information about the relationship cardinalities.
• A cardinality describes the nature of the relationship
between two entities.
– It indicates how many instances of one entity can be linked
to a specific instance of another entity.
– For example, the cardinality between the event Sales and
the agent Customer answers the question:
• For each sale a company makes, how many customers
are associated with that sale?
57
Cont…
• Unfortunately, there is no universal standard
for diagramming cardinalities.
• In this chapter, we adopt the graphical “crow’s
feet” notation style because:
– It is becoming increasingly popular.
– It is used by many software design tools.
58
Cont…
• Using the crow’s feet notation:
– The symbol for zero is a circle: O
– The symbol for one is a single stroke: |
– The symbol for many is the crow’s foot:
59
Cont…
• There is typically a minimum and maximum
cardinality for each entity participating in a
relationship.
– The minimum cardinality can be either zero or
one.
– The maximum cardinality can be either one or
N (many).
60
Cont…
• Three types of relationships
– Three types of relationships are possible
between entities.
– Relationships depend on the maximum
cardinality on each side of a relationship.
61
Cont…
• A one-to-one relationship (1:1) exists when the maximum cardinality for each
entity in the relationship is one.
Take Order
Sale
62
Cont…
• A one-to-many (1:N) relationship exists when the maximum cardinality
on one side is one and the maximum on the other side is many.
Sale Customer
63
Cont…
• A many-to-many (M:N) relationship exists when the maximum on both
sides is many.
Inventory Sale
64
Cont…
• It is not a “one size fits all” world for
relationships and cardinalities. The
cardinalities between two entities can vary
based on how the particular company does
business.
• Let’s look at some examples.
65
Cont…
• Customers pay for
Sale each sale with a
maximum of one
payment (typical for
retail stores).
• Each cash receipt
from a customer
relates to one (and
Cash only one) sale.
• The relationship
Receipt
between sales and
cash receipts is
1:1.
66
Cont…
• Customers pay for
Sale each sale with a
maximum of many
payments
(installments).
• Each cash receipt
from a customer
relates to one (and
Cash only one) sale.
• The relationship
Receipt
between sales and
cash receipts is
1:N.
67
Cont…
• Customers make
Sale only one payment
for a sale.
• Each cash receipt
from a customer
can relate to
multiple sales (e.g.,
they pay for all
Cash sales that month in
one payment).
Receipt
• The relationship
between sales and
cash receipts is
1:N.
68
Cont…
• Customers may
Sale make multiple
payments for a
particular sale.
• A cash receipt from
a customer may
relate to more than
one sale.
Cash • The relationship
Receipt between sales and
cash receipts is
M:N.
69
Cont…
70
Cont…
• Now let’s go back to the REA diagram for the
revenue cycle and see if we can complete the
cardinalities.
71
Cont…
• In relationships between events and agents:
– For each event that occurs, the cardinality
between event and agent is typically (1:1).
– Example: When a sale occurs:
• There is usually one and only one customer.
• There is usually one and only one salesperson.
This practice makes it more feasible for the
organization to establish employee
accountability for the event.
72
Cont…
Inventory
Customer
Sale
Employee
Receive
Cash Customer
Cash
73
Cont…
• For each agent the cardinality between agent
and event is typically (0:N).
– Example: For a particular salesperson:
• There is typically a minimum of zero sales (allows for
inclusion of a new salesperson who has not yet made
any sales).
• A salesperson can have a maximum of many sales.
– Or: For a particular customer:
• There is typically a minimum of zero sales (to allow for
the inclusion of prospective customers who haven’t
bought anything yet) and a maximum of many sales.
74
Cont…
Inventory
Customer
Sale
Employee
Receive
Cash Customer
Cash
75
Cont…
• Let’s now look at the relationship between
events and resources.
– In the cardinality between event and resource,
the minimum cardinality is typically one, because
an event can’t occur without affecting at least
one resource.
76
Cont…
Inventory
Customer
Sale
Employee
Receive
Cash Customer
Cash
77
Cont…
• The maximum could be one or many.
– In this particular story, each sale can involve
many items of inventory, so the maximum is
many.
– However, every receipt of cash is deposited to
one and only one cash account, so the
maximum there is one.
78
Cont…
Inventory
Customer
Sale
Employee
Receive
Cash Customer
Cash
79
Cont…
• In the cardinality between resource and
event, the minimum is typically zero.
– A company can have an inventory item for
which there has never been a sale.
– When the company’s cash account is new,
there has never been a cash receipt deposited
in it.
80
Cont…
Inventory
Customer
Sale
Employee
Receive
Cash Customer
Cash
81
Cont…
• In the cardinality between resource and
event, the maximum is typically many.
– Most inventory items can be sold many times. (An
exception might occur if each inventory item is
one unique item, such as a piece of real estate.)
– The company’s cash account can have many cash
receipts.
82
Cont…
Inventory
Customer
Sale
Employee
Receive
Cash Customer
Cash
83
Cont…
• Finally, let’s look at the relationships between events.
• When events occur in a sequence, the minimum
cardinality between the first event and the second
event is always zero, because there is a span of time
(although possibly quite short) when the first event has
occurred but there are zero occurrences of the second
event.
• Examples:
– When an order is first taken, there have been no
deliveries of goods (sale event) to the customer.
– When goods are delivered to the customer, there is a
span of time, however brief, in which there is no cash
receipt from the customer.
84
Cont…
Inventory
Customer
Sale
Employee
Receive
Cash Customer
Cash
85
Cont..
• The minimum cardinality between the second
event and the first event is typically one,
because the second event can’t occur without
the first event having occurred.
86
Cont…
Inventory
Customer
Sale
Employee
Receive
Cash Customer
Cash
87
Cont…
• The maximums in the cardinalities between
events can be either one or many, and these
maximums vary based on business practices.
• We saw this when we looked at the four
different possibilities for the relationships
between sales and cash receipts previously.
• On the following slides, see if you can explain
the maximums between the three events.
88
Cont…
Inventory
Customer
Sale
Employee
Receive
Cash Customer
Cash
89
Cont…
• Uniqueness of REA diagrams
– Each organization will have its own unique REA
diagram.
• Business practices differ across companies, so
cardinalities and relationships will differ.
• A given organization can change business practices,
leading to a change in its REA diagram:
– A change in practice could cause a change in
cardinalities.
– Could even lead to the inclusion of different entities
on the diagram.
90
Cont…
• Data modeling can be complex and repetitive.
– Data modelers must discuss their drafts of models
with intended users to ensure that:
• Key dimensions are not omitted or misunderstood.
• Terminology is consistent.
91
DATABASE SYSTEMS AND THE FUTURE OF
ACCOUNTING
• Database systems may profoundly affect the
fundamental nature of accounting:
– May lead to abandonment of double-entry
accounting, because the redundancy of the
double entry is not necessary in computer data
processing.
– May also alter the nature of external reporting.
• EXAMPLE: External users could have access to the
company’s database and manipulate the data to meet
their own reporting needs.
92
Cont…
• The use of accounting information in decision
making will be enhanced by:
– Powerful querying capabilities that accompany
database packages.
– The ability to accommodate multiple views of the
same underlying phenomenon.
– The ability to integrate financial and operational
data.
93
Cont…
• Accountants must become knowledgeable
about databases so they can participate in
developing the AIS of the future.
• They must help ensure that adequate controls
are included to safeguard the data and assure
its reliability.
94
The End!
95