Sie sind auf Seite 1von 9

CHAPTER 4

Learning Objectives:

RELATIONAL DATABASES

1. Explain the importance and advantages of databases, as well as the


difference between database and file-based legacy systems.
2. Explain the difference between logical and physical views of a
database.
3. Explain fundamental concepts of database systems such as DBMS,
schemas, the data dictionary, and DBMS languages.
4. Describe what a relational database is and how it organizes data.
5. Create a set of well-structured tables to properly store data in a
relational database.
6. Perform simple queries using the Microsoft Access database.
Questions to be addressed in this chapter:
1. How are databases different than file-based legacy systems?
2. Why are databases important and what is their advantage?
3. What is the difference between logical and physical views of a
database?
4. What are the fundamental concepts of database systems such as
DBMS, schemas, the data dictionary, and DBMS languages?
5. What is a relational database, and how does it organize data?
6. How are tables structured to properly store data in a relational
database?

Introduction
The emphasis in this chapter will be on understanding the structure of a
relational database system.
Files versus Databases
A file, as described in the back of our book in the glossary, is a
set of logically related records, such as the payroll records of
all employees.
Figure 4-1 on page 87 shows the basic elements of data hierarchy.
Fields contain data about one customer such as the customers
address, customer name, and so on.
All the fields for one customer form a record.

Page 1 of 9

A set of related records, such as all customer records,


