Chapter 3
Relational Databases, Data modeling and
                Data base design
                                                    4-1
Copyright © 2012 Pearson Education
                Learning Objectives
           Explain the importance and advantages of databases.
           Describe the difference between database systems and file-based legacy systems.
           Explain the difference between logical and physical views of a database.
           Explain fundamental concepts of database systems such as DBMS, schemas, the data dictionary, and
            DBMS languages.
           Describe what a relational database is and how it organizes data.
           Create a set of well-structured tables to store data in a relational database.
           Explain Database Systems and the Future of Accounting.
           Explain Data Modeling and Database Design.
           Explain The REA Data Model. Reading assignment
Copyright © 2012 Pearson Education                                                                             4-2
                 INTRODUCTION
 Relational databases underlie most modern integrated AISs. How to
  participate in the design and implementation of a database AIS will be
  explained. The emphasis is on understanding the structure of the relational
  database system.
                                                 Files versus Databases
 To fully appreciate the power of databases, it is important to understand
  some basic principles about how data are stored in computer systems.
  Information about attributes of an entity is stored in fields. All the fields that
  contain data about the same entity form a record. A set of related records are
  grouped to form a file. For example, all customer receivable records are
  stored in an account receivable file. A set of interrelated, centrally
  coordinated files is referred to as a database.
Copyright 2012 © Pearson Education, Inc. publishing as Prentice Hall                   4-3
                        Example: Accounts Receivable File is shown below
Copyright 2012 © Pearson Education, Inc. publishing as Prentice Hall       4-4
                Data Hierarchy
         Field
                Attributes about
                 an entity
         Record
                Related group of
                 fields
         File
                Related group of
                 records
         Database
                Related group of
                 files
Copyright © 2012 Pearson Education   4-5
                 Types of Files
 Two basic types of files exist. A master file is conceptually similar to a
  ledger in manual AIS. Master files store cumulative information about an
  organization’s resources and the agents with whom it interacts. For example
  the inventory and equipment master files store information about important
  organizational resources.
 Master files are permanent; they exist across all periods. Individual records
  within a master file, however, are frequently changed.
       updating the data to reflect the effect of specific transactions.
       new records may also be added to the master file and
       sometimes, individual records may even be deleted.
Copyright 2012 © Pearson Education, Inc. publishing as Prentice Hall              4-6
        Types of Files
 The second type of file is called a Transaction file, which is conceptually
  similar to a journal in manual AIS. Transaction files contain records of the
  individual business transactions (events) that occur during a specific fiscal
  period. For example, a file containing records of sales events and another file
  containing records of customer payments. Both of them would be used to
  update individual customer account balances in the customers’ master file.
  Transaction files are not permanent.
                                                                             4-7
                 DATABASES
 Database systems were developed to address the problems associated with
  the proliferation of master files.
            For years, each time a new information need arose, companies created new files
             and programs.
            The result: a significant increase in the number of master files.
Copyright 2012 © Pearson Education, Inc. publishing as Prentice Hall                          4-8
                 Problems of master files
                                                                       This proliferation of master
                                                                       files created problems:
                                                                        Often the same information
                                                                         was stored in multiple master
                                                                         files.
                                                                        Made it more difficult to
                                                                         effectively integrate data and
                                                                         obtain an organization-wide
                                                                         view of the data.
                                                                        Also, the same information
                                                                         may not have been consistent
                                                                         between files.
                                                                              If a customer changed his
                                                                              phone number, it may
                                                                              have been updated in one
                                                                              master file but not another
Copyright 2012 © Pearson Education, Inc. publishing as Prentice Hall                                        4-9
                 Databases
 Database systems were developed to address the problems associated with
  the proliferation of master files.
 A database is a set of interrelated, centrally coordinated files. The database
  approach treats data as an organizational resource that should be used by
  and managed for the entire organization, not just the originating department
  or function. The focus is data integration and data sharing with all
  authorized users. Integration is achieved by combining master files into
  larger pools of data that many application programs can access.
 This is accomplished by a program called database management systems
  (DBMSs), which acts as an interface between the database and the various
  application programs. The combination of the database, the DBMS, and the
  application programs that access the database through the DBMS is referred
  to as the database system
Copyright 2012 © Pearson Education, Inc. publishing as Prentice Hall               4-10
                 Databases
               Database system
Copyright 2012 © Pearson Education, Inc. publishing as Prentice Hall   4-11
                 Advantages of Database Systems
                  Data Integration
                        Files are logically combined and made accessible to various systems.
                  Data Sharing
                        With data in one place it is more easily accessed by authorized users.
                  Minimizing Data Redundancy and Data Inconsistency
                        Eliminates the same data being stored in multiple files, thus reducing inconsistency in
                         multiple versions of the same data.
                  Data Independence
                        Data is separate from the programs that access it. Changes can be made to the data
                         without necessitating a change in the programs and vice versa.
                  Cross-Functional Analysis
                        Relationships between data from various organizational departments can be more easily
                         combined.
