Lecture 17-18 Flashcards

1
Q

What is buffering?

A

Data in secondary or tertiary storage needs to be transferred to main memory, before being rpocessed by the cpu. However, transport time takes longer than memory access, hence, multiple bufferes in main memory exist, while one is being read or written, the CPU can process data in other buffers.

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

What are the characteristics of discs?

A

Physically they are made up of tracks, cylinders, sectors, and blocks. A hardware address, surface number, track number, block or sector number.

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

How are file records formatted on the disk?

A

Records are a collection of related data values or items, usually this is a tuple or row.
Record types are a collectino of field names and their data types.
A file contains a sequence of records, typically all will be the same record type.
In fixed length records every record is exactly the same size, in variable length records different records have different sizes.

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

How do variable length records work?

A

A seperator character that isn’t used in any field seperates the fields. A special character can also be used to seperate the field name from the field value.

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

What are spanned and unspanned records?

A

Records must be allocated to disk blocks, a spanned record can span more than one block, an unspanned record cannot.

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

What is a block? What are the important things to consider for fixed length and variable length records?

A

The unit of data transfer between disk and memory. Blocking factor is the number of records stored in a block. In fixed length records this is the block size/the record size(rounded down), the unused space is the block size - (blocking factor*records in a block).
For variable length records the blocking factor is an average, and the number of blocks required for r records is r/blocking factor, rounded up.

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

What are the methods for block allocation?

A

As needed: data scattered all over disk.
Contiguous: file blocks allocated to consecutive disk blocks, fast read, but expansion is problematic.
Linked: each block contains pointer to next block, slower read, easy expansion.
Clusters: clusters of consecutive blocks and clusters linked, typically done to segments of disk or extents of records.
Indexed: index blocks have pointers to actual data blocks.

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

How are files or unorganised records dealt with?

A

They use heap files, records are placed in the order they are inserted, new records at the end of the file. This makes insertion simple, but searching is linear. Deletion also wastes storage space, as it just removes the record from the block, without reshuffling block. Sorting could be done, but this can be expensive for a large disk file.

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

How are files of ordered records dealt with?

A

They have an ordering field, the key field. This makes reading in order, finding the next record often doesn’t need disk access as it is in same block, search is binary, and a search involving > or < is efficient. However, insertion and deleting records is expensive, modifying ordered field requires delete and insert and no help for searches on non ordering field.

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

How are files of hashed records dealt with?

A

Hash files make access very fast for hashed field, needs a hash function, typically K mod M, where M is typically a prime and K is the value. insertion and deletion is relatively simple, equality search is also efficient.
Needs collission resolution, this could be open addressing (subsequent positions), chaining(place in an unused overflow location, add pointer to this location in occupied location, or multiple hashing(second hash function.

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

How does hashing work for disk files?

A

Disk space divided into buckets, hashing maps to relative bucket number, file header maintains table that maps bucket number into disk block address. In static hashing a fixed number of buckets is allocated, this is a drawback for dynamic files.

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

What are indexes?

A

Additional files on the disk, which allow access of records without affecting physical placement of records on disk, they consist of an indexing field and a list of pointers to disk blocks.
Every record has a unique index key field, used to physically order the index records on disk. Binary search on the index is much faster than on data file as the index file is is much smaller.

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

What are single-level ordered indexes?

A
A file can have at most one physical ordering field, types of this are:
Primary index(ordered by key field of ordered file, each will be unique)
Clustering index( ordering field not key, as such more than one record may have the same value), a file can have a primary index or clustering but not both.
A secondary index is specified on any non-ordering field,  several of these can exist.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are some important things about primary indexes?

A

Ordered file with records of fixed length with two fields: Data from the ordering key field, and a pointer to the data block. The number of index entries = the number of disk blocks used, with only the block anchor being referenced.
A dense index has an index entry for every record, a sparse index has index entries for only some, a primary index in nondense(sparse).
Moving records may change anchor records, meaning reorganisation can be required.

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

What is an anchor record/block anchor?

A

The first record of a block.

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

What are some important things about clustering indexes?

A

These are for an ordered file whose ordering field is not a key, it has the same problems as primary index for insertion and is non-dense. It will point to the start of the first block which contains the index value(which could be the value before).

17
Q

What are some important things about clustering indexes?

A

Secondary means for when primary access already exists, for ordered files or attributes not in ordering field. Can be done on a key field or non key, can be many.
On a key field: uses non ordering field which links Key field to unique values, two entries are the data from some non-ordering files and a pointer to the data. It is a dense index. The index is ordered, allowing binary search on it to link to the unordered file.
Non key field: many records can have same value for indexing field.
Our options are: several index entries for same field(Dense index), variable length records for index entries with repeating pointer value(non-dense), extra level of indirection to handle multiple pointers(non dense).