Hashed Files Flashcards

1
Q

Define external hashing

A

External hashing is hashing on disk files.
In this method, blocks are divided into equal-sized buckets, with each bucket corresponding to a fixed number of blocks.

Hashing uses a hash key (K) for data retrieval. The hash key is one of the fields (attributes/columns) of the file. In order to determine which bucket a record is going to be stored in, the hash key is put through the hashing function. ie to determine which bucket(i):

i=h(K)

An example of a hashing function is 8 mod 10

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

When do collisions occur in hashing

A

Collisions in hashing occur when a record is hashed to a bucket that is already full

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a hash index

A

The hash index is a secondary structure to access
the file by using hashing on a search key other
than the one used for the primary data file
organization

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the index entries of a hash index

A

The index entries are of the type <K, Pr> or <K,
P>, where Pr is a pointer to the record containing
the key, or P is a pointer to the block containing
the record for that key

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Describe searching for a record using a hash key

A

Searching for an entry uses the hash search
algorithm on K. Once an entry is found, the
pointer Pr (or P) is used to locate the
corresponding record in the data file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What happens when there are thousands of buckets, how does the DBMS keep track of the buckets

A

In a practical application, there may be thousands
of buckets; the bucket number, which may
be several bits long, would be subjected to
the directory schemes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Do the example from 46 to 48

A

9320

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the different methods for collision resolution

A

chaining
open addressing
multiple hashing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Describe multiple hashing

A

If a collision occurs, a second hash function is applied by the program. If another collision occurs, open addressing is used or a third hash function is applied and then the program uses open addressing as necessary

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Describe chaining

A

For this method, various overflow locations are kept, usually by extending the array with a number of overflow positions.
A collision is resolved by placing the new record in an unused overflow location and setting the pointer of the occupied hash address location to the address of that overflow location.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Describe open addressing

A

Proceeding from the occupied position
specified by the hash address, the program checks the subsequent positions in order until an unused (empty) position is found

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Go through the example on 51

A

skj

How well did you know this?
1
Not at all
2
3
4
5
Perfectly