das - database design (erd) .pdf

Upload: hafiz-fizul

Post on 02-Mar-2016

100 views

Category:

Documents


0 download

DESCRIPTION

Database for ERD

TRANSCRIPT

  • Database Design: Logical & Physical ModelingDatabase Accounting Systems

    Actg/IDS 475

    Accounting 475

    Systems Development Life Cycle

    Planning RequirementsAnalysis Design CodingImplemen-

    tation Operation

    Logical ModelingPhysical Modeling

    Classical Model

    MSAccess

    Accounting 475

    Logical Design Tools

    Flowchart Data Flow Diagram Entity-RelationshipDiagram

    DatabaseOverall Schema

    Maps the dataenvironment ina process-oriented manner

    Maps the dataenvironment in a relationship-oriented manner

    Maps the dataenvironment ina proceduralmanner

    Accounting 475

    Logical Modeling

    Flowchart Data Flow Diagram Entity-RelationshipDiagram

    DatabaseOverall Schema

    Maps the dataenvironment ina process-oriented manner

    Maps the dataenvironment in a relationship-oriented manner

    Physical ModelingDesign of relational database tables

    Maps the dataenvironment ina proceduralmanner

    Accounting 475

    Logical Modeling

    Flowchart Data Flow Diagram Entity-RelationshipDiagram

    DatabaseOverall Schema

    Maps the dataenvironment ina process-oriented manner

    Maps the dataenvironment in a relationship-oriented manner

    Physical ModelingDesign of relational database tables

    Maps the dataenvironment ina proceduralmanner

    CodingCreate database in MSAccess

    Accounting 475

    Data Flow Diagram Flowchart Comparison Manual processing

    DFD Flowchart

  • Accounting 475

    Data Flow Diagram Flowchart Comparison Computer Processing Magnetic Tape

    DFD Flowchart

    Accounting 475

    Data Flow Diagram Flowchart Comparison Computer Processing Magnetic Disk

    DFD Flowchart

    Accounting 475

    ERD Modeling

    Makes sure that the database captures and stores data about each business activity the company intends to plan, control or evaluate

    It produces a database that is in third normal form (3NF)

    Accounting 475

    Entity Relationship Diagram

    Entity - any class of objects about which data is collected.

    Customer

    OrderSale

    Accounting 475

    Entity Relationship Diagram

    Attributes - properties or characteristics of an entity that are of interest

    Invoice #

    CustomerName

    TelephoneNumber

    Accounting 475

    Entity Relationship Diagram

    Relationship - the link between one or more entities describing how they are related

    Pays for

    Received by

    Made to

  • Accounting 475

    Entity Relationship Diagram

    Cardinality - the number of occurrences of one entity that may be associated with a single occurrence of the other entity. Maximum Cardinality Minimum Cardinality

    Accounting 475

    Entity Relationship Diagram

    Employee Is married to

    Employee #

    Address

    Telephone #

    Unary Relationship

    Name1

    1

    Accounting 475

    Entity Relationship DiagramBinary Relationship

    Sales Pays for

    Invoice #

    CashCollectionsItem

    Price $ Amount

    CustomerName

    Invoice #

    1 N

    Accounting 475

    Entity Relationship Diagram

    Office

    Employee ComputerIs assigned to

    Ternary Relationship

    1

    1

    1

    Accounting 475

    1) Do not include attributes in ERD2) Use only binary relationships in ERD

    2 SimplifyingAssumptions!!!

    Accounting 475

    Sample E-R Diagrams

    SupervisorsEmployers

    Departments

    Part ofManages

    Managed

    By

    Customer Orders Sales

    Cash Receipts

    Part of Part of

    Players Teams LeaguePart of Part of

  • Accounting 475

    Entity Relationship Diagram

    Maximum Cardinality - the maximumnumber of occurrences of one entity that may be associated with a single occurrence of the other entity. One to One One to Many Many to One Many to Many

    Accounting 475

    Entity Relationship DiagramMaximum Cardinalities

    One to One (1:1) Relationships

    e.g. Cash Sale Each instance of a sale is linked to at most one instance of

    a cash collections event Each instance of a cash collection is linked to at most one

    instance of a sales event

    Sales Pays for CashCollections1 1

    Accounting 475

    One to Many (1:N) Relationships

    e.g. Installment Payments Each instance of a sale is linked to many instances of a

    cash collection event Each instance of a cash collection is linked to at most one

    instance of a sales event event

    Sales Pays for CashCollections1 N

    Entity Relationship DiagramMaximum Cardinalities

    Accounting 475

    Many to One (N:1) Relationships

    e.g. Paying monthly store card in full Each instance of a sale is linked to at most one instance of

    a cash collections event Each instance of a cash collection is linked to many

    instances of a sales event

    Sales Pays for CashCollectionsN 1

    Entity Relationship DiagramMaximum Cardinalities

    Accounting 475

    Many to Many (N:N) Relationships

    e.g. Paying monthly store card in part each month (balance forward method)

    Each instance of a sale is linked to many instances of a cash collections event

    Each instance of a cash collection is linked to many instances of a sales event

    Sales Pays for CashCollectionsN N

    Entity Relationship DiagramMaximum Cardinalities

    Accounting 475

    How do you know what the maximum cardinalities should be?

    Companys business policies General business knowledge

  • Accounting 475

    ERD MethodologyData Modeling Reading example

    1. Identify the entities for the ERD using the:

    REA model

    Accounting 475

    Resource Event Agent Model

    Resource

    Event

    Agent

    Things of economic value to an organization that it wants to collect data about, which includes: 1) Assets - cash, inventory, supplies, stores2) Intangibles (not on balance sheet) employee

    services, manufacturing techniques3) Items not owned neighborhoods (in a real estate

    database), delivery routes (used by a truckingcompany)

    All organizations activities about which management wants to collect data - sales, cash collections, customer orders

    Types of people an organization collects data about, people who participate in events - employee, vendor, customer

    Accounting 475

    2. Draw rectangles to represent each entity and arrange event entities in chronological order on page (start with events and then add related resources and agents)

    CashCollections

    Sales

    Resource Event Agent

    Cash

    SalespersonInventory

    Customer

    Cashier

    ERD MethodologyData Modeling Reading example

    Accounting 475

    3. Add diamonds to represent important relationships

    CashCollections

    Sales

    Resource Event Agent

    Cash

    SalespersonInventory

    Customer

    Cashier

    Increases

    Lineitems

    Paysfor

    Receivedby

    Receivedfrom

    Madeto

    Partyto

    ERD MethodologyData Modeling Reading example

    Accounting 475

    4. Specify maximum relationship cardinalities

    CashCollections

    Sales

    Resource Event Agent

    Cash

    SalespersonInventory

    Customer

    Cashier

    Increases

    Lineitems

    Paysfor

    Receivedby

    Receivedfrom

    Madeto

    Partyto

    N N N

    NN

    NN

    N

    N1

    1

    1

    1

    1

    ERD MethodologyData Modeling Reading example

    Accounting 475

    5. Specify minimum relationship cardinalities

    CashCollections

    Sales

    Resource Event Agent

    Cash

    SalespersonInventory

    Customer

    Cashier

    Increases

    Lineitems

    Paysfor

    Receivedby

    Receivedfrom

    Madeto

    Partyto

    ERD MethodologyData Modeling Reading example

  • Accounting 475

    Entity Relationship Diagram

    Minimum Cardinality - the minimumnumber of occurrences of one entity that may be associated with a single occurrence of the other entity.

    Accounting 475

    How do you know what the minimum cardinalities should be? Companys business policies Knowledge of effective internal

    controls

    Accounting 475

    Minimum Cardinalities and Internal Control

    Internal controls:1) Safeguard the assets2) Ensure the accuracy & reliability of

    the accounting data3) Ensure efficient operations4) Enforce managerial policies

    Some of these controls can be built into thestructure of the database

    Accounting 475

    Minimum Cardinalities and Internal Control

    For good Internal Control there are 3 types of minimum cardinalities:1) Event-Resource 2) Event-Agent3) Event-Event

    Accounting 475

    5. Specify minimum relationship cardinalities

    CashCollections

    Sales

    Resource Event Agent

    Cash

    SalespersonInventory

    Customer

    Cashier

    Increases

    Lineitems

    Paysfor

    Receivedby

    Receivedfrom

    Madeto

    Partyto

    ERD MethodologyData Modeling Reading example

    1 0

    Accounting 475

    Event-Resource Relationships

    Every event involves the acquisition, use or disposal of some resource, but a resource may not be involved in any event

    Each instance of inventory is linked to a minimum of zero sales events (ie. Unsold or slow-moving inventory - mana-gerial control)

    Each instance of a sale is linked to a minimum of one inven-tory item (sale w/o inventory indicates a transaction error)

    Inventory Line Item Sales1 0

    Entity Relationship DiagramMinimum Cardinalities

  • Accounting 475

    5. Specify minimum relationship cardinalities

    CashCollections

    Sales

    Resource Event Agent

    Cash

    SalespersonInventory

    Customer

    Cashier

    Increases

    Lineitems

    Paysfor

    Receivedby

    Receivedfrom

    Madeto

    Partyto

    ERD MethodologyData Modeling Reading example

    10

    Accounting 475

    Event-Agent Relationships

    Ensures that all events are legitimate Each instance of a sale must be made by a minimum of one

    salesperson (sale w/o salesperson indicates a transaction error)

    Each salesperson is linked to a minimum of zero sales (ie. Person is not effective or was on vacation for the period, etc - managerial control.)

    Sale Party to Salesperson0 1

    Entity Relationship DiagramMinimum Cardinalities

    Accounting 475

    5. Specify minimum relationship cardinalities

    CashCollections

    Sales

    Resource Event Agent

    Cash

    SalespersonInventory

    Customer

    Cashier

    Increases

    Lineitems

    Paysfor

    Receivedby

    Receivedfrom

    Madeto

    Partyto

    ERD MethodologyData Modeling Reading example

    1

    0

    Accounting 475

    Event-Event Relationships

    Ensures that events are legitimate and occur in proper order Each instance of a sale is linked to a minimum of zero cash

    collections (ie. uncollected A/R, overdue accounts, etc. -managerial control)

    Each cash collection is linked to a minimum of one previous sale (cash collection without a previous sale indicates a transaction error)

    Sales Pays for Cash Collection

    1 0

    Entity Relationship DiagramMinimum Cardinalities

    Accounting 475

    5. Specify minimum relationship cardinalities

    CashCollections

    Sales

    Resource Event Agent

    Cash

    SalespersonInventory

    Customer

    Cashier

    Increases

    Lineitems

    Paysfor

    Receivedby

    Receivedfrom

    Madeto

    Partyto

    1 0 0

    01

    00

    0

    01

    1

    1

    1

    1

    ERD MethodologyData Modeling Reading example

    Accounting 475

    Summary of some ERD Rules

    Relationships go through EVENTS; there are not Resource Agent relationships

    Only one

  • Accounting 475

    Physical Modeling

    Once the ERD is finished you convert this diagram into relational database tables

    Then apply Normalization rules and make sure the database is in desired normal form

    Accounting 475

    Physical ModelingERD Conversion

    General Guidelines1) Create tables for each Entity and N:N relationship2) Primary key for entity table is a single numeric field;

    Primary key for N:N relationship table are two fields3) Link the resulting tables

    For tables in a 1:1 relationship, insert a foreign key in one ofthe two tables. In event-event relationships, put foreign key in later event table.

    For tables in a 1:N relationship, put foreign key in table of entity participating many times in relationship

    Accounting 475

    Coding

    1) Create and link tables in MSAccess2) Create forms for each event process3) Create forms for maintenance of each

    agent and resource entity4) Create queries and reports for each

    information process

    Accounting 475

    Effects of Databases on Accounting

    Mechanics of storing and retrieving accounting information change

    Journals and Ledgers are outputs of the system, not the core of the system

    Less emphasis on double-entry bookkeeping Some internal controls are built into the

    database structure

    ENDDatabase Design: Logical &

    Physical ModelingDatabase Accounting Systems

    Actg/IDS 475

    Review of ERD Modeling andDatabase Design

    Database Accounting SystemsActg/IDS 475

  • Accounting 475

    ERD Modeling Approach

    From the problem description determine what are the data elements to be captured in the database. These are fields within entities.

    Determine what entities those fields will be contained in. If you only need one data element about something that is a field. If

    you need several data elements about something, those are attributes (fields) about an entity.

    Sort the entities into types: Events anything that happens about which we want to capture

    information (transaction, meeting, call, appointment, order, sale, etc.) Agents people involved in those events Resources either assets (cash, inventory, etc) or anything else of

    value (services, processes) that are involved in the events, and about which the organization wants to record information.

    Accounting 475

    ERD Modeling Approach

    Connect up entities with appropriate relationships Determine the cardinality of the relationships

    The cardinality question is One record of the first entity can be associated with how many records of the second entity at minimumand maximum?

    In assigning cardinalities, use the normal guidelines, but remember: what determines the cardinalities are the business rules of the particular case!

    Accounting 475

    Database Design

    In a relational database we are collecting attributes in tables.

    Which attributes go in which tables and how are tables linked and queried?

    2 basic approaches

    Accounting 475

    Database DesignApproach 1

    Gather attributes from current business documents (invoices, master files, etc.)

    Group into tables according to most likely dependencies, add keys

    Use normalization rules to adjust table design to eliminate anomalies

    Eliminate derived attributes

    Accounting 475

    Database DesignApproach 2

    Use the Entity Relationship Diagram (REA version) to model data

    Convert the ERD into schema (table design) and determine all attributes and keys

    Check design against normalization rules Eliminate derived attributes

    ENDReview of ERD Modeling and

    Database Design

    Database Accounting SystemsActg/IDS 475