Chapter 11: Sequential File Organization - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Chapter 11: Sequential File Organization

Description:

... generate the white pages of telephone directory would be sorted by subscriber ... be useful to have a telephone directory with records sorted by subscriber ... – PowerPoint PPT presentation

Number of Views:4341
Avg rating:3.0/5.0
Slides: 19
Provided by: Dew
Category:

less

Transcript and Presenter's Notes

Title: Chapter 11: Sequential File Organization


1
Chapter 11Sequential File Organization
2
What is Sequential Organized File?
  • In sequential organized file, the records are
    written consecutively when the file is created
    and must be accessed consecutively when the file
    is later used for input.
  • In many cases the records of a sequential file
    are ordered by the value of some field in each
    record. Such file is said to be a sorted file
    the field whose value is used to determine the
    ordering is known as the sort key.
  • A file may be sorted in ascending or descending
    order by a sort key comprised of one or more
    fields.

3
Structure of a Sequence File
Beginning of file
End of file
4
Ordering Records
  • Processing requirement determine the appropriate
    order for sorting the records of a sequential
    file
  • For example, the records of a sequential file
    used to generate the white pages of telephone
    directory would be sorted by subscriber last name
    or first name. However, in some cases, it may be
    useful to have a telephone directory with records
    sorted by subscriber address, or by zip code, or
    type of business.
  • But if the directory data are sorted as a
    sequential file, they can be in only one sorted
    order. One sequential file or records cannot be
    in sorted order by last name, first name and also
    be in sorted order by address.
  • To satisfy the sort requirement, you will have
    three sequential files. One is sorted by first
    name. Another one is sorted by last name. And the
    last file is sorted by address. These three
    sequential files would contain the same data but
    be sequenced differently.

5
Processing Sequential File
  • Because the records of a sequentially organized
    file must be accessed consecutively, sequential
    files are used more commonly in batch processing
    than in interactive processing.
  • For example, a sequential file of customer data (
    names, addresses, credit ratings, and the like)
    could be accessed in batch mode to print mailing
    labels to advertise a special sale each customer
    record would be accessed.
  • A sequential file of employee payroll data could
    be accessed batch mode to generate paychecks.

6
Advantages and Disadvantages
  • The major advantage of the sequential technique
    of organizing files is the ability to access the
    next record quickly. As long as the pattern of
    access to a sequential file matches the ordering
    of records on the file, access times are very
    good. However, if a programs patterns of access
    do not match the record ordering pattern, then
    performance of the program can be terrible.
  • Another advantage of sequential file organization
    is its simplicity.

7
Storing Sequential Files
  • There are two basic classes of secondary storage
    devices serial-access and direct access devices.
  • On a serial-access storage device, the time
    required to access two records is a function of
    the space between their locations (addresses) on
    the device. It takes longer to access them if
    they are far apart than if they are closer
    together.
  • On a direct-access storage device, the time
    required to access two records is not necessarily
    dependent on their relative locations.

8
Storing Sequential Files
  • Sequential files can be stored on either serial
    or direct-access devices.
  • The serial-access devices are considerably less
    expensive than the direct-access devices on a
    computer system.
  • For example, tape drives is less expensive than
    the disk drives.
  • The direct-access storage devices on a computer
    system nearly always provide larger capacities
    and faster data access than do the serial devices
    on the machine.

9
Magnetic Tape
  • The tape medium is a strip of thin, flexible
    plastic called Mylar, with a coating of
    ferric-oxide film. The tape is kept on a reel,
    which is mounted on a tape drive for read/write
    access.
  • The records on the tape are stored in physically
    sequential order. The time required to access two
    records is a function of how far apart they are
    on the tape. The best case is that the second
    record would appear immediately following the
    first the worst case is that the second record
    would be at the other end of the tape.

10
Data Representation and Density
  • Data are recorded digitally on the tape medium as
    magnetized spots in the ferric-oxide film
    coating.
  • Positive magnetization represents a 1-bit, while
    negative magnetization represents a 0-bit, or
    vice versa.
  • The magnetized areas are not randomly located on
    the medium rather they are arranged in tracks,
    which run parallel to the edge of the tape.
  • There are usually nine tracks on a tape. Eight of
    them record data and the ninth records
    error-control bits.
  • Density is measured in units of bits per inch
    (bpi).
  • Density is a function of both the tape medium and
    the drive used to record onto the medium.

