Accounting Information System Chapter Four - Relational Databases
Accounting Information System Chapter Four - Relational Databases
Chapter 4
1
Types of Files
Two basic types of files are used to store
data.
1 The transaction file, which is
conceptually similar to a journal in a
manual system.
2 The master file, which is conceptually
similar to a ledger in a manual system.
2
File Approach
For many years, companies created new files
and programs each time an information need
arose.
This proliferation of master files created
problems:
1 Often the same data was stored in two or
more separate files.
2 The specific data values stored in the different
files were not always consistent.
3
File-Oriented Approach
File 1
Fact A Sales
Fact B Program
Fact C
File 2
Fact B Shipping
Fact D Program
Fact E
File 3
Fact A Billing
Fact G Program
Fact E 4
Databases
The database approach views data as an
organizational resource that should be used by,
and managed for, the entire organization, not
just the originating department or function.
Its focus is data integration and data sharing.
Integration is achieved by combining master
files into larger pools of data that can be
accessed by many application programs.
5
Databases
Database management system (DBMS)
is the program that manages and
controls access to the database.
Database system is the combination of
the database, the DBMS, and the
application program that uses the
database.
Database administrator (DBA) is the
person responsible for the database.
6
Database Approach
Fact A
Database
Fact B Shipping
management
Program
Fact C system
Fact D
Fact E Billing
Program
7
Relational Databases
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 form of tables.
Technically, these tables are called
relations.
8
Relational Databases
Each row in a relation, called a tuple,
contains data about a specific
occurrence of the type of entity
represented by that table.
9
Logical and Physical
Views of Data
A major advantage of database systems
over file-oriented systems is that the
database systems separate the logical
and physical view of data.
What is the logical view?
It is how the user or programmer
conceptually organizes and understands the
data.
10
Logical and Physical
Views of Data
What is the physical view?
Itrefers to how and where the data are
physically arranged and stored on disk,
tape, CD-ROM, or other media.
The DBMS controls the database so that
users can access, query, or update it
without reference to how or where the
data are physically stored.
11
Logical and Physical
Views of Data
Program-data independence is the
separation of the logical and physical
views of data.
12
Schemas
A schema describes the logical structure
of a database.
There are three levels of schemas:
1 Conceptual-level schema
2 External-level schema
3 Internal-level schema
13
Schemas
14
The Data Dictionary
The data dictionary contains information
about the structure of the database.
For each data element stored in the
database, such as the customer number,
there is a corresponding record in the
data dictionary describing it.
15
The Data Dictionary
The data dictionary is often one of the
first applications of a newly implemented
database system.
What are some inputs to the data
dictionary?
– records of any new or deleted data
elements
– changes in names, descriptions, or uses of
existing data elements
16
The Data Dictionary
What are some outputs of the data
dictionary?
– reports useful to programmers, database
designers, and users of the information
system
What are some sample reports?
– lists of programs in which a data item is used
– lists of all synonyms for the data elements in
a particular file
17
DBMS Languages
18
DDL Language
Thedata definition language (DDL) is
used to...
– build the data dictionary.
– initialize or create the database.
– describe the logical views for each
individual user or programmer.
– specify any limitations or constraints on
security imposed on database record or
fields.
19
DML Language
The data manipulation language (DML)
is used for data maintenance.
What does it include?
– updating portions of the database
– inserting portions of the database
– deleting portions of the database
20
DQL Language
The data query language (DQL) is used
to interrogate the database.
The DQL retrieves, sorts, orders, and
presents subsets of the database in
response to user queries.
21
Basic Requirements of the
Relational Data Model
1. Each column in a row must be single valued.
2. Primary keys cannot be null.
3. Foreign keys, if not null, must have values
that correspond to the value of a primary key
in an other relation.
4. All non-key attributes in a table should
describe a characteristic about the object
identified by the primary key.
22
Anomalies That May Occur in Non-
Normalized Relational Tables
Update Anomaly: When changes
(updates) to data values are not
correctly recorded.
Instead of having to update once, each
record in the single table has to be updated
individually in order to avoid inconsistencies
in the database.
23
Anomalies That May Occur in Non-
Normalized Relational Tables
Insert Anomaly: There is no way to
store information about one entity in the
database without it being associated
with another entity
In the text, we would not be able to store
information on new customers without their
being associated with transactions first!
24
Anomalies That May Occur in Non-
Normalized Relational Tables
Delete Anomaly: Unintended results
arising from deleting a row of data
pertaining to one entity and resulting in
the deletion of data regarding another
entity as well.
Inthe text, if a particular Inventory item were
discontinued and hence removed from the
database table, we would lose information on
the customer associated with that inventory
item as well.
25
Approaches to
Database Design
Normalization
Starts with the assumption that all data is initially
stored in a large non-normalized table.
This table is then decomposed using a set of
normalization rules to create a set of tables in the
Normal Form.
Semantic Data Modeling
The database designer uses his/her knowledge
about the business structure to create a set of
relational tables.
26
Database Systems and the
Future of Accounting
Database systems have the potential to
significantly change the nature of
external reporting.
Perhaps the most significant effect of
database systems will be in the way that
accounting information is used in
decision making.
Explain it more?
27
Designing and Implementing a
Database System
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).
28
Designing and Implementing a
Database System
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).
29
The REA Data Model
30
The REA Data Model
Operation and
Planning
maintenance
Data Requirements
modelin Implementation
analysis
g occurs
here
Design Coding
31
The REA Data Model
32
Types of Entities
33
Types of Entities
Resources are defined as those things
that have economic value to the
organization.
What are some examples?
– cash
– inventory
– equipment
34
Types of Entities
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
35
Types of Entities
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
36
Developing an REA Diagram
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.
37
Developing an REA Diagram
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.
38
Basic REA template
Resource A GET
Inflow Participant Internal Agent
Resource A
Economic
Duality
GIVE
Resource B Outflow Participant Internal Agent
Resource B
39
Sample REA diagram
Participant
Economic
Customer
Duality
Participant
Cash
Cash Stock-flow Participant Cashier
Receipts
40
REA Diagram, Step 1:
Identify Economic Exchange Events
41
REA Diagram, Step 1:
Identify Economic Exchange Events
42
REA Diagram, Step 2:
Identify Resources and Agents
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.
43
REA Diagram, Step 2:
Identify Resources and Agents
Afterspecifying 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).
44
REA Diagram, Step 3:
Include Commitment Events
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
45
Decomposing Sales into Orders and Sales
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
46
REA Diagram, Step 4: Determine Cardinalities
47
Continued…
(0, N)
Sales Made to Customer
49
Continued…
(1,1) (0, N)
Sales Made to Customer
50
Continued…
(0, N)
Sales Made to Customer
52
Continued…
(1,1) (0, N)
Sales Made to Customer
53
Continued…
54
Relationships between Entities
55
Different types of relationships
Cash
Sales (0,1) (1,1)
Receipts
56
Different types of relationships
Cash
Sales (0,N) (1,1)
Receipts
57
Different types of relationships
Cash
Sales (0,1) (1,N)
Receipts
58
Different types of relationships
Cash
Sales (0,N) (1,N)
Receipts
59
Entity-Relationship Diagram
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.
60
Sample E-R Diagrams
Managed
Employers By
Supervisors
Part of
Manages
Departments
61
Sample E-R Diagram based on REA model
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
62
Implementing an 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.
63
Implementing an REA Diagram in a
Relational Database
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
64
Implementing an REA model
(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
65
Create Tables
From the previously discussed REA diagram, nine
tables would be created: one for each of the seven
entities and one for each of the 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
66
Assign Attributes for Each Table
67
Implement One-to-One and One-to-
Many Relationships
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.
68
Implement One-to-One and
One-to-Many Relationships
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
69
Documentation of Business Practices
70
Documentation of Business Practices
Cash Sales-
(1, N) Cash Receipts (0, N) Sales
Receipts
71
Documentation of Business Practices
Cash Sales-
(1, N) Cash Receipts (0, N) Sales
Receipts
72
Extracting Information From the AIS
73
Extracting Information From the AIS
75
Extracting Information
From the AIS
76
Extracting Information
From the AIS
78