You are on page 1of 59

Chapter 9

Database
Management
Systems

Accounting Information
Systems 9e
James A. Hall
© 2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in
whole or in part, except for use as permitted in a license distributed with a certain product or
service or otherwise on a password-protected website for classroom use.
Objectives for Chapter 9
• Understand operational problems inherent in the flat-file
approach to data management that gave rise to the database
concept.
• Understand the relationships among the defining elements of
the database environment.
• Understand the anomalies caused by unnormalized databases
and the need for data normalization.
• Be familiar with stages in database design, including entity
identification, data modeling, constructing the physical
database, and preparing user views.
• Be familiar with operational features of distributed databases
and recognize issues that need to be considered in deciding
on a particular database configuration.
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 2
The Flat-File Approach
• Under the flat-file approach users own their data files.
Natural consequence of legacy-system era problems:
– Business culture barriers inhibit entity-wide data integration.
– Data files structured to the unique needs to the primary user.

• Data redundancy causes data management problems:


– Data storage: Commonly used data duplicated many times
creating excessive costs.
– Data updating: Changes must be made separately for each
user, adding significant data management costs.
– Currency of information: If users don’t record appropriate
changes, duties and decisions may used outdated data.
• Task-data dependency is the user’s inability to obtain
additional information as needs changes.
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 3
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 4
The Database Approach
• The database approach pools data into a common
database shared by all users, which resolves problems.
– No data redundancy as each data element is only stored once.
– As such, only a single update procedure is required.
– Changes any user makes updates values for all users.
– Users have access to all firm data, subject to authorizations.

• Database management system (DBMS) is a special


software system that controls access to the database.
• Three conceptual models: hierarchical model, network
model and relational model.
– Hierarchical and network databases are navigational or
structured models with data elements using predefined paths.
– Relational model is flexible and allows users to create paths.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 5
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 6
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 7
Elements of the Database Environment
• Users access the database in two ways:
– Via application programs prepared by system professionals.
– Via direct query, which requires no formal program.

• Database management system (DBMS) assists user access


to database and efficiently manage data resources. Includes:
– Program development to create database access applications.
– Backup and recovery, database usage reporting and access.

• Data definition language (DDL) defines the physical


database to the DBMS on three levels.
– Internal view presents physical arrangement of database records.
– Conceptual view (schema) represents database logically and
abstractly while the user view (subschema) defines how a user
sees the portion of the database user is authorized to access.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 8
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 9
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 10
DBMS Operation
1. User program sends data request (call) to the DBMS.

2. DBMS analyzes request by matching called data elements against


user and conceptual view. If request matches, it is authorized and
processing proceeds. If not, access is denied.
3. DBMS passes parameters to the operating system which
performs the data retrieval.
4. Using the appropriate access method operating system retrieves
data from the physical database and stores it in a main memory
buffer area managed by the DBMS.
5. DBMS transfers data to user for access and manipulation.

6. When processing is complete, steps 4. and 5. are reversed to


