1
Sequential Access
Data is written sequentially.
Access speed depends on the location of the target data.
Example: magnetic tape.
Understand how systems read and write records using different file access methods.
Data is written sequentially.
Access speed depends on the location of the target data.
Example: magnetic tape.
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.
File: StudentRecords.txt
| Name | Class | Class No. | Grade |
|---|---|---|---|
| John | 4A | 1 | A |
| Mary | 4A | 2 | C |
| Bob | 4A | 3 | B |
| Tom | 4B | 4 | D |
| Alice | 4B | 5 | F |
Process:
Time: ~0 reads
Direct access with index lookup
| Rec# | Addr |
|---|---|
| 1 | 0 |
| 2 | 100 |
| 3 | 200 |
| 4 | 300 |
| 5 | 400 |
| Addr | Name | Class | Class No. | Grade |
|---|---|---|---|---|
| 0 | John | 4A | 1 | A |
| 100 | Mary | 4A | 2 | C |
| 200 | Bob | 4A | 3 | B |
| 300 | Tom | 4B | 4 | D |
| 400 | Alice | 4B | 5 | F |
Process:
Time: ~0 read
| Aspect | Sequential Access | Direct Access |
|---|---|---|
| Data access rate | Averagely lower | Averagely higher |
| Unit price per capacity | Lower | Higher |
| Portability | Higher | Lower |
| Lifespan | Longer | Shorter |
| Common usage | Backup storage | Frequently used data |