| English | 意味 |
|---|---|
| file organisation/faɪl ˌɔːɡənaɪˈzeɪʃn/ | ファイル組織 |
| access method/ˈækses ˈmeθəd/ | アクセス方法 |
| serial file/ˈsɪərɪəl faɪl/ | 直列ファイル |
| sequential file/siːˈkwenʃl faɪl/ | 順次ファイル |
| key field/kiː fiːld/ | キーフィールド |
| direct access/daɪˈrekt ˈækses/ | 直接アクセス |
| sequential access/siːˈkwenʃl ˈækses/ | 順次アクセス |
| random file/ˈrændəm faɪl/ | ランダムファイル |
Why the bank's night job took all night
- Into the 1980s a bank's accounts lived on magnetic tape. A tape can only be read from one end to the other, so the day's transactions were sorted overnight and the whole master file was read start to finish, once, to apply them.
- Ask for one customer's balance in the middle of the afternoon and the answer was: not until tomorrow. The organisation of the file, not the speed of the computer, decided what the bank could offer.
- Disks made a different organisation possible: compute where a record is from its key and jump there. That is what lets a cash machine answer in a second.
- This lesson is file organisation 文件组织, the two access methods 访问方式, and how to choose from what the program mostly does.
Three organisations
- A serial file 串行文件 holds records in the order they were added, with no sorting. Appending is fast; searching means reading from the start. Used for logs and audit trails.
- A sequential file 顺序文件 holds records sorted by a key field 键字段. Searching is faster, because you can stop early or binary-search; inserting is slow, because later records must shift. Used for master files updated in batch.
- A random, or direct-access, file 随机文件 holds each record at a position computed from its record key, usually by a hash. Lookup by key is very fast; reading in key order is awkward. Used for large lookup tables and customer accounts.

Serial: order of arrival, nothing more

Sequential: the same records, in key order
The two access methods
- Sequential access 顺序存取 reads from the start of the file to the record wanted. It is the only access a serial file allows, and it is how a sequential file is processed in a batch.
- Direct access 直接存取 jumps straight to a known position without reading what comes before. It is how a random file is read, and a sequential file can also be read directly when the position of a key is known or indexed.
- So the syllabus pairing is: sequential access for serial and sequential files; direct access for sequential and random files.

Random: the key tells you where to look
ファイルアクセスルート
ストレージからプログラムへ、そして戻ってくるまでファイルを安全に追跡する。
シリアルファイルはレコードを以下のように格納する:
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
シリアルファイルは着信順にレコードを保持し、追加は速いものの検索は遅い。順次ファイルはキーで整列されている。
各ファイル組織化を、レコードの格納方法と対応させよ。
難易度 2/5 · 140 コイン + 今日初回完了時に小ボーナス付与
シリアル=着信順;順次=整列済み;ランダム=ハッシュ位置;インデックス付き順次=整列+インデックス。
ランダム(直接アクセス)ファイルは各レコードを以下のように配置する:
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
キーはハッシュなどによって位置に変換されるため、単一キーの照会は非常に速い。
シリアルファイルと順次ファイルの違いは何か?
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
着信順 versus キー順整列。この単一の違いが、順次ファイルが検索には適しているが挿入には遅い理由である。
Worked example: choose the organisation
- A payroll program reads every employee record once a month, in employee-number order, to produce payslips. Which organisation and access, and why?
- Sequential organisation with sequential access: every record is processed, so there is nothing to gain from jumping about, and storing them in key order means the payslips come out in order with no sorting step.
- A cash machine must fetch one account by its number in under a second. Random organisation with direct access: the position is computed from the account number, so exactly one read is needed instead of a search through millions.
- A web server appends one line per request to a log. Serial: only appending matters, and appending to the end is the fastest thing a serial file does.
順次ファイルは順次アクセスおよび直接アクセスの両方で読み取れる。
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
順次アクセスはシリアルおよび順次ファイルに対応し、直接アクセスは順次およびランダムファイルに対応する。シリアルファイルだけが1つの手法に限定される。
ランダムファイルから1つのアカウントを取得する手順を正しい順序で並べ替えよ。
難易度 3/5 · 200 コイン + 今日初回完了時に小ボーナス付与
検索処理は一切行われない:キーは位置に変換され、一度だけ読み取られる。最終的なチェックが衝突を検知する。
The trade-offs, side by side
| serial | sequential | random | |
|---|---|---|---|
| order of records | as added | sorted by key | computed from key |
| adding a record | fast, append | slow, records shift | fast, if the slot is free |
| finding one record | slow, read all | faster, can stop early | fastest, one read |
| reading in key order | needs a sort | natural | needs a sort |
- The right answer is always argued from the dominant operation: what does this program do most?
順次ファイル組織化は、レコードを順次すべて処理するのに適している。
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
直接アクセスは単一レコードの照会に適している。
各状況を、それに適したファイル組織化と対応させよ。
難易度 2/5 · 140 コイン + 今日初回完了時に小ボーナス付与
追加のみ、順序通りすべての処理、または単一レコードの照会:最も頻繁に行われる操作が組織化を決定する。
Worked example: justify a change
- A library's book file is serial. Searching for one title is slow. Suggest a change and justify it.
- Reorganise as a random file, hashing the ISBN to an address, so a search becomes one direct read instead of a scan of the whole file.
- If the library also prints a catalogue in title order, a sequential organisation by title serves both reasonably: the catalogue needs no sort and a search can stop early or binary-search.
- Name the organisation, name the access method, and tie both to an operation the question mentions.
キー順でレポートを作成する場合、最適なファイル組織化は:
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
順次ファイルはすでにキー順なので、順次読み取りすれば整列されたレポートが得られる。
ファイル組織化は、プログラムの ____ 操作を見ることで選択される。
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
すべての組織化には得意・不得意があり、最も頻繁に行われる操作がそれを決定するためである。
What the key has to be, and why hashing breaks
- Direct access needs a key, and the key must be unique to one record. A surname is not a key; a customer number is.
- Hashing turns that key into a record address in one calculation, so a single read reaches the record however large the file is.
- Two different keys can hash to the same address. That is a collision, and it is not a fault in the algorithm: it is unavoidable once there are more possible keys than addresses.
- The fix named in the mark scheme is an overflow area, or storing a pointer at the address to a chain of records that share it. A collision therefore costs one extra read, not a lost record.
- So the honest comparison is: hashing gives near-constant access until the file fills up, and its performance degrades as collisions build. Sequential access never degrades but was never fast.
2つのレコードが同じアドレスにハッシュされる。正しいものはどれか?すべて選択せよ。
難易度 2/5 · 140 コイン + 今日初回完了時に小ボーナス付与
データは失われない;衝突は読みに1回追加されるのみだ。原理的には避けられない——可能なキーの数は必ずアドレスより多いからだ。
Marks that slip away
- Serial is order of arrival; sequential is sorted by a key. They are not synonyms, and the exam tests exactly that difference.
- Organisation is how the records are laid out; access is how the program reaches one. A question names one or the other.
- A sequential file supports both access methods; a serial file supports only sequential access.
- Justify from the dominant operation, not from "it is faster". Say faster at what, and why.
You've got it
- serial: order added, append fast, search slow, used for logs · sequential: sorted by a key field, good for batch processing and in-order output · random: position computed from the record key, one read to find a record
- sequential access reads from the start; direct access jumps to a position
- sequential access serves serial and sequential files; direct access serves sequential and random files
- choose from the dominant operation: process everything, look one up, or only append