restore processed data to the database.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 11
Data Manipulation (DML) and Query Language
• DML is the proprietary programming language that a DBMS
uses to retrieve, process, and store.
• Entire user programs may be written in the DML, or selected
DML commands can be inserted into universal programs,
such as PL/1, COBOL and FORTRAN.
• DBMS query capability permits end users and programmers
to access data in the database directly.
• IBM’s structured query language (SQL) requires far less
training and program skills than many languages.
– Many commands that allow users to easily input, retrieve and
modify data.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 12
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 13
The Database Administrator (DBA)
• Responsible for managing database resources:
– May be an entire department in large organizations.
– Database planning, design, implementation, operation and
maintenance, change and growth.
• User requests go to the DBA who evaluates them to
determine user needs and grants access authority.
• DBA creates and maintains the data dictionary which
describes every data element in the database.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 14
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 15
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 16
The Physical Database
• Fourth major element of the database approach.
• Lowest level of the database.
• Collection of records and files.
• Relational databases are based on the indexed sequential
file structure.
– Facilitates both direct access to individual records and batch
processing of the entire file.
– Multiple indexes can be used to create a cross-reference or
inverted list which allows even more flexible access.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 17
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 18
The Relational Database Model
• Portrays data in the form of two-dimensional tables.
• Supports the relational algebra functions of restrict, project
and join:
– Restrict: Extracts specified rows from a specified table.
– Project: Extracts specified attributes (columns) from a table to
create a virtual table.
– Join: Builds a new physical table from two tables consisting of all
concatenated pairs or rows, from each table.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 19
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 20
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 21
Data Modeling Concepts
• Data model is a visual representation of organization’s data.
– Designed in theory using a top-down approach which requires a
detailed analysis of information needs. In practice many use a
bottom-up approach which modifies predefined models.
• Entity is anything about which an organization wishes to
capture data, either physical or conceptual.
– Graphical technique used to depict model is an entity relationship
(ER) diagram with each entity in the diagram corresponding to a
table in a physical database.
– Relation describes the situation where data in one table is related
to data in another table.
– Occurrence describes number of items associated with an entity.
– Attributes are data elements that define an entity.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 22
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 23
Data Modeling Concepts
• Association describes the nature of the functional
connection between two entities in a relation.
• Cardinality is degree of association between two entities
– The number of possible occurrences in one table that are
associated with a single occurrence in a related table.
– Four basic forms: zero or one (0,1), one and only one (1,1),
zero or many (0,M), and one or many (1,M).
• Tuple is the formal name for a row in the table.
– Value of at least one attribute in each tuple must be unique
(primary key). Other nonkey attributes need not be unique
– All attribute values in any column must be of the same class.
– Each column in a given table must be uniquely named.
– Tables must conform to the rules of normalization.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 24
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 25
• Related tables need to be physically connected to achieve
data model associations. Accomplished using foreign keys.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 26
• User view is the set of data a particular user sees. Large
organizations will have thousands of user views.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 27
Database Anomalies
• Improperly normalized tables can cause DBMS processing
problems that restrict or deny user access to needed info.
– Such tables exhibit anomalies that will exist in tables that are not
normalized or are normalized at low levels such as first normal
form (1NF) or second normal form (2NF).
– Anomaly free tables must be at third normal form (3NF) level.

• The update anomaly is the result of data redundancy in an


unnormalized table.
• The insertion anomaly occurs when data cannot be added
to a table because of its primary key.
• The deletion anomaly involves the unintentional deletion of
data from a table.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 28
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 29
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 30
Normalizing Tables in a Relational Database
• Database anomalies are symptoms of structural problems
within tables called dependencies.
– Repeating groups, partial dependencies, and transitive
dependencies.
• Normalization process involves removing structural
dependencies resulting in 3NF tables that meet two
conditions.
– All nonkey (data) attributes in the table are dependent on (defined
by) the primary key.
– All nonkey attributes are independent of other nonkey attributes.

• A 3NF table is one in which the primary key wholly and


uniquely defines each attribute in the table and none of the
table attributes is defined by an attribute other than the
primary key.
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 31
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
32
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
• Can we store all the data needed for this view in a single table
that also meets the two 3NF conditions?

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 33
• Next step is to represent the view as a single table that
contains all of the view attributes.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 34
• First step in correcting structural dependencies is to
determine if the table contains repeating groups (which must
be removed and placed in a separate table).

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 35
• Next check for partial dependencies which occur when one
or more nonkey attributes are dependent on only part of a
primary key. May be resolved by splitting table in two.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 36
• Final step is to remove transitive dependencies which occur
in a table where nonkey attributes are dependent on other
nonkey attributes and independent of the primary key.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 37
• To work together in the physical database, the tables in the
data model need to be linked via foreign keys.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 38
• This requires determining the cardinality between the tables
and assigning foreign keys.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 39
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 40
Accountants and Data Modeling
• Accountants should understand the data normalization
process and be able to determine whether a database is
properly normalized.
• Update anomalies can generate conflicting and obsolete
database values.
• Insertion anomalies can result in unrecorded transactions
and incomplete audit trails.
• Deletion anomalies can cause the loss of accounting
records and the destruction of audit trails.
• Organization’s database may consist of thousands of
normalized tables and navigation of the network requires
understanding of data structures.
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 41
Top-Down Approach to Designing Relational
Databases: View Modeling
1. Identify the view to be modeled.
2. Normalize the data model and add primary keys.
3. Determine cardinalities and add foreign keys.
– Combining data needs of all users in a single entity-wide
schema is called view integration:
1. An entity must consist of two or more occurrences.
2. No two entities may have the same primary key (exception are entities
with composite keys).
3. No non-key attribute may be associated with more than one entity.