Copyright © 2012 Pearson Education                                                                                 4-12
                Database Terminology
              Database Management System (DBMS)
                        Interface between software applications and the data in files.
              Database Administrator (DBA)
                        Person responsible for maintaining the database
              Data Dictionary
                              Information about the structure of the database
                                Field names, descriptions, uses
Copyright © 2012 Pearson Education                                                        4-13
                Logical vs. Physical views of data
            Database systems separate the logical and physical views of data. The logical
             view is how the user or programmer conceptually organize and understand the
             data. For example, a sales manager may conceptualize all information about
             customers as being stored in form of a table. The physical view refers to how
             and where the data are physically arranged and stored on disk, tape, CD ROM,
             or other media
            Physical View
              Depends on explicitly knowing:
                        How is the data actually arranged in a file
                        Where is the data stored on the computer
            Logical View
                 A Schema separates storage of data from use of the data
                        Unnecessary to explicitly know how and where data is stored.
Copyright © 2012 Pearson Education                                                           4-14
                 Databases
      Separating the logical and the physical views of data facilitates developing
       new applications because programmers can concentrate on coding the
       application logic (what the program will do) and do not need to focus on how
       and where the various data items are stored or accessed. The database
       management system software deals with the links between the way the data
       are physically stored and each user’s logical view of the data.
      Separating the logical and the physical views of data also means that users
       can change their conceptualization about relationships among data items
       (their logical view of the task) without making changes in the way those data
       are physically stored. Likewise, the database administrator can change the
       physical storage of the data to improve performance, without affecting users
       or application programs.
Copyright 2012 © Pearson Education, Inc. publishing as Prentice Hall            4-15
                Schemas
         Describe the logical structure of a
          database. There are three levels of
          schemas: the conceptual, the external,
          and the internal.
           Conceptual Level
               Organization wide view of the
                 data
           External Level
               Individual users view of the data
               Each view is a subschema
           Internal Level
               Describes how data are stored
                 and accessed
                  Description of: records,
                      definitions, addresses, and
                      indexes
Copyright © 2012 Pearson Education                  4-16
        DBMS Languages
Every DBMS must provide a means of performing the three basic functions of creating,
   changing, and querying the database. The set of commands used to perform these functions
   are referred to as the data definition, data manipulation, and data query languages
   respectively
 Data Definition Language (DDL)
      Builds the data dictionary
      Creates the database
      Describes the subschema
      Specifies record or field security constraints
 Data Manipulation Language (DML)
      Changes the content in the database
        Updates, insertions, and deletions
 Data Query Language (DQL)
      Enables the retrieval, sorting, and display of data from the database
                                                                                              4-17
                Relational Database
              Relational data model represents the conceptual and external level
               schemas as if data are stored in tables.
              Table
                        Each row, a tuple, contains data about one instance of an entity.
                          This is equivalent to a record
                        Each column contains data about one attribute of an entity.
                          This is equivalent to a field
Copyright © 2012 Pearson Education                                                           4-18
       Row (Record)   A Relational Table
                      Each row contains multiple attributes            Same type of data
                      describing an instance of the entity. In
                                                                 Column (Field)
                      this case, inventory.
Copyright © 2012 Pearson Education                                                         4-19
 Types of Attributes
 Primary Key
      An attribute or combination of attributes that can be used to uniquely
       identify a specific row (record) in a table. Example item id in inventory
       table, customer id in customer table.etc
      This rule is referred to as the entity integrity rule
 Foreign Key
      An attribute in one table that is a primary key in another table.
        Used to link the two tables. Example item id in sales table become
          primary key in inventory table.
        This rule is referred to as the referential integrity rule.
 Other non-key attributes.          In each table store important information about that
   entity. For example, in the inventory table, quantity on hand, description and list price
   are non-key attributes.
                                                                                               4-20
                Database Design Errors
              If database is not designed properly data errors can occur.
                        Update Anomaly
                          Changes to existing data are not correctly recorded.
                                    Due to multiple records with the same data attributes
                        Insert Anomaly
                          Unable to add a record to the database.
                        Delete Anomaly
                          Removing a record also removes unintended data from the database.
