Objectives: - PowerPoint PPT Presentation

About This Presentation
Title:

Objectives:

Description:

When to use sequential search Searching text file for patterns Small files ... A Summary File organization depends on what use you want to make of the file. – PowerPoint PPT presentation

Number of Views:14
Avg rating:3.0/5.0
Slides: 10
Provided by: Chua79
Category:

less

Transcript and Presenter's Notes

Title: Objectives:


1
Chapter 5 Managing Files of Records
  • Objectives
  • To get familiar with
  • Record Access
  • File organization and file access
  • Advanced file organizations

2
Outline
  • Record access
  • More about record structure
  • File access and file organization
  • Beyond record structures
  • Portability and standardization

3
Record Access
  • Record Keys
  • Primary key
  • unique, data-less, unchanging
  • e.g Social Security Number
  • Secondary key
  • other fields to search generally not unique
  • e.g., name, address

4
Record Access (contd)
  • Sequential Search
  • Read through the file record by record, looking
    for a record of a particular key.
  • Count the number of READs -- assume all READs are
    equally costly
  • The average number of READs needed for
    sequentially searching a file of n records is
    n/2. The sequential search has order O(n), i.e.,
    linear order.
  • Placing several records together as a block and
    reading a block at a time.
  • Sequential search with block is still of linear
    order.
  • When to use sequential search
  • Searching text file for patterns
  • Small files -- files with few records
  • Files that rarely need to be searched
  • Searching on secondary keys and expecting a large
    number of matches

5
Record Access (contd)
  • Direct access
  • Directly position at the beginning of the record
    with a single SEEK( ) call and then read the
    record
  • Order O(1) -- constant, independent of the number
    of records
  • Need to know the position of the record before
    hand.
  • Assume the relative record number (RRN) is known.
  • The first record in a file has RRN 0 the second
    has RRN 1, and so on.
  • If the records in a file is of fixed length, say
    r bytes, the byte offset of the record with RRN n
    is
  • byte offset n ? r.
  • Sometimes, an index is stored in a separate file.

6
More about Record Structure
  • Fixed record length
  • fixed field length
  • variable field length
  • A head record is often placed at the beginning of
    the file to hold some general information about a
    file.
  • The header record has a different structure from
    the data records.
  • The header record may include a count for the
    number of records in the file, the length of the
    data records, the date and time of the files
    most recent update, etc.
  • A file can be self-describing by keeping file
    structure information in a header, e.g.,
  • the name for each field,
  • the width of each field, and
  • the number of fields per record.

7
File Access and File Organization A Summary
  • File organization depends on what use you want to
    make of the file.
  • Since using a file implies accessing it, file
    access and file organization are intimately
    linked.
  • Example though using fixed-length records makes
    direct access easier, if the documents have very
    variable lengths, fixed-length records is not a
    good solution the application determines our
    choice of both access and organization.

8
Beyond Record Structure
  • Abstract data models for file access
  • Headers and self-describing file
  • Metadata data about data
  • Color raster images and FITS files
  • Store metadata with data
  • Mixing object types in one file
  • tagged file
  • Representation-independent file access
  • logical file vs. physical file
  • Extensibility
  • for new file formats

9
Portability and Standardization
  • Factors affecting portability
  • Differences among operating systems
  • Differences among languages
  • Differences in machine architectures
  • Achieving portability
  • Agree on a standard physical record format and
    stay with it
  • Agree on a standard binary encoding for data
    elements
  • Number and text conversion
  • Standard intermediate format, such as XDR
  • File structure conversion
  • File system differences
  • Unix and portability
  • the dd utility
Write a Comment
User Comments (0)
About PowerShow.com