4. Construct the physical database.


5. Prepare the physical user view.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 42
• Under the centralized database approach, remote users
send requests via terminals for data to the central site, which
processes the request and transmits data back to user.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 43
Databases in a Distributed Environment

• Distributed data processing (DDP) is an alternative to the


centralized approach.
• Achieving data currency (data files accurately reflect the
effects of transactions) is critical, but challenging with DDP.
– During data processing, account balances pass through a state of
temporary inconsistency in which values are incorrectly stated.
• To achieve data currency, simultaneous access to data
elements by multiple sites must be prevented.
– Solution is to use database lockout, a software control that
prevents multiple simultaneous access.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 44
Distributed Databases
• Partitioned database approach splits the central database
into segments that are distributed to primary users.
• Storing data at local sites increases users’ control.
• Permitting local access to data and reducing volume of data
that must be transferred between sites improves response
time.
• Partitioned databases reduce potential for disaster as loss at
a single site cannot terminate all of the organization’s data
processing.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 45
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 46
Distributed Databases
• Possible that multiple sites will lock each other out and
prevent transaction processing.
– When one site has requested (and locked) data and another site
needs the same data, a deadlock occurs because there is mutual
exclusion to data.
– Can result in incomplete processing and database corruption.

• Resolving deadlock usually involves sacrificing one or more


transactions which must be terminated to complete the
processing of other transactions in deadlock. Decision
influenced by:
– Resources currently invested in the transaction.
– Transaction’s stage of completion.
– Number of deadlocks associated with the transaction.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 47
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 48
Distributed Databases
• Replicated databases exist when the entire database is
replicated at each site.
– Effective when there is a high degree of data sharing but no
primary user.
– Primary justification is to support read-only queries.
– Problem arises when local sites need to update the replicated
database with transactions.
• Database concurrency is the presence of complete and
accurate data at all remote sites.
– Commonly used method of concurrency control is to serialize
transactions using classes and time stamps.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 49
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 50
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 51
Distributed Databases and the Accountant
• Decision to distribute database should be entered into
thoughtfully.
• Many issues and trade-offs to consider, including:
– Should organization’s data be centralized or distributed?
– If distributed, should databases be replicated or partitioned?
– If replicated, should there be total or partial replication?
– If partitioned, how should the data segments be allocated among
the sites?
• The choices made impact the organization’s ability to
maintain database integrity, preserve audit trails, and have
accurate accounting records.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 52
Appendix:
Distinguishing Features of Structured Databases
• Earliest DBMSs were based on the hierarchical data model.
– Popular because it reflected many organization aspects that are
hierarchical in relationship and an efficient data processing tool for
highly structured problems.
– Constructed of sets of file with each set containing a parent and a
child.
• Hierarchical model is a navigational database because
traversing it requires following a predetermined path.
• Hierarchical model present a limited view of data
relationships.
– A parent record may have one or more children.
– No child record can have more than one parent.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 53
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 54
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 55
• Network database model is a variation of the hierarchical
model that allows a child to have multiple parents and is
flexible in allowing complex relationships to be

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 56
Data Structures
• Data structures are the bricks and mortar of the database.
• Hierarchical model data structure uses the hierarchical
indexed direct access method.
– The root segment of the database is organized as an indexed file.
– Lower level records use pointers in a linked-list arrangement which
allows both efficient processing and direct access for inquiries.
• The network model data structure is also a navigational
database with pointers creating explicit linkages between
records.
– Unlike the hierarchical model, this model supports multiple paths to
the same record.

2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 57
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 58
2015 Cengage Learning. All rights reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 59

You might also like