110 likes | 241 Views
Week 14 Reading a File. Loops. Files. File - collection of records. Logical records - represent entities (persons, places, objects, things, etc.). 1234567890123456 John Smith 12000 500.00. 1234654321098765 Richard Roe 12000 500.00. Fields - describe properties of the entities.
E N D
Week 14Reading a File Loops
Files File - collection of records Logical records - represent entities (persons, places, objects, things, etc.) 1234567890123456 John Smith 12000 500.00 1234654321098765 Richard Roe 12000 500.00 Fields - describe properties of the entities
Basic Concepts DASD (direct access storage device) • Performance: • Seek time • Rotational delay • Transfer time Track Magnetic disks Cylinder (vertical alignment of tracks)
Access Data Tracks Rotational delay Seek time Locating the beginning sector Locating the right track Transfer time: Transferring data from the disk to memory Read/write Head
Basic Concepts DASD (direct access storage device) Tracks Physical records (blocks, pages) Block overhead Logical records
File Organization and Access Methods Progression Magnetic tape • Heap (sequential) files • Hashed • Hashed files • Sorted* • Indexed sequential • B+ trees (e.g., VSAM files) Sequential access method Hash methods DSAD Secondary storage devices Indexed access methods *Applies to accessing records, not just storing them
File Organization and Access Methods • File OrganizationThe physical arrangement of data in a file into records and pages on secondary storage • Types: • Heap (unordered)-sequential • Ordered (ordered by value) • Hash • Access methodThe steps involved in storing and retrieving records from a file
Heap or Sequential Files Queue Records are accessed in the same sequence they were placed into the file (first in, first out).
Insert at the very top Define variables Define file stream Open file For-nextLoop
Copy-and-pastefrom For-next loop While loop End of file