Copyright © 2012 Pearson Education                                                             4-21
                Design Requirements for Relational Database
             1.       Every column must be single valued. there shall be one and only
                      one value in each cell.
             2.       Primary keys must contain data (not null). the primary key is the
                      attribute or a combination of attributes that uniquely identifies a
                      specific row in a table. For this to be true, the primary key for any
                      row can't be null or blank
             3.       Foreign keys must contain the same data as the primary key in
                      another table. foreign keys are used to link rows in one table to
                      rows in another table. This is only possible if the values correspond
                      to their values in the row of the original table.
             4.       All other attributes must identify a characteristic of the table
                      identified by the primary key.
Copyright © 2012 Pearson Education                                                            4-22
                  Approaches to Database Design
   There are two basic approaches to design a well structured relational database:
    One approach called normalization.
          It starts with the assumption that everything is initially stored in one large table.
           then
          A set of rules is then followed to decompose that initial table into a set of
           normalized tables. The objective is to produce a set of tables what are called third
           normal form (3NF), because such tables are free of the types of update, insert and
           delete anomalies (problems described earlier)
Copyright © 2012 Pearson Education                                                            4-23
       Approaches to Database Design
 An 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 & about the information needs associated with
       transaction processing. Then
       first 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 3NF.
   Semantic data modeling has two significant advantages over simply following the
      rules of normalization.
   1. It facilitates efficient design of transaction processing databases. Because it use of
      the system designer's domain knowledge about business processes and practices.
   2. Because the resulting graphical model explicitly represents information about the
      organization's business processes and policies, it facilitates communicating with
      the intended users of the system. Such communication is extremely important in
      ensuring that the resulting system meets the actual needs of users.
                                                                                       4-24
                 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.
       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.
Copyright 2012 © Pearson Education, Inc. publishing as Prentice Hall                              4-25
                 DATABASE SYSTEMS AND THE FUTURE OF ACCOUNTING
        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
Copyright 2012 © Pearson Education, Inc. publishing as Prentice Hall              4-26
                 Data Modeling and Database Design
      Building accurate databases requires a great deal of careful planning and
       design before even sitting down at the computer
Copyright 2012 © Pearson Education, Inc. publishing as Prentice Hall               4-27
                 Database Design Process
 There are six basic steps in database design.
1.      Planning Stage- involves the initial planning to determine the need for and
        feasibility of developing the new system. This includes preliminary judgments
        about the proposals technological and economic feasibility.
2.      Requirements Analysis Stage- involves identifying user information needs,
        defining the scope of the proposed new system, and using information about
        the expected number of users and transaction volumes to make preliminary
        decisions about hardware and software requirements.
3.      Design Stage- involves developing the different schemas for the new system,
        at the conceptual, external, and internal levels. The requirements analysis and
        design stages are the stages of data modeling.
Copyright 2012 © Pearson Education, Inc. publishing as Prentice Hall               4-28
                                                                    Con’t
4. Coding- involves translating the internal level schema into the actual
   database structures that will be implemented in the new system. This is also
   the stage when new applications are developed.
5. Implementation- this stage includes all activities associated with
   transferring data from existing systems to the new database AIS, testing the
   new system, and training employees how to use it.
6. Operation and Maintenance- involves using and maintaining the system
   including carefully monitoring system performance and user satisfaction to
   determine the need for making system enhancements and modifications.
   Eventually, changes in business strategies and practices or significant new
   developments in information technology initiate investigation into the
   feasibility of developing a new system and the entire process starts again.
                                                                             4-29
                 Fig of Data modeling in the database design process   .
Copyright 2012 © Pearson Education, Inc. publishing as Prentice Hall       4-30
                 How accountants participate in database design
                 process?
      Accountants can and should participate in all stages of the database design
       process, although the level of their participation in each stage is likely to
       vary.
             In the planning stage, accountants both provide some of the information used to
              evaluate the feasibility of the proposed project and participate in making that
              decision.
             In the requirements analysis and design stages, accountants participate in
              identifying user information needs, developing the logical schemas, designing the
              data dictionary, and specifying controls.
             During the implementation stage, accountants can also help test the accuracy of
              the new database and the application programs that will use that data.
             Finally, accountants use the database system to process transactions, and
              sometimes they even help manage it.
Copyright 2012 © Pearson Education, Inc. publishing as Prentice Hall                       4-31
                                                                             con’t
               Accountants may provide the greatest value to their organizations by
                taking responsibility for data modeling. Data modeling is the
                process of defining a database so that it faithfully represents all
                aspects of the organization, including its transactions with the
                external environment.
               Data modeling occurs during both the requirements analysis and
                design stages of the database design. Two important tools that
                accountants can use to facilitate participation in data modeling are
                entity relationships diagramming and the REA data model.
Copyright 2012 © Pearson Education, Inc. publishing as Prentice Hall                   4-32