CPSC 333: Solutions for Assignment #3, Question #1

Location: [CPSC 333] [Assignment #3] [Accounts Management System, Version One] Solution for Assignment #3, Question #1

This page was most recently modified on April 2, 1997


Data Tables

Table Name: Accounts
Corresponds To: Entity ``Accounts''
Columns:
Table Name: Transactions
Corresponds To: Weak Entity ``Transactions''
Columns:

In all cases above, columns correspond to (and have the sames names as) attributes of the corresponding entity or weak entity.

There was, essentially, only one right answer for this part of the question, because the entity-relationship diagram and a data dictionary for it had been provided, and a well defined (and ``deterministic'') process for mapping entity-relationship diagrams to sets of data tables had also been supplied.

Interface Functions

While there was only ``one right answer'' for the first part of this question, there could be quite a few correct answers for this part of the question. You might have chosen to replace one of the ``interface'' functions for reporting or changing information, given below, with collections of several operations. You might also have chosen to use a somewhat more ``intelligent'' interface, by including functions to list all registered transactions for a given account, etc.

The interface given below is intended to be quite simple, and uniform. The interface given below for ``Transactions'' is the one that should be used for Question 2 on Assignment #4.

No attempt has been made here to choose function or parameter names that could be used in source code, since multiple word names are used with words separated by spaces. However, you can obtain a name that's usable in source code easily, by replacing each space with an ``underscore'' character.

The same ``Assumption'' will be made for every function listed below - namely, that the inputs are syntactically correct. Put another way, it's up to the rest of the system to validate the syntax of values.

Almost each of these functions has one or more ``error conditions'' that should be checked and reported. A ``status code'' will be used to report these. This will be assumed to be a nonnegative integer, with a value between 0 and k, when there are k distinct (and mutually exclusive) kinds of errors that can occur. The value 0 will always be used to report that no errors were found, while a different positive value will be used for each kind of error.

If you're using C or C++ to implement the system then you can let the ``status code'' be the value returned by the function, rather than explicitly listing ``status code'' as a separate output - so, ``status code'' won't be listed as an output in the descriptions given below.

If you aren't using a language that makes it possible (or convenient) to return a status code in this way, then you should list ``status code'' as the final output, for every operation in which it's possible for a nonzero status code to be returned.

Finally, this is clearly not (quite) in the format that's previously been used for process specifications (although the same information is included); obviously, it won't be expected that you followed this format in your submissions for the assignment. It's also true that it won't be assumed that you'll have listed all the ``assumptions'' that are given below.

Interface for ``Accounts''

Name: Initialize Accounts
Inputs: none
Outputs: none
Assumptions: none
Error Conditions and Status Codes: none
Effects: If this is the first interface function called (after the system is initiated) then the data area is initialized to be empty (that is, to contain no accounts). Otherwise (that is, if other interface functions have been used), it should have no effect.
Name: Create New Account
Inputs: account number, account name, balance forward, opening date, next transaction number
Outputs: none
Error Conditions and Status Codes:
1 - account number is already in use
Effects (or ``Processing Details''): A new account is created using the values supplied.
Name: Update Account
Inputs: Same as for ``Create New Account''
Outputs: none
Error Conditions and Status Codes:
1 - account number is not in use
Effects: The account with the given account number is updated - the values for all its non-key attributes are replaced using the corresponding input values.
Name: Delete Account
Inputs: account number
Outputs: none
Assumptions: There are currently no transactions for the given account included in the ``Transactions'' data area.
Error Conditions and Status Codes:
1 - account number is not in use
Effects: The account with the given account number is deleted (whether there are transactions for it in the ``Transactions'' data store, or not).
Name: Get Account
Inputs: account number
Outputs: account name, balance forward, opening date, next transaction number
Error Conditions and Status Codes:
1 - account number is not in use
Effects: The values of the non-key attributes are returned for the account corresponding to the input ``account number.'' If the account number was not found, then you can use any values you want (of the expected types) as outputs, since the status code (or function value) will flag the fact that the account number wasn't found.
Name: List All Accounts
Inputs: none
Outputs: account numbers
Error Conditions and Status Codes: none
Effects: A sequence of account numbers (listed in increasing order), for all the accounts currently stored, is returned as output.

Interface for ``Transactions''

Please read the information given above about how to interpret these function descriptions, if you haven't already.

Name: Initialize Transactions
Inputs: none
Outputs: none
Assumptions: none
Error Conditions and Status Codes: none
Effects: If this is the first interface function used (after the system has been initiated) then the data area is initialized to be empty (that is, to include no transactions). Otherwise (that is, if other interface functions have already been used) it should have no effect.
Name: Create New Transaction
Inputs: account number, transaction number, transaction date, transaction amount, memo, registered?
Outputs: none
Assumptions: There is an ``account'' stored in the ``Accounts'' data area that has the account number that's included in the input.
Error Conditions and Status Codes:
1 - There is already a transaction with the given account number and transaction number
Effects: A new transaction is created using the values supplied.
Name: Update Transaction
Inputs: Same as for ``Create New Transaction''
Outputs: none
Error Conditions and Status Codes:
1 - There is no transaction with the given account number and transaction number.
Effects: The transaction with the given account number and transaction number is updated - the values for its non-key attributes are replaced using the corresponding input values.
Name: Delete Transaction
Inputs: account number, transaction number
Outputs: none
Error Conditions and Status Codes:
1 - There is no transaction with the given account number and transaction number.
Effects: The transaction with the given account number and transaction number is deleted (if one is found).
Name: Get Transaction
Inputs: account number, transaction number
Outputs: transaction date, transaction amount, memo, registered?
Error Conditions and Status Codes:
1 - There is no transaction with the given account number and transaction number.
Effects: The values of the non-key attributes are returned for the transaction that corresponds to the inputs. If no such transaction was found, then any values (of the expected types) can be returned as output, since the status code will flag the fact that the account number and transaction number weren't found.
Name: List Transactions for Account
Inputs: account number
Outputs: transaction numbers
Error Conditions and Status Codes: none
Effects: A sequence of transaction numbers (listed in increasing order), for the transactions (in the system) with the given account, is returned as output.

Location: [CPSC 333] Assignment #3] [Accounts Management System, Version One] Solution for Assignment #3, Question #1


Department of Computer Science
University of Calgary

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

eberly@cpsc.ucalgary.ca