5. File Access Mode

Understand how systems read and write records using different file access methods.

1

Sequential Access

Data is written sequentially.

Access speed depends on the location of the target data.

Example: magnetic tape.

2

Direct Access

Data can be written to any position.

Each storage position has a unique address.

Data can be accessed directly without starting from the beginning.

Examples: hard disk, USB flash drive, and floppy disk.

Example: Ms Li want to search the Grade of Tom

Sequential File

File: StudentRecords.txt

NameClassClass No.Grade
John4A1A
Mary4A2C
Bob4A3B
Tom4B4D
Alice4B5F

Process:

  1. Press the arrow button to start reading from line 1.

Time: ~0 reads

Direct Access File

Direct access with index lookup

Rec#Addr
10
2100
3200
4300
5400
AddrNameClassClass No.Grade
0John4A1A
100Mary4A2C
200Bob4A3B
300Tom4B4D
400Alice4B5F

Process:

  1. Press the arrow button to start direct access lookup.

Time: ~0 read

AspectSequential AccessDirect Access
Data access rateAveragely lowerAveragely higher
Unit price per capacityLowerHigher
PortabilityHigherLower
LifespanLongerShorter
Common usageBackup storageFrequently used data