11
Parity and Error Control
  • In order to interpret correctly the data that are
    stored on a tape, the encoding scheme (EBCDIC,
    ASCII, or other code) that was used when the data
    were written must be known.
  • Additionally, the technique used to record
    error-control bits has to be known in order for
    that information to be used.
  • One common technique for error control on
    magnetic tape is parity.
  • Parity bits are written when data on the tape are
    written, then are checked when the tape is read
    to verify that an error has not occurred.

12
Parity and Error Control
  • In odd parity, there must be an odd number of
    1-bits represented for each character.
  • If the bits making up a characters binary
    representation already have and odd number of
    1-bits, then the parity bit (in the ninth track
    of a 9-track tape) is 0-bits if there is an even
    number of 1-bits, the parity bit for that
    character is a 1-bits, making the total number of
    1-bits for that characters representation odd.
  • Similarly, parity bits on a tape with even parity
    are recorded so that there is an even number of
    1-bits represented for each character.
  • For example

11110001
Odd parity
0
Parity bit
11110001
Even parity
1
13
Parity and Error Control
  • This simple technique of even/odd parity can
    detect single-bit (or 3-bit or 5-bit or 7 bit)
    errors in a characters representation, but can
    not detect 2-bit, 4-bit, 6-bit, or 8-bit errors.
  • Furthermore, this technique does not indicate
    which of the bits is wrong.
  • Error may appear on a magnetic tape because of
    dirt deposits, bends or wrinkles, areas where the
    ferric-oxide coating is missing, worn edges,
    stretched areas, too low a level of
    magnetization, errors in recording the data in
    the first place, and so on.

14
Blocking
  • Data are read from or written to a tape in groups
    of characters called blocks.
  • A block is the smallest amount of data that can
    be transferred between secondary memory and
    primary memory in one access.
  • A block may contain one or more records.
  • A block is sometimes referred to as a physical
    record.
  • Between each pair of blocks, there is a space or
    gap (sometimes called an interblock gap)

15
Tape Marks and Labels
  • The beginning and end of the tape reel are each
    marked by an aluminum, reflective strip that can
    be sensed by photoelectric sensor in the tape
    drive.
  • The tape mark at the beginning of the tape reel
    is known as the load point. Data can be written
    on the tape after this point until the
    end-of-tape mark is encountered.
  • A piece of adhesive affixed to the reels plastic
    casing is known as external label.
  • A tape may also have an internal label, which is
    recorded electronically on the tape.
  • A tape with an internal label is called a labeled
    tape.

16
Performance of Sequential Files
  • The performance of a sequential file is
    determined by three major factors blocking
    factor, file length, and key selection.
  • Blocking Factor
  • When a sequential file is stored on a
    serial-access storage device, it is generally
    desirable to make the blocks as large as
    possible. The limiting factors become main memory
    buffer space availability, operating system
    parameters (which may limit block size, and the
    local charging algorithm (which trades off main
    memory use and secondary storage accesses).
  • When a sequential file is stored on a
    direct-access storage device, it is generally
    desirable to make the block size as close as
    possible to the sector size or to the track size,
    since an entire sector or track will be passed
    over to access anything on that sector or track
    anyway.

17
Performance of Sequential Files
  • File Length
  • File length is determined by data volumes and
    record design, which is the problem of
    determining which fields are in which records in
    which files.
  • One guideline is to segment fields into records
    according to how frequently they are accessed
    together. For example consider an application
    that needs a file of employee personnel
    information. Some information about employees may
    be used more frequently than other information
    about the same employees. If so, it may be
    advantageous to split the employee data into two
    record types and to place them in separate files.
  • Splitting the employee data into an active file
    and a relatively inactive file reduces the size
    of the active file and therefore reduces
    processing time on that file.

18
Performance of Sequential Files
  • Selecting the Key
  • The key of a sequential file determines the order
    in which its records are accessed.
  • The appropriate field(s) to form the key of a
    sequential file are determined by the application
    requirement.
  • For example, if the file is a report file, then
    the ordering of records is determined by the
    desired form of the output. If the file is a
    master file, the key usually is some obvious
    identifier.
  • If a sequential file is not sorted on a
    particular field, records will simply appear in
    the order they were written.
Write a Comment
User Comments (0)
About PowerShow.com