Programming Logic and Design: Ninth Edition
Programming Logic and Design: Ninth Edition
Programming Logic and Design: Ninth Edition
Ninth Edition
Chapter 7
File Handling and Applications
• Organizing files
– Directories and folders
• Organization units on storage devices
– Path
• Combination of disk drive plus the complete hierarchy of
directories
• Example:
C:\Logic\SampleFiles\PayrollData.dat
• Sequential file
– Program reads all the records in this file from beginning to
end, processing them one t a time
• Sorting
– The process of placing records in order by the value in a
specific field or fields
• Ascending order – records sorted in order from lowest to
highest values
• Descending order – records sorted in order from highest to
lowest values
• Examples
– A library maintains a master file of all patrons and a
transaction file with information about each book or other
items checked out
– A college maintains a master file of all students and a
transaction file for each course registration
– A telephone company maintains a master file of every
telephone line (number) and a transaction file with
information about every call
• Updating approaches
– Change information in master file
– Copy master file and change new version
• Begin with both files sorted in the same order on the
same field
• Master files
– Hold relatively permanent data
– Updated by transaction files
• Real-time applications
– Require random access files where records can be located
in any order
• Instant access files and direct access files are files in
which records must be accessed immediately