Information Technology Reference
In-Depth Information
13. The zip code file
One thing that bothers me is unnecessary work. If I'm at a web site and ordering
some stuff to build a time machine, I'll probably have to enter some address information
so they'll know where to send the materials. This includes street address, city, state and
zip code. I can understand entering the street address, but wouldn't just keying the zip
code relieve me of inputting the city and state? This is so because each zip code is tied to
one specific state and city. With that in mind, this means that our account number file
need not have all three of these fields on file records.
Sly in accounting wants a simple online program - not the one we talked about
earlier - to list account number, last name, and the address fields. The following program
will do that using a new file, the zip code file. Our account number file no longer carries
the state and city, so we have to get it from the zip file. The advantage of this extra read
could be used in adding or changing records to our main file - especially if we changed
city, state or zip code. Any specific change of this type could cause problems since
modifying the city or state could mess up the zip code. Changing the city from Buffalo to
Boston means that the zip that you had on the file is not appropriate for Boston. This
means that a change to the city needs a modification to the zip code and perhaps to the
state as well. Obtaining city and state from the zip code file can make things more precise
and also save work for the operator - and the programmer, as well. Another advantage of
accessing the zip code file is that the operator can't input an invalid zip code on an add or
an update.
You might say that the extra reads of the zip code file may slow down the system
but file access these days is quite fast so it shouldn't be a factor. If it is though, the city
and state could be stored on the account file since disk space is so cheap and available
and this may be preferable to extra I /O. It really depends on your system. You will note
that the accuracy of the data on the zip code file is very important and someone is
responsible for it. Once again the data is in the hands of individuals and we will assume
some integrity on their part.
Another possibility is to put the zip code data into a large table, which our
program can access. This method of getting information will be much faster than getting
it from reading a file since the approach is internal as we have the city and state available
already and need not do any I/O to an external file. Once again the table will change but
many systems keep up with this change because the table is dynamic. This means that we
bring it into our program as it currently exists so that all the latest changes to it are
included. I'll talk about a topic related to this in another chapter when I get into copy
members .
This program is named after the requester.
program-name : acctsly
define file acctfile record account-record status acct-status structure
account-number integer( 9)
last-name character (18)
field character (58)
Search WWH ::




Custom Search