Common Storage Devices
(Also known as Storage Media)
Magnetic disk (including floppy disk and hard disks)
Magnetic tape
CD-ROM (including CD-R, CD-RW)
Zip Disks
DAT
Some storage devices allow you to skip through your file to find the place you want (Direct Access Media). Other media devices require you to go through all the data to find the piece you want.
Files
Files are made up of records, records are made up of fields
Files - Records - Fields
A Field is:
A Record is:
A File is:
Logical vs. Physical File Organisation
The physical storage of a file is how it is stored on the storage medium.
The logical storage of a file is how it looks to the user when it is being processed.
File Access Methods
A serial access file has data stored in the order in which it was written. New data goes to the end of the file. To read a record from the file it is necessary to read through all of the records from the start of the file until reaching the required record.
A sequential access file has data stored in the order of a key field.
An indexed sequential file stores data in the order of a key field, but also has an index holding the key field values and the address at which they are stored. This allows both sequential and direct access.
A direct access file is one where any record can be accessed without having to access other records first. This is also known as Random Access.
NB Direct Access Files can only be stored on Direct Access Media.
Why are files
stored on a tape cartridge always serial access?
Advantages of Direct Access over Sequential Access
Records can be accessed in any chosen order
Records do not have to be put into any order when the file is created
Selected records can be accessed far more quickly from direct access files.
Advantages of Sequential Access over Direct Access
Sequential Files can be stored on Tape as well as disk
It is easier to write programs to handle sequential files
Advantages of Sequential Access over Serial Access
Updating master files with transaction files is made more easy using sequential files since they are both in the same order to begin with
What would be the
best method of access to find one record in a large file -
sequential or direct?
Why choose different methods of file access?
Some file organisations are better than others for particular tasks. These are some of the reasons why a particular file organisation may be chosen:
The number of records to be accessed - If not many records are to be accessed, direct access is more efficient. If most records are to be accessed during processing then sequential access is better. This file activity is measured by hit rate. (See later)
The size of the file - In large files sequential searches take a long time, so direct access is better. In small files time delay is less important, so sequential access is acceptable.
The type of application - Sequential access is usually suitable for batch applications, but on line applications usually require direct access to give a fast response time.
The type of storage media - Magnetic tape is a serial access medium so direct access cannot be used.
Relational Databases
Information is very valuable and must be organised so that it can be accessed as easily and quickly as possible. A database not only stores the data, but also organises the data and controls access to it with a program called the Database Management System (DBMS).
Flat files
The earliest data storage computer systems used flat files- A fiat file is like information stored in a grid or table.
Each row in the table contains a record information about a particular person or thing.
Each column in the file contains information on one field, for example Name, Type, and so on.
Primary key
No two records in a file can be the same or it will lead to confusion. For example, if two people have the same name, there must be some other means of identifying which record refers to which person.
Therefore each record has to have a unique identifier - something that makes it different from all the other records - called the primary key.
A persons surname cannot be used as a primary key because:
It is a good idea to create a special field to act as the primary key. Sometimes there is an obvious candidate, for example in a garage keeping a file on cars it repairs, the registration number would be an ideal primary key.
Why are flat files inefficient?
In flat files data tends to be stored in several places. For example, in a school information system information about teachers may be stored on the file for classes, as well as on an administration file holding employment information.
This is very inefficient because repeating data wastes disk space. It could also lead to inconsistent data if the teacher's address was stored differently in the two files.
We could store the information more efficiently by using a database with two files. The class table and the teacher table.

Entity Relationship Diagram
This diagram shows the relationship between the teacher and the class. The diagram shows that a teacher can teach more than one class. It also shows that each class can only be taught by one teacher.
We can find out the name and address of each teacher from the teacher table
How is a database different from a flat file?
There can be more than one table in a database. A flat file database has only one table. Each table in a database contains information about an entity, for example teacher, class, and so on
What is a relational database?
In a relational database the tables are related. This means the tables are linked together in some way. For example in the school database, we can create a relationship between the teacher number field in the teacher table and the class code field in the class table.
In the class table, class code is the primary key as it uniquely identifies the class. However it is not unique in the teacher table as one teacher can teach more than one class. By looking in the class table we can find out the teacher code of the teacher who takes that class. By looking in the teacher table we can find out more information about the teacher.
Flat files or databases?
Flat files have been used by computers for many years. They are usually used for one particular specific purpose. For example, a company might maintain an employee file used to produce a pay slip. The personnel department might also have a file of employees' records, which holds some different data.
When information is held on separate files in different parts of an organisation, difficulties arise. Information on one file might be up-dated but not on the other, leading to inconsistencies. Most businesses now use databases to organise their data more efficiently and to give flexibility.
The file approach is program-oriented; the needs of the program determine how it is stored. The database approach is data-oriented, the type of data determines how it is stored. This gives it a number of advantages over a file-based system.
Advantages of the database approach
Disadvantages of the database approach
NB
a table is another name for a file in a database
a relationship is a link between two tables
an entity is a subject about which data is stored
Types of relationship
A relational database consists of a number of entities or tables which are related in some way. Entities can be related in any one of three ways:
Examples
Each product in a supermarket has a bar code. The relationship between product name and its bar code is one-to-one.
One supermarket company has many stores. This is an example of a one-to-many relationship.
There are many different products, each on sale in many different stores. This is an example of many-to-many relationship.
Database Normalisation
Normalisation means structuring the database in the most efficient manner. In a relational database it is not possible to have many-to-many relationships as these will lead to ambiguities.
Tables should be structured in such a way that
Database administration
The Data Dictionary
The data dictionary is information about the database, such as:
The Database Management System (DBMS)
The DBMS is the program that provides an interface between the database and the user in order to make access to the data as simple as possible, it has several other functions:
Database security
As we have already seen data stored in a database is very valuable. Good security to prevent loss, theft or corruption of data is vital. Relational databases such as Microsoft Access and Paradox are multi-access databases. This means that on a network, more than one user may access the same database at the same time, How can the software cope with two or more users opening the same file, making alterations and yet maintain the integrity of the database?
Relational databases provide different methods of database security:
Databases or a manual system?
Why should a video shop use a database? Could a manual system be better than a database system? Both systems record details of members and who has hired which video. (This could easily be done in a paper-based system by using a list of all videos and the name of the hirer written next to it.)
A manual system is cheaper, unlikely to break down and requires little training. However the computerised system will probably be better for the following reasons:
Management information is automatically gathered, for example details of each hiring, financial details, how many times a customer has hired a video and how many times a video has been hired. These figures can be used in preparation of accounts or to analyse which videos are most popular.
Better service to customers. Using a bar code reader to enter the video code and the member code is very quick. Queues at the counter will be shorter.
Details of members and videos can be found and printed quickly.
The names and addresses of members can be used for advertising purposes in a direct-mail shot. The database can be queried to come up with a list of people who havent hired a video for six months and a letter written offering them a discount if they hire a film this week. The letter can be personalised using the mail-merge from a word-processing package.
Similarly automatic reminders can be sent out to members who have not returned a video by the due date.
The database can be extended to include the members date of birth. The computer can be used to ensure that a member is old enough to hire, say, an 18 video.