| << 16.3.1- Writing a Component that Accesses a Data Store | Chapter16 | 16.3.3- Building the Script Component >> |
Setting up the Database
Once again, we've provided two types of database file with the source code for this example:
- Bank.mdb – an Access database file. If you're planning to use the simpler Access database, then all you need to do is place the Bank.mdb file somewhere on your hard disk (in this case, I placed it in my C:\datastores\ folder).
- Bank_Data.mdf – a database file for use with MSDE. If you're using MSDE, then place the Bank_Data.mdf file in your \MSSQL7\Data\ folder. MSDE will detect the file automatically when we need it.
Whichever you use, you'll find that there are two tables in the Bank database. The first is the Account table, which contains information relating to the ID and ownership of each account. It contains two fields:
|
The Account Table |
|
|
Field |
Purpose |
|
Account |
The ID number of the account |
|
HolderName |
The name of the account holder |
The second is the Register table. This table is a register of all the actions that take place on all the accounts in the bank.
|
The Register Table |
|
|
Field |
Purpose |
|
SeqID |
An integer indicating the position in the overall sequence of all transfers, in chronological ordering |
|
AccountID |
A string of the form 1111-1111, which uniquely identifies the account |
|
CheckNumber |
A check number, entered by the user when the transfer request is made |
|
TransDate |
The date of the transfer |
|
TransType |
The type of action being made on the account – W for withdrawal or D for deposit |
|
TransNote |
An optional string containing notes about the transfer |
|
Amount |
The amount being transferred into or out of the account |
|
PriorBalance |
The balance immediately before the action |
|
ResultingBalance |
The balance immediately after the action |
Note that the Account table itself doesn't have a Balance field. Instead, when we need to establish the account's current balance, we will search the register table for the most recent transfer relating to that account – and we'll take the current balance value from there.
We will also assume, for simplicity, that cash transfers in this system are between two accounts that are listed in the Account table of the database. There will be no cash transfers to or from accounts held at other banks!
| << 16.3.1- Writing a Component that Accesses a Data Store | Chapter16 | 16.3.3- Building the Script Component >> |

RSS
