13. file structures. accessmethodsaccessmethods 13.1
TRANSCRIPT
![Page 1: 13. File Structures. ACCESSMETHODSACCESSMETHODS 13.1](https://reader035.vdocuments.us/reader035/viewer/2022062408/56649f125503460f94c24f44/html5/thumbnails/1.jpg)
13. File Structures
![Page 2: 13. File Structures. ACCESSMETHODSACCESSMETHODS 13.1](https://reader035.vdocuments.us/reader035/viewer/2022062408/56649f125503460f94c24f44/html5/thumbnails/2.jpg)
ACCESSACCESSMETHODSMETHODS
ACCESSACCESSMETHODSMETHODS
13.113.1
![Page 3: 13. File Structures. ACCESSMETHODSACCESSMETHODS 13.1](https://reader035.vdocuments.us/reader035/viewer/2022062408/56649f125503460f94c24f44/html5/thumbnails/3.jpg)
AAccess methodsccess methods
A file is a collection of related data records treated as a unit.
Files are stored in what are known as auxiliary or secondary storage devices.
The two most common forms of secondary storage are optical and magnetic disks.
A record in a file can be accessed sequentially or randomly.
![Page 4: 13. File Structures. ACCESSMETHODSACCESSMETHODS 13.1](https://reader035.vdocuments.us/reader035/viewer/2022062408/56649f125503460f94c24f44/html5/thumbnails/4.jpg)
TTaxonomy of file structuresaxonomy of file structures
![Page 5: 13. File Structures. ACCESSMETHODSACCESSMETHODS 13.1](https://reader035.vdocuments.us/reader035/viewer/2022062408/56649f125503460f94c24f44/html5/thumbnails/5.jpg)
SEQUENTIALSEQUENTIALFILESFILES
SEQUENTIALSEQUENTIALFILESFILES
13.213.2
![Page 6: 13. File Structures. ACCESSMETHODSACCESSMETHODS 13.1](https://reader035.vdocuments.us/reader035/viewer/2022062408/56649f125503460f94c24f44/html5/thumbnails/6.jpg)
SSequential fileequential file
In sequential access, each record must be accessed sequentially, one after the other, from beginning to end.
The update of a sequential file requires a new master file. An old master file, a transaction file, and an error report file.
![Page 7: 13. File Structures. ACCESSMETHODSACCESSMETHODS 13.1](https://reader035.vdocuments.us/reader035/viewer/2022062408/56649f125503460f94c24f44/html5/thumbnails/7.jpg)
While Not EOF{
Read the next recordProcess the record
}
Program 13.1Program 13.1 Processing records in a sequential fileProcessing records in a sequential file
![Page 8: 13. File Structures. ACCESSMETHODSACCESSMETHODS 13.1](https://reader035.vdocuments.us/reader035/viewer/2022062408/56649f125503460f94c24f44/html5/thumbnails/8.jpg)
Updating a sequential fileUpdating a sequential file
![Page 9: 13. File Structures. ACCESSMETHODSACCESSMETHODS 13.1](https://reader035.vdocuments.us/reader035/viewer/2022062408/56649f125503460f94c24f44/html5/thumbnails/9.jpg)
INDEXEDINDEXEDFILESFILES
INDEXEDINDEXEDFILESFILES
13.313.3
![Page 10: 13. File Structures. ACCESSMETHODSACCESSMETHODS 13.1](https://reader035.vdocuments.us/reader035/viewer/2022062408/56649f125503460f94c24f44/html5/thumbnails/10.jpg)
RRandom accessandom access
In random access, a record can be accessed without having to retrieve any records before it. The address of the record must be known.
For random access of a record, an indexed file, consisting of a data file and an index, can be used.
In random file access, the index maps a key to an address, which is then used to retrieve the record from the data file.
![Page 11: 13. File Structures. ACCESSMETHODSACCESSMETHODS 13.1](https://reader035.vdocuments.us/reader035/viewer/2022062408/56649f125503460f94c24f44/html5/thumbnails/11.jpg)
Updating process
×
?
![Page 12: 13. File Structures. ACCESSMETHODSACCESSMETHODS 13.1](https://reader035.vdocuments.us/reader035/viewer/2022062408/56649f125503460f94c24f44/html5/thumbnails/12.jpg)
MMapping in an indexed fileapping in an indexed file
An indexed file is made of a data file, which is a sequential file, and an index.
The index itself is a very small file with only two fields: the key of the sequential file and the address of the corresponding record on the disk.
![Page 13: 13. File Structures. ACCESSMETHODSACCESSMETHODS 13.1](https://reader035.vdocuments.us/reader035/viewer/2022062408/56649f125503460f94c24f44/html5/thumbnails/13.jpg)
LLogical view of an indexed fileogical view of an indexed file
![Page 14: 13. File Structures. ACCESSMETHODSACCESSMETHODS 13.1](https://reader035.vdocuments.us/reader035/viewer/2022062408/56649f125503460f94c24f44/html5/thumbnails/14.jpg)
HASHEDHASHEDFILESFILES
HASHEDHASHEDFILESFILES
13.413.4
![Page 15: 13. File Structures. ACCESSMETHODSACCESSMETHODS 13.1](https://reader035.vdocuments.us/reader035/viewer/2022062408/56649f125503460f94c24f44/html5/thumbnails/15.jpg)
MMapping in a hashed fileapping in a hashed file
A hashed file is a random-access file in which a function maps a key to an address.
In direct hashing, the key is the address, and no algorithm manipulation is necessary.
![Page 16: 13. File Structures. ACCESSMETHODSACCESSMETHODS 13.1](https://reader035.vdocuments.us/reader035/viewer/2022062408/56649f125503460f94c24f44/html5/thumbnails/16.jpg)
DDirect hashingirect hashing
![Page 17: 13. File Structures. ACCESSMETHODSACCESSMETHODS 13.1](https://reader035.vdocuments.us/reader035/viewer/2022062408/56649f125503460f94c24f44/html5/thumbnails/17.jpg)
MModulo divisionodulo division
In modulo division hashing, the key is divided by the file size. The address is the remainder plus 1.
![Page 18: 13. File Structures. ACCESSMETHODSACCESSMETHODS 13.1](https://reader035.vdocuments.us/reader035/viewer/2022062408/56649f125503460f94c24f44/html5/thumbnails/18.jpg)
DDigit extraction igit extraction
In digit extraction hashing, the address is composed of digits selected from the key.125870 158122801 128121267 112123413 134
Keys that hash to the same address are called synonyms.
![Page 19: 13. File Structures. ACCESSMETHODSACCESSMETHODS 13.1](https://reader035.vdocuments.us/reader035/viewer/2022062408/56649f125503460f94c24f44/html5/thumbnails/19.jpg)
CCollisionollisionA collision is an event that occurs when a
hashing algorithm produces an address for an insertion, and that address is already occupied.
Collision resolution methods move the hashed data that cannot be inserted to a new address.
![Page 20: 13. File Structures. ACCESSMETHODSACCESSMETHODS 13.1](https://reader035.vdocuments.us/reader035/viewer/2022062408/56649f125503460f94c24f44/html5/thumbnails/20.jpg)
OOpen addressing resolutionpen addressing resolution
The open addressing collision resolution method searches the prime area for an open address for the data to be inserted.
![Page 21: 13. File Structures. ACCESSMETHODSACCESSMETHODS 13.1](https://reader035.vdocuments.us/reader035/viewer/2022062408/56649f125503460f94c24f44/html5/thumbnails/21.jpg)
LLinked list resolutioninked list resolution
The linked list resolution method uses a separate area to store collisions and chains all synonyms together in a linked list.
![Page 22: 13. File Structures. ACCESSMETHODSACCESSMETHODS 13.1](https://reader035.vdocuments.us/reader035/viewer/2022062408/56649f125503460f94c24f44/html5/thumbnails/22.jpg)
BBucket hashing resolutionucket hashing resolution
Bucket hashing is a collision resolution method that uses buckets, nodes that accommodate multiple data occurrences.
![Page 23: 13. File Structures. ACCESSMETHODSACCESSMETHODS 13.1](https://reader035.vdocuments.us/reader035/viewer/2022062408/56649f125503460f94c24f44/html5/thumbnails/23.jpg)
TEXTTEXTVERSUSVERSUSBINARYBINARY
TEXTTEXTVERSUSVERSUSBINARYBINARY
13.513.5
![Page 24: 13. File Structures. ACCESSMETHODSACCESSMETHODS 13.1](https://reader035.vdocuments.us/reader035/viewer/2022062408/56649f125503460f94c24f44/html5/thumbnails/24.jpg)
TText and binary interpretations of a fileext and binary interpretations of a file
A text file is a file of characters.A binary file is data stored in the internal
format of the computer.