forms a file.
A set of interrelated files forms a database.
We use the term database to mean the collected data sets that are
organized and stored as an integral part of a firms computerbased information system.
In turn, we define the term data sets as flexible data
structures. Data sets include groupings of data that are
logically related as well as the files with which we are
familiar
Figure 4-2 on page 90 provides a comparison of file-oriented
versus database systems
Most firms developing new systems and applications for use in
todays business environment choose the database approach to data
management.
Data independence, a critical feature of the data-base approach,
is the separation of data from the various applications that
access and process the data.
Data independence is achieved by interposing the database
management system (DBMS) software between the database and the
users of the data(e.g., the application programs.
A database management system (DBMS) acts as an interface between
the database and the various application programs.
As technology improves many companies are developing very large
databases called data warehouses.
Data mining is the process of analyzing data repositories for new
knowledge about the companys data and business processes; as
discussed in greater detail in Chapter 14.

The Importance and Advantages of Database Systems


Note to Students: Some of the job announcements for accounting
positions require the knowledge and skills from experience in
using MS Access.
Most accounting students will audit or work for a company that
uses database technology to store, process, and report accounting
transactions.
Database technology is widespread because it provides
organizations with the following benefits:
1. Data integration: Integration is achieved by combining
master files into larger pools of data that many
application programs can access. An example is an employee

Page 2 of 9

database that consolidates data formerly contained in


payroll, personnel, and job skills master files. This makes
it easier for information to be combined in unlimited ways
2. Data sharing: Integrating data makes it easier to share data
with all authorized users.
3. Reporting flexibility: Reports can be revised easily and
generated as needed and the database can be easily browsed
to research a problem or obtain detailed information
underlying a summary report.
4. Minimal data redundancy and data inconsistencies: Because
data items are usually stored only once, data redundancy and
data inconsistencies are minimized.
5. Data independence: Because data and the programs that use
them are independent of one another, each can be changed
without having to change the other. This makes programming
easier and simplifies data management.
6. Central management of data: Data management is more
efficient because a database administrator is responsible
for coordinating, controlling, and managing data.
7. Cross-functional analysis:
relationships, such as the
and promotional campaigns,
used in the preparation of

In a database system,
association between selling costs
can be explicitly defined and
management reports.

Database Systems
Logical and Physical Views of Data
Figure 4-3 at the bottom of page 90 provides an example of a
record layout of an accounts receivable file.
The logical view is how the user or programmer conceptually
organizes and understands the data.
The physical view refers to how and where the data are physically
arranged and stored in the computer system.
Figure 4-4 on page 91 provides multiple logical views of data.
As shown in Figure 4-4, database management system (DBMS) software
handles the link between the way data are physically stored and
each users logical view of the data.

Schemas
A schema describes the logical structure of a database.

Page 3 of 9

Three levels of schemas: the conceptual, the external, and


the internal.
Figure 4-5 on page 91 provides the three levels of schemas
The conceptual-level schema is the organization-wide view of
the entire database.
The external-level schema consists of a set of individual
user views of portions of the database, each of which is
also referred to as a subschema.
The internal-level schema provides a low-level view of the
database. It describes how the data are actually stored and
accessed, including information about record layouts,
definitions, addresses, and indexes.

The Data Dictionary


The data dictionary contains information about the structure
of the database. The data elements composing the database
are fully described in a data dictionary, which serves as a
repository containing facts about the structure of the data
elements employed in applications.
Table 4-1 on page 93 provides an example of a data
dictionary.

Database Management System (DBMS) Languages


The data definition language (DDL) is used to (1) build the
data dictionary, (2) initialize or create the database, (3)
describe the logical views for each individual user or
programmer, and (4) specify any limitations or constraints
on security imposed on database records or fields.
The data manipulation language (DML) is used for data
maintenance, which includes such operations as updating,
inserting, and deleting portions of the database.
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.
A report writer is a language that simplifies report
creation.
In addition to the functions provided by these components,
many DBMS packages allow users to
1.
2.
3.
4.
5.

Analyze data and create ad hoc or customized reports


Create and display graphs
Create customized applications via host programming
languages
Import and export data and images from other packages
Perform on-line data editing

Page 4 of 9

6.
7.
8.
9.

Purge or archive obsolete data


Back up data
Maintain other security measures
Interface with communications networks

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 like the one
shown in Table 4-2 on page 94.
Technically, these tables are called relations (hence the
name relational data model), but we will use the two words
interchangeably.
Each row in a relation, called a tuple (which rhymes with
couple), contains data about a specific occurrence of the
type of entity represented by that table. For example, each
row in the inventory table in Table 4-2 contains data about
a particular inventory item that S&S carries.
Types of Attributes
A primary key is the attribute, or combination of
attributes, that uniquely identifies a specific row in a
table. The primary key for the inventory table in Table 4-2
is the Item Number.
A foreign key is an attribute in a table that is a primary
key in another table. Foreign keys are used to link tables.

Designing a Relational Data Base for S&S, Inc.


Option 1: Store All Data in One Uniform Table.
This data is provided in Table 4-3 on page 95
This approach has two disadvantages:
1. It creates a great deal of redundancy in terms of
stored data. For example, because there are three
separate inventory items sold, the sales invoice
number 102 is listed three times with the invoice
and customer data is repeated each time an item is
sold.
2. The second problem that can occur is referred to as
an insert anomaly, because there is no way to store
information about prospective customers until they
actually make a purchase.

Page 5 of 9

Option 2: Vary the Number of Columns


This data is provided in Table 4-4 on page 94.
In this option, the data storage is to record the sales invoice
and customer information just once.
This required additional items which required five additional
columns:
1. Item
2. Quantity
3. Description
4. Unit Price
5. Extended Amount
We still have disadvantages. This approach does not reduce some of
the redundancy and some of the anomalies associated with the data
storage scheme illustrated in Table 4-3.
This table is set up for the sale of five items. What
happens if eight items are sold? This would require 40
columns! Now we are going to have even more columns to add
three more items.
The problems associated with Options 1 and 2 in Tables 4-3 and 4-4
can be solved with a relational database.
Basic Requirements of a Relational Database
1.

Every 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 another table.

4.

All nonkey attributes in a table should describe a


characteristic about the object identified by the primary key.

A set of relational databases are provide in Table 4-5 on page 98.


As shown in Table 4-5 we now have more than one table that have
relationships:
1. Sales Table
2. Sales-Inventory Table
3. Inventory Table
4. Customer Table

Page 6 of 9

Primary key is the attribute, or combination of attributes, that


uniquely identifies a specific row in a table. As a result, the
value for a primary key cannot be blank (null). If it was blank,
then there would be no way to identify a specific row and retrieve
any data.
The entity integrity rule ensures that every row in every relation
must represent data bout some specific object in the real world.
Foreign keys are used to link rows in one table to rows in another
table. Refer to the lines and arrows in Table 4-5.
The link to each sales transaction with the customer who
participated in that event if the customer number values in
the sales table correspond to actual customer numbers in the
customer table.
This is referred to as the referential integrity rule
that ensures the consistency of the database.
For example, the customer number is a foreign key in the
sales table that relates to the customer number that is a
primary key in the customer table.
Foreign keys can have a null value. Some customers that pay
cash may not want to give up their identity which would be
able to allow a company to track them. Therefore, their will
be some customer number fields that will be left blank.
Nonkey attributes are items in a table that are neither a primary
key nor a foreign key. As previously described as the fourth basic
requirement for a relational database; all nonkey attributes in a
table should describe a characteristic about the object identified
by the primary key.
Two Approaches to Database Design
One approach is called normalization, which starts with the
assumption that everything is initially stored in one large table.
The details of the normalization process are beyond the
scope of this book but can be found in any database
textbook.
The following Website provides more detailed information regarding
normalization: http://en.wikipedia.org/wiki/Database_normalization .
Note that normalization is also spelled normalization.
Another alternative way to design well-structured relational
databases involves semantic data modeling. Under this approach,
the database designer uses knowledge about how business processes
typically work and about the information needs associated with
transaction processing to draw a graphical picture of what should
be included in the database. The resulting figure can then be
directly used to create a set of relational tables that are in
third normal form (3NF). Refer to the Website for the third normal
form.

Page 7 of 9

The MS Access menu is shown in Table 4-6 on page 99


Query 1. We are using the Sales and Customer Tables for this
Query.
Next we select the files from each Table to be included in the
Query. Note the Sales Table Primary Key is Sales Invoice # and the
Foreign Key is the Customer # which is the Primary Key for the
Customer Table.
This is shown in Table 4-7 on page 99.
The Sales and Customer Tables, and the Results of the Query are
shown in Table 4-8 on page 100.
Query 2. This query involves the Sales, Sales-Inventory, and
Inventory tables. Students should be able now to determine the
Primary Keys and the Foreign Keys involved.
The Completed Query 2 and Query 2 Answer are provided in Table 4-9
on page 101.
Query 3. Now we are using four tables; Customer, Sales, SalesInventory, and Inventory tables.
The Completed Inquiry 3 and Query 3 Answer are provided in Table
4-10 on page 102.
Query 4. We will be using the Sales, Sales-Inventory, and
Inventory tables.
The Completed Inquiry 4 and Query 4 Answer are provided in Table
4-11 on page 103.
Query 5. We will be using the same three tables that were used in
Query 4.
The Completed Inquiry 5 and Query 5 Answer are provided in Table
4-12 on page 103.

Database Systems and the Future of Accounting


Database systems may profoundly affect the fundamental nature of
accounting. For instance, database systems may lead to the
abandonment of the double-entry accounting model.
If the amounts associated with a transaction are entered into a
database system correctly, then it is necessary to store them only
once, not twice.
Database systems also have the potential to significantly alter
the nature of external reporting.

Page 8 of 9

Why not simply make a copy of the companys financial database and
make it available to external users in lieu of the traditional
financial statements?
Focus 4-1 on page 125 discusses this possibility in more detail.
Perhaps the most significant effect of database systems will be in
the way accounting information is used in decision making.
Relational databases, however, provide query languages that are
powerful and easy to use.
Managers can concentrate solely on specifying what information
they want.
Finally, relational DBMSs provide the capability of integrating
financial and operational data.

Page 9 of 9

Das könnte Ihnen auch gefallen