Information Technology Reference
In-Depth Information
5. File access
If you work with different computers you will hear about flat files, sequential
files, indexed or keyed files and databases. That's only the beginning. The first
designation is not used to represent a file that was run over by a steamroller but rather a
simple file that we can read one record after the other and can't update. There are no keys
in the records of the file so we can't read a specific record without reading every other
record, at least until we get to that record. This is also what is referred to as a sequential
file. These types of files can be used quite successfully to back up a file and restore it and
either can be done quickly. An equivalent music device is the cassette or eight-track, each
of which results in listening to every song in order or fast forwarding to get to the song
you wish to hear. I'm not sure where the term, flat file originated, but why do we need the
designation when the term sequential file suffices?
The next type of file is an indexed file or keyed file, which has some sort of key in
it. This enables us to get to a specific record without reading every other record in the file.
This could save us some time since we could obtain the record we want quite quickly, but
we have to know the key to the record or at least part of that key or some other significant
field. If the key was the account number and we didn't know it but we knew the
customer's name, the computer program could be intelligent enough to give us a list of
accounts to chose from and one of those could be the one we wanted. Many systems give
you this option. An equivalent music device is the record or CD since either can get us to
a specific song without much effort, unlike the cassette or obsolete eight-track.
If you have a keyed file, the keys are usually unique, that is, you won't have two
records with the same key. Nonetheless you can have a file that is an indexed file with
duplicate keys. There is a reason for this, which I won't get into. Just be forewarned.
There are all kinds of indexed files and the differences are due to the company that
developed them or the time when they came out. If you know one index file method you
can adapt to any other.
The last designation is a database, and as I mentioned earlier every file is a
database as each has data that is a bas e for our system. Some will argue that a database
needs to have a key and this equates to an indexed file, but certainly a sequential file is a
database - with limitations. Thus, every database is a file. The distinction between files
and databases is a very fine point, which I won't belabor.
If you work with other systems, you will note that the program using a file may
have to open it, read it and finally close it. The language that uses this file may actually
do a close of the file as the program ends just in case you somehow forgot to do it. This
suggests to me that the close that seems to be required is not really necessary. In our
sample report program earlier we neither had to open nor close the file because our
system is quite intelligent, which is what all systems should be.
For our system, all the files will be indexed files. They will all have unique keys
and we can access records in the files by keys as well as read those files in a sequential
manner. That is exactly what we did in our very first program to list the fields on the
Account balance report. We will get into processing data by specific keys later. The file
we used in the previous chapter was also processed sequentially. In our system, the field
Search WWH ::




Custom Search