CPSC 333: Accounts Management System, Version One

Location: [CPSC 333] [Ongoing Examples] [Accounts Management System] Version One

This page was most recently modified on March 25, 1997


Problem Statement

This system is used to keep track of an individual's bank accounts.

A unique account number, a short account name (which isn't necessarily unique), a ``balance forward, '' and an ``opening date'' are maintained for each account.

The system also maintains about ``transactions'' - cash deposits or withdrawals - for the accounts. Each transaction refers to exactly one of the accounts that the system knows about, and each transaction has a transaction number which can be used to distinguish it from other transactions for the same account. The system generates transaction numbers automatically, by starting with transaction number ``1'' for each account, and incrementing the value for the transaction number used, every time a new transaction for the account is added. Each transaction also has a transaction date, a transaction amount (which is negative if the transaction is a ``cash withdrawal,'' and positive if it's a deposit), and a ``memo,'' which is a short description of the transaction (or its purpose).

The system will also be used to ``balance'' accounts by comparing information in the system with information that appears on bank statements. When the user receives a bank statement, he or she will wish to mark as ``registered'' the transactions that appear on the bank statement, and correct transactions if errors are discovered.

The user can also ask the system for the ``account balance'' that would be obtained by starting with the ``balance forward,'' and applying the transactions that refer to the account and that have been registered - which is something that the user might want to compare with a ``closing balance'' that appears on a bank statement. The user can request that an account balance be ``corrected,'' by entering the final balance that he thinks should be what one would get by applying the registered transactions to the opening balance (he probably ``thinks this'' because this is the closing balance on a bank statement); the system will respond by creating (and marking as registered) whatever transaction would be needed to make the account balances agree. Finally, the user can request that the account be ``cleared.'' This should cause all ``registered'' transactions to be applied to the ``balance forward'' in order to produce a new value for this - at which point the account's ``opening date'' is set to the current date, and all the account's registered transactions are deleted.

The system should be able to generate two reports, at the user's request: A listing of the account names and account numbers for the accounts currently maintained in the system, and an ``account listing'' for any given account. The account listing will include the account's opening date and balance forward, as well as a list of all the transactions that refer to it (in order by transaction number), and the balances that would be obtained by applying these transactions - so, this report looks like a bank statement for the account generally does.


References in Assignments

This system will be considered in several assignments.


Additional Information for Assignment #2

Entity-Relationship Diagram

Picture of ERD


Data Dictionary for Entity-Relationship Diagram

This uses an ``auxiliary definition'' to define some attributes with common data types (which was discussed via email and the newsgroup, during work on the first assignment).

Name: Account
Kind: E
Type: @account number + account name + balance forward + opening date + next transaction number
Description: Represents a user's bank account
Name: account name
Kind: At
Type: string
Description: A non-key attribute of Account
Name: account number
Kind: At
Type: integer
Description: Key attribute of Account
Name: balance forward
Kind: At
Type: currency
Description: Non-key attribute of Account
Name: currency
Kind: H
Type: real
Description: Represents an amount of money, in dollars and cents; should represent two digits after the decimal point (so that the unit of measure is actually ``dollars''); used to define balance forward and transaction amount
Name: memo
Kind: At
Type: string
Description: Non-key attribute of Transaction
Name: next transaction number
Kind: At
Type: integer
Description: Non-key attribute of Account; represents the transaction number that will be assigned to the next transaction that is created.
Name: opening date
Kind: At
Type: date
Description: Non-key attribute of Account
Name: registered?
Kind: At
Type: [ `yes' | `no' ]
Description: Non-key attribute of Transaction
Name: Transaction
Kind: WE
Type: @account number + @transaction number + transaction date + transaction amount + memo + registered?
Description Represents a cash deposit or withdrawal; depends on the entity Account
Name: transaction amount
Kind: At
Type: currency
Description: Non-key attribute of Transaction
Name: transaction date
Kind: At
Type: date
Description: Non-key attribute of Transaction
Name: transaction number
Kind: At
Type: integer
Description: Key attribute of Transaction

[Problem Statement] [References in Assignments] [ERD] [Data Dictionary]


Solution for Assignment #2, Question #1

Event List

All inputs are received from an ``Account Holder,'' and all outputs are sent to the ``Account Holder,'' as well.

The statements of ``Effects'' given below are completely optional, and weren't used in most examples shown before now. This can be used to make note of system responses that might not be obvious and might be overlooked.

Event Number: 1
Event Name: User Opens New Account
Inputs: account number, account name, balance forward
Outputs: status message
Error Conditions:
  1. Syntactically incorrect inputs
  2. Account number is already in use
Effects: A new ``account'' is created, using the current date as the account's ``opening date,'' and using ``1'' as the initial value for the ``next transaction number.''
Corresponds to Process #1.1

Event Number: 2
Event Name: User Changes Account Name
Inputs: account number, account name
Outputs: Error Conditions:
  1. Syntactically incorrect inputs
  2. Account number is not in use
Corresponds to Process #1.2

Event Number: 3
Event Name: User Closes Account
Inputs: account number
Outputs: status message
Error Conditions:
  1. Syntactically incorrect input
  2. Account number is not in use
Corresponds to Process #1.3

Event Number: 4
Event Name: User Requests List of Accounts
Inputs: none
Outputs: list of accounts
Error Conditions: none
Corresponds to Process #1.4

Event Number: 5
Event Name: User Requests Account Listing
Inputs: account number
Outputs: account listing, status message
Error Conditions:
  1. Syntactically incorrect input
  2. Account number is not in use
Corresponds to Process #2.5

Event Number: 6
Event Name: User Enters New Deposit
Inputs: account number, transaction date, deposit amount, memo
Outputs: transaction number, status message
Error Conditions:
  1. Syntactically incorrect inputs
  2. Account number is not in use
  3. Deposit amount is $0.00 or represents a negative amount of funds
Effects: A new transaction is created; the ``transaction number'' used is the current value of the account's ``next transaction number,'' and this is incremented when this new transaction is created. The new transaction's ``transaction amount'' is the input, ``deposit amount.''
Corresponds to Process #2.1

Event Number: 7
Event Name: User Enters New Withdrawal
Inputs: account number, transaction date, withdrawal amount, memo
Outputs: transaction number, status message
Error Conditions:
  1. Syntactically incorrect inputs
  2. Account number is not in use
  3. Withdrawal amount is $0.00 or represents a negative amount of funds
Effects: A new transaction is created; the ``transaction number'' used is the current value of the account's ``next transaction number,'' and this is incremented when this new transaction is created. The new transaction's ``transaction amount'' is the negation of the input, ``withdrawal amount.''
Corresponds to Process #2.2

Event Number: 8
Event Name: User Corrects Transaction
Inputs: account number, transaction number, transaction date, transaction amount, memo
Outputs: status message
Error Conditions:
  1. Syntactically incorrect inputs
  2. Account number is not in use
  3. There is no transaction, with the specified transaction number, for the given account
  4. Transaction amount is $0.00
Corresponds to Process #2.3

Event Number: 9
Event Name: User Requests Deletion of Transaction
Inputs: account number, transaction number
Outputs: status message
Error Conditions:
  1. Syntactically incorrect inputs
  2. Account number is not in use
  3. There is no transaction, with the specified transaction number, for the given account
Corresponds to Process #2.4

Event Number: 10
Event Name: User Registers Transaction
Inputs: account number, transaction number
Outputs: status message
Error Conditions:
  1. Syntactically incorrect inputs
  2. Account number is not in use
  3. There is no transaction, with the specified transaction number, for the given account
  4. The specified transaction is already registered
Corresponds to Process #3.1

Event Number: 11
Event Name: User ``Unregisters'' Transaction
Inputs: account number, transaction number
Outputs: status message
Error Conditions:
  1. Syntactically incorrect inputs
  2. Account number is not in use
  3. There is no transaction, with the specified transaction number, for the given account
  4. The specified transaction is not registered
Corresponds to Process #3.2

Event Number: 12
Event Name: User Requests Account's Balance
Inputs: account number
Outputs: balance, status message
Error Conditions:
  1. Syntactically incorrect input
  2. Account number is not in use
Corresponds to Process #3.3

Event Number: 13
Event Name: User Requests Correction of Balance
Inputs: account number, balance
Outputs: transaction number, transaction date, transaction amount, memo, status message
Error Conditions:
  1. Syntactically incorrect input
  2. Account number is not in use
  3. No correction is needed (that is, new balance agrees with old)
Effects: The difference between the input balance and the balance that computed for the account is used as the ``transaction amount'' for a new transaction (if this is nonzero); the ``transaction date'' is the current date, ``memo'' is ``Account Correction,'' and the new transaction is automatically entered as ``registered''
Corresponds to Process #3.4

Event Number: 14
Event Name: User Requests Clearing of Account
Inputs: account number
Outputs: balance forward, opening date, status message
Error Conditions:
  1. Syntactically incorrect input
  2. The account number is not in use
Effects: New ``balance forward'' is obtained by applying all the registered transactions (for this account) to the current one, ``opening date'' is set to the current date, and the registered transactions are all deleted
Corresponds to Process #3.5

Notes: The most important ``last minute change,'' that might not have been noticed by groups who finished early, would probably be the addition of ``next transaction number'' as an attribute of ``Account.'' This won't affect the above event list, but it might change the way the ``next transaction number'' is represented on the DFDs that are produced from it.

Since no one asked about conditions that should be checked when an account is closed, no conditions were included here. It might, or might not, ``really'' be acceptable to close (and delete) an account before all transactions for it have been registered. As well, no outputs (apart from a status message) are listed above, but at least one - the account's final balance - would be plausible. We'll pretend that the user would have obtained an ``account listing'' for it before closing it, so this output isn't listed, above.

Possibly the least sensible output listed above is the ``transaction date'' included when an ``account correction'' is made - because this is always the current date. The ``memo,'' which is always ``Account Correction,'' seems unnecessary as well. They're included here, because, I said they should be when answering someone's question (and not because they really seem to be useful).

Finally, additional events might be plausible. For example, it might be reasonable for the user to ask to see a specific transaction, and for this system then to display the transaction's date, amount, and memo. One could also combine together some of the events given above - for example, one might combine together events #6 and #7 to produce a single event, ``User Enters New Transaction,'' and one might replace events #10 and #11 by a single event, ``User Changes Transaction's Registration'' (which would ``toggle'' the status from unregistered or registered, or vice-versa). You could break some of these events down into several, as well. For example, event #8 might possibly be replaced by several events, with names like ``User corrects transaction amount,'' ``User corrects transaction date,'' and so on. These variations will all be acceptable.

However, the event list that's given above is the one that will be used to prepare a leveled set of data flow diagrams, in the rest of the solutions for this question.

Context Diagram

Picture of Context Diagram

If you've viewing this using Netscape or another sufficiently poweful browser, then you can navigate through the data flow diagrams by clicking on the objects whose definition or refinement you wish to see.

Data Dictionary for Entity-Relationship and Data Flow Diagrams

Name: Account
Kind: E
Type: @account number + account name + balance forward + opening date + next transaction number
Description: Represents a user's bank account
Name: account
Kind: DF
Type: Account
Description:
Name: Accounts
Kind: DS
Type: { Account }
Description:
Name: accounts
Kind: DF
Type: { account }
Description:
Name: account listing
Kind: DF
Type: account number + account_name + opening date + balance forward + transaction listing
Description: Lists information for an account currently in the system
Name: account name
Kind: At, DF
Type: string
Description: A non-key attribute of Account
Name: account number
Kind: At, DF
Type: integer
Description: Key attribute of Account
Name: balance
Kind: DF
Type: currency
Description:
Name: balance forward
Kind: At, DF
Type: currency
Description: Non-key attribute of Account
Name: currency
Kind: H
Type: real
Description: Represents an amount of money, in dollars and cents; should represent two digits after the decimal point (so that the unit of measure is actually ``dollars''); used to define balance, balance forward, deposit amount, transaction amount, updated balance, and withdrawal amount
Name: deposit amount
Kind: DF
Type: currency
Description: Must be greater than zero
Name: list of accounts
Kind: DF
Type: { account number + account name }
Description: Used to list accounts currently in system
Name: memo
Kind: At, DF
Type: string
Description: Non-key attribute of Transaction
Name: next transaction number
Kind: At
Type: integer
Description: Non-key attribute of Account; represents the transaction number that will be assigned to the next transaction that is created.
Name: opening date
Kind: At, DF
Type: date
Description: Non-key attribute of Account
Name: registered?
Kind: At
Type: [ `yes' | `no' ]
Description: Non-key attribute of Transaction
Name: status message
Kind: DF
Type: string
Description: Used to report error conditions and normal command completions
Name: Transaction
Kind: WE
Type: @account number + @transaction number + transaction date + transaction amount + memo + registered?
Description Represents a cash deposit or withdrawal; depends on the entity Account
Name: transaction
Kind: DF
Type: Transaction
Description:
Name: Transactions
Kind: DS
Type: { Transaction }
Description:
Name: transactions
Kind: DF
Type: { transaction }
Description:
Name: transaction amount
Kind: At, DF
Type: currency
Description: Non-key attribute of Transaction
Name: transaction date
Kind: At, DF
Type: date
Description: Non-key attribute of Transaction
Name: transaction listing
Kind: H
Type: { transaction record }
Description: Used to define account listing
Name: transaction number
Kind: At, DF
Type: integer
Description: Key attribute of Transaction
Name: transaction record
Kind: H
Type: transaction number + transaction date + transaction amount + memo + registered? + updated balance
Description: Used to define transaction listing
Name: updated balance
Kind: H
Type: currency
Description: Used to define transaction record
Name: withdrawal amount
Kind: DF
Type: currency
Description: Must be greater than zero

Additional Information for Assignment #3

Context Diagram

Picture of Context Diagram

This version of the system includes a simple menu-based interface, and the use of text files to store system data between system executions. Using Netscape, you can navigate through the data flow diagrams by clicking the objects whose definition or refinement you wish to see.

Revised Data Dictionary for Use with Assignment #3

Data Dictionary for Entity-Relationship and Data Flow Diagrams

Name: Account
Kind: E
Type: @account number + account name + balance forward + opening date + next transaction number
Description: Represents a user's bank account
Name: account
Kind: DF
Type: Account
Description:
Name: Accounts
Kind: DS
Type: { Account }
Description:
Name: accounts
Kind: DF
Type: { account }
Description:
Name: account info
Kind: DF
Type: account number + account_name + opening date + balance forward + transaction listing
Description:
Name: account listing
Kind: DF
Type: string
Description: Lists information for an account currently in the system
Name: account name
Kind: At, DF
Type: string
Description: A non-key attribute of Account
Name: account number
Kind: At, DF
Type: integer
Description: Key attribute of Account
Name: account request
Kind: CF
Type:
Description:
Name: accounts file
Kind: DF
Type: file
Description: Used to store account and transaction data when system is not in use.
Name: balance
Kind: DF
Type: currency
Description:
Name: balance forward
Kind: At, DF
Type: currency
Description: Non-key attribute of Account
Name: clear
Kind: CF
Type:
Description:
Name: continue
Kind: CF
Type:
Description:
Name: correct
Kind: CF
Type:
Description:
Name: currency
Kind: H
Type: real
Description: Represents an amount of money, in dollars and cents; should represent two digits after the decimal point (so that the unit of measure is actually ``dollars''); used to define balance, balance forward, deposit amount, transaction amount, updated balance, and withdrawal amount
Name: delete
Kind: CF
Type:
Description:
Name: deposit
Kind: CF
Type:
Description:
Name: deposit amount
Kind: DF
Type: currency
Description: Must be greater than zero
Name: display
Kind: CF
Type:
Description:
Name: file status
Kind: DF
Type: [ 'ok' | 'file not found' | 'permission denied' ]
Description:
Name: list
Kind: CF
Type:
Description:
Name: list of accounts
Kind: DF
Type: { account number + account name }
Description: Used to list accounts currently in system
Name: memo
Kind: At, DF
Type: string
Description: Non-key attribute of Transaction
Name: menu
Kind: DF
Type: string
Description: Used to display commands for selection
Name: next transaction number
Kind: At
Type: integer
Description: Non-key attribute of Account; represents the transaction number that will be assigned to the next transaction that is created.
Name: new
Kind: CF
Type:
Description:
Name: opening date
Kind: At, DF
Type: date
Description: Non-key attribute of Account
Name: prompt
Kind: DF
Type: string
Description: Used to request input from Account Holder
Name: quit
Kind: CF
Type:
Description:
Name: ready
Kind: CF
Type:
Description: Used by initialization subystem to report successful completion
Name: reconciliation
Kind: CF
Type:
Description:
Name: register
Kind: CF
Type:
Description:
Name: registered?
Kind: At
Type: [ `yes' | `no' ]
Description: Non-key attribute of Transaction
Name: selection
Kind: DF
Type: character
Description: Used by Account Holder to select from a menu or answer a simple question from the system
Name: status message
Kind: DF
Type: string
Description: Used to report error conditions and normal command completions
Name: syntax error
Kind: CF
Type:
Description:
Name: Transaction
Kind: WE
Type: @account number + @transaction number + transaction date + transaction amount + memo + registered?
Description Represents a cash deposit or withdrawal; depends on the entity Account
Name: transaction
Kind: DF
Type: Transaction
Description:
Name: Transactions
Kind: DS
Type: { Transaction }
Description:
Name: transactions
Kind: DF
Type: { transaction }
Description:
Name: transaction amount
Kind: At, DF
Type: currency
Description: Non-key attribute of Transaction
Name: transaction date
Kind: At, DF
Type: date
Description: Non-key attribute of Transaction
Name: transaction listing
Kind: H
Type: { transaction record }
Description: Used to define account listing
Name: transaction number
Kind: At, DF
Type: integer
Description: Key attribute of Transaction
Name: transaction record
Kind: H
Type: transaction number + transaction date + transaction amount + memo + registered? + updated balance
Description: Used to define transaction listing
Name: transaction request
Kind: CF
Type:
Description:
Name: unregister
Kind: CF
Type:
Description:
Name: updated balance
Kind: H
Type: currency
Description: Used to define transaction record
Name: valid account name
Kind: DF
Type: account name
Description: Represents an account name whose syntax has been checked
Name: valid account number
Kind: DF
Type: account number
Description: Represents an account number whose syntax has been checked
Name: valid accounts command
Kind: DF
Type: [ '1' | '2' | '3' | '4' | 'M' | 'Q' ]
Description:
Name: valid balance forward
Kind: DF
Type: balance forward
Description: Represents a balance forward whose syntax has been checked
Name: valid command
Kind: DF
Type: [ '1' | '2' | '3' | 'Q' ]
Descripton:
Name: valid reconciliations command
Kind: DF
Type: [ '1' | '2' | '3' | '4' | '5' | 'M' | 'Q' ]
Description:
Name: valid transactions command
Kind: DF
Type: [ '1' | '2' | '3' | '4' | '5' | 'M' | 'Q' ]
Description:
Name: withdrawal
Kind: CF
Type:
Description:
Name: withdrawal amount
Kind: DF
Type: currency
Description: Must be greater than zero

Location: [CPSC 333] [Ongoing Examples] [Accounts Management System] Version One


Department of Computer Science
University of Calgary

Office: (403) 220-5073
Fax: (403) 284-4707

eberly@cpsc.ucalgary.ca