AS6 Flashcards

1
Q

Purpose and Structure of Files

A
  • Files enable data to persist in storage between executions of a program.
  • One file contains many records.
  • One record is structured as multiple fields.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Fixed Length Record

A
  • Every record has to be the same size, so the programmer needs to define the size at the start. (Think about max number of characters, not average).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Variable Records

A
  • Has a different number of bytes in each record.
  • More difficult to calculate how much space required.
  • Slower to process by a computer as start/end locations need to be calculated at read/write time.
  • Saves storage space as no blank spaces are left.
  • Each field can extend to accommodate characters.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Estimating File Size

A
  • Singular record: Adding together the size of the individual fields.
  • Final size: Multiply by number of records + 10%. (for metadata)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Sizes of Types

A
  • Byte = 1B
  • Short = 2B
  • Int = 4B
  • Long = 8B
  • Float = 4B
  • Double = 8B
  • Boolean = 1B
  • Single ASCII character = 1B
  • Single Unicode character = 2B/4B
  • N characters = NB (ASCII)/2NB(Unicode)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

File Access

A
  • Normally provided by the core language or imported libraries.
  • Files are processed by being read line by line. The file handler will contain a pointer to tell the handler where the last read/write operation occurred up until it reached an End Of File designator.
  • Normal practice to close files once finished with them.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Serial Files

A
  • New records being appended to back of file is easiest storing method. Important that file is opened in append mode.
  • Normally stored in chronological order.
  • Serial files are used when records are not required to be in order, the number of records is small, or the data must stored in the order it arrived.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Sequential File Access

A
  • Order records based on primary key field.
  • One field will determine if order is ascending or descending. Makes searching for a record easier.
  • A requirement for implementing an index.
  • Inserting into a sequential file is more complex than appending to a serial file. Necessary to find correct position in the file to insert it.
  • Not possible to move records to make room for a new one, a temp file copies all records before, the new record, and then records after. Replaces original file.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Indexed Sequential File Access

A
  • Contains an index that makes accessing record groups faster.
  • Locates records in logical chunks e.g. starting with same letter.
  • Speeds up searches, slows down insertion/deletion. When a record is added, the start and finish points of the index will change the size of one record.
  • Access can still be slow for large amounts of records.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Direct (random) File Access

A
  • Jumping to a record without needed to perform a search/use an index.
  • Can be implemented using a hashing algorithm (primary key taken and used to produce file position).
  • DA files are split into blocks which contain a fixed number of records. The file will take up the same amount of space no matter amount of stored records.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Overflow

A
  • A collision is when a hashing algorithm returns the same block position for two keys.
  • Each block has max record count, so it can fill up.
  • An overflow file can allow for excess records.
  • Creating a new file containing more blocks and re-hashing every record the the new file fixes this.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Overflow v. File Re-Organisation

A
  • Overflow area is lower in cost than a new file, can slow down searches.
  • When a search reaches the end of the block, overflow will also be checked. Because both areas work in the same way, the file will be less efficient.
  • Creating a new file and re-hashing could be expensive. This is used when the load factor is too high.
  • Selecting a larger block size reduces the need.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Generations of Files

A
  • File backups can be created in a structure to allow a series of steps to be taken so that the system will be restored in steps depending on when the loss occurred.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Transaction Logs

A
  • Maintain the security of the system by giving accountability/ allowing file changes to be tracked.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Master and Transaction Files

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

Field

A
  • To store data, it needs to be organised in fields.
  • Each field represents a piece of data.