Anda di halaman 1dari 3

Multikey File Access

CS 102  indexed sequential file organizations only provide


File Structures & access by one primary key field.
File Organizations  What if you want to access the file by other than
the primary key ?
 Secondary Key Fields – fields used to access a
file other than the primary key.
Chapter 08
Multiple Key File Organization

CJD

Examples Multikey File Organizations


 allow multiple ways to access the file by several
 Suppose you want to access the student file by different key fields
student number, and then later by last name, and  use indexing structures with indexes for each key
then later by course field
 Suppose you want to access the employee file  provides inverse relationship between
by employee number, and also by last name,
and also by rank, and also by date of hire, and data in a record and
also by department the primary key of the record
 lists the primary keys of the records that contain
a particular secondary key value, for each
secondary key value.

CJD CJD

Two Areas Example Record Area


 a record area – a random or indexed sequential Primary Secondary Secondary Non Key
Key Key 1 Key 2
file organization of the records by the primary
Employee Name Department Rank Age
key field.
Ananias Accounting Rank & File 58
 a directory area – an additional indexing Barabas IT Rank & File 34
structure Caiapas Management Manager 52
 for the records using the secondary key field. Cleopas IT Supervisor 41
Elias Operations Supervisor 37
 may be organized into sequential or indexed Hestas Operations Rank & File 23
sequential file on the secondary key field Judas Payroll Rank & File 26
values. Lukas IT Rank & File 21
Matias Management Supervisor 28
Zakarias Operations Rank & File 30
CJD CJD

1
Maintenance Types
 The file organization must be tediously  Types of Multiple-Key File Organization
maintained for every Inverted File Organization
insertion and deletion of records Multilist File Organization
change in secondary field values

CJD CJD

Inverted File Organization By Department Example


 There is a directory of all possible values of a Directory of Inverted Files for Department as a B-Tree
secondary key field. For each value is a list of IT Operations
primary keys of all records with this value.
 Indices for several secondary fields may be stored Accounting Management Payroll
 as one combined file (difficult to manage) or
 as separate files (easier to work with) Department Primary Key(s) Linked List
 The lists for the values of a secondary key field Accounting Ananias
may be stored in one index file IT Barabas, Cleopas, Lukas
 as variable length records or Management Caiapas, Matias
 as fixed length records each as big as the longest list Operations Elias, Hestas, Zakarias
Payroll Judas
 The lengths of inverted lists vary greatly for
 Each entry in the linked lists points to the location of the
different values of a secondary key field. record in the record area
CJD CJD

By Rank Example Inverted Files Record Area


Directory of Inverted Files for Rank as a B-Tree Primary Secondary Secondary Non Key
Rank & File Key Key 1 Key 2
Employee Name Department Rank Age
Manager Supervisor Ananias Accounting Rank & File 58
Barabas IT Rank & File 34
Rank Primary Key Caiapas Management Manager 52
Cleopas IT Supervisor 41
Manager Caiapas Elias Operations Supervisor 37
Rank & Ananias, Barabas, Hestas, Hestas Operations Rank & File 23
File Judas, Lukas, Zakarias Judas Payroll Rank & File 26
Supervisor Cleopas, Elias, Matias Lukas IT Rank & File 21
Matias Management Supervisor 28
 Each entry in the linked lists points to the location of the Zakarias Operations Rank & File 30
record in the record area
CJD CJD

2
Multilist File Organization By Department Example
 A directory of all possible values of a secondary Directory of Multilists for Department as a B-Tree
key field and a pointer to a linked list of all IT Operations
records containing each value.
Accounting Management Payroll
 For each secondary key value, the directory
contains
 only the first primary key of the record with the value Department Primary Key Length
Accounting Ananias 1
 the number of records linked on the value IT Barabas 3
 All data attributes with the value are linked in the Management Caiapas 2
data file. One linked list per value. Operations Elias 3
Payroll Judas 1
 Each data record contains one pointer field for
each secondary key field.  Each entry in the list above points to the location of the
first record in a department in the record area
CJD CJD

By Rank Example Multilist Files Record Area


Directory of Multilists for Rank as a B-Tree
Primary Secondary Link 1 Secondary Link 2 Non
Rank & File Key Key 1 Key 2 Key
Employee Department Ptr to Rank Ptr to Age
Manager Supervisor Ananias Accounting - Rank & File Barabas 58
Barabas IT Cleopas Rank & File Hestas 34
Caiapas Management Matias Manager - 52
Rank Primary Key Length Cleopas IT Lukas Supervisor Elias 41
Manager Caiapas 1 Elias Operations Hestas Supervisor Matias 37
Rank & File Ananias 6 Hestas Operations Zakarias Rank & File Judas 23
Judas Payroll - Rank & File Lukas 26
Supervisor Cleopas 3
Lukas IT - Rank & File Zakarias 21
Matias Management - Supervisor - 28
Zakarias Operations - Rank & File - 30
 Each entry in the list above points to the location of the pointers from department directory area pointers from rank directory area
first record in a rank in the record area
CJD CJD

Database Management Systems End

Out of scope

Enroll in another course :

IM 201

CJD CJD

Anda mungkin juga menyukai