File organisation and access
導入済み
15:07
ユーザー定義データ型
単純な文字列フィールドは、意味のない値でも喜んで格納します。「車両タイプ」を求め、誰かが「バナナ」と入力しても、プログラムは異議を唱えずに受け入れます。しかし、あなたが…
英語のナレーション・英語と中国語の字幕を切り替え可能
このレッスンの内容
| English | 意味 |
|---|---|
| magnetic tape | A storage medium that stores data on a long strip read in order. |
| transactions/trænˈsækʃnz/ | Actions that move money into or out of bank accounts. |
| master file | The main collection of records kept and updated over time. |
| file/faɪl/ | A collection of records stored at positions calculated from their keys. |
| Disks | Storage media that allow data to be read directly from known positions. |
| record/ˈrekɔːd/ | A stored collection of information about an item, person or event. |
| key/kiː/ | A value used to identify or look up an associated item, such as a key in a dictionary or database. |
| file organisation/faɪl ˌɔːɡənaɪˈzeɪʃn/ | ファイル組織 |
| serial file/ˈsɪərɪəl faɪl/ | 直列ファイル |
| Appending | Adding new data or records to the end of a file. |
| searching/ˈsɜːtʃɪŋ/ | The process of looking through data to find a wanted item. |
| logs | Files that keep records of events or actions as they happen. |
| audit trails | Records of actions that allow changes and events to be checked later. |
| sequential file/siːˈkwenʃl faɪl/ | 順次ファイル |
| sorted by a key field | Arranged in order according to the values in a chosen field. |
| binary-search | A search that repeatedly halves an ordered set of records to find a value. |
| batch/bætʃ/ | A group of tasks or records processed together at one time. |
| Direct access/daɪˈrekt ˈækses/ | Reading a record at a known position without reading earlier records. |
| record key | A value that uniquely identifies one record in a file. |
| hash/hæʃ/ | A function that calculates an initial storage address from a record key. |
| Lookup | The process of finding a record or value using a key. |
| lookup tables | Collections of stored values that can be found using keys. |
| access method/ˈækses ˈmeθəd/ | アクセス方法 |
| Sequential access/siːˈkwenʃl ˈækses/ | Reading records in order from the start until the wanted record is reached. |
| random file/ˈrændəm faɪl/ | ランダムファイル |
| indexed/ˈɪndekst/ | Describes data organised with a separate structure that helps the database find records faster. |
| scan/skæn/ | A search that reads records in order to find the wanted data. |
| collisions/kəˈlɪʒnz/ | A conflict such as different keys mapping to the same hash location, or simultaneous transmissions interfering on a shared network medium. |
| web server/web ˈsɜːvə/ | A computer or program that sends web content when users request it. |
| Hashing/ˈhæʃɪŋ/ | The process of calculating an initial record address from a key. |
| record address | The position in storage where a record is or can be placed. |
| algorithm/ˈælɡərɪθəm/ | A finite sequence of precise steps for solving a problem or carrying out a task. |
| overflow area/ˌəʊvəˈfləʊ ˈeərɪə/ | Extra storage used for records whose calculated file or hash-table locations are already occupied. |
| pointer/ˈpɔɪntə/ | A value that identifies a memory location or refers to another stored object. |
| chain/tʃeɪn/ | A series of connected records reached by following links between them. |
| key field/kiː fiːld/ | キーフィールド |
バンクの夜作業が一夜を要した理由
- 1980年代まで、銀行の口座情報は磁気テープ上に保存されていました。テープは一端から他端へしか読めないため、当日の取引は夜間にソートされ、マスターファイル全体が最初から最後まで一度だけ読み込まれて適用されました。
- 午後真ん中に顧客の残高を照会しても、答えは「明日までお待ちください」でした。銀行が提供できるサービスは、コンピュータの速度ではなくファイルの組織構造によって決まりました。
- 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.
- この教訓は、ファイル組織、2つのアクセス方法、およびプログラムが主に実行する処理に基づいた選択方法に関するものです。

3つの組織
- シリアルファイルは、追加された順にレコードを保持し、ソートは行いません。追加は高速ですが、検索は先頭から読む必要があります。ログや監査トレールに使用されます。
- シーケンシャルファイルは、キーフィールドでソートされたレコードを保持します。検索が速く、早期終了や二分探索が可能です。ただし、挿入は遅く、後続のレコードを移動させる必要があるため、バッチ更新用のマスターファイルに使用されます。
- ランダム、または直接アクセスのファイルは、各レコードを記録キーから計算された位置に保持し、通常ハッシュ関数を使用します。キーによる照会は非常に速く、キー順での読み出しは面倒です。大規模な照会テーブルや顧客口座に使用されます。

シリアル: 到着順、それ以上ではない

シーケンシャル: 同じレコードがキー順


2つのアクセス方法
- 順次アクセスは、ファイルの先頭から目的のレコードまで読み進めます。シリアルファイルが許容する唯一のアクセス方法であり、これがバッチ処理におけるシーケンシャルファイルの処理方法です。
- 直接アクセスは、それ以前の内容を読まずに既知の位置へジャンプします。ランダムファイルの読み出し方法であり、キーの位置が既知またはインデックス化されている場合、シーケンシャルファイルも直接アクセスで読み出すことができます。
- よって、シラバスでの対応付けは以下の通りです:シリアルおよびシーケンシャルファイルには順次アクセスを、シーケンシャルおよびランダムファイルには直接アクセスを割り当てます。

ランダム: キーが探索場所を示す

File access route
Follow a file from storage to program and back safely.
A serial file stores records:
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Serial files keep records in arrival order — fast to append, slow to search. Sequential files are sorted by key.
Match each file organisation to how it stores records.
難易度 2/5 · 140 コイン + 今日初回達成時の小ボーナス
Serial = arrival order; sequential = sorted; random = hashed position; indexed-sequential = sorted + an index.
A random (direct-access) file places each record:
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
A key is converted (often by a hash) to a position, so a single-key lookup is very fast.
What is the difference between a serial file and a sequential file?
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Order of arrival versus sorted by key. That single difference is what makes a sequential file searchable early and slow to insert into.
演習例: 組織形式を選択する
- 給与支払プログラムは、従業員番号順に每个月一度、すべての従業員レコードを読み込んで給与明細書を作成する。どのような組織とアクセス方法を用い、なぜか?',
- 順次組織形式と順次アクセス: 全レコードを処理するため、跳跃して読み込むメリットはなく、キー順に格納することで、並べ替え工程なしに順序通りの給与明細を出力できる。
- ATMは番号によってアカウントを1秒以内に取り出す必要があります。 ランダム組織化と直接アクセス:位置はアカウント番号から計算されるため、何百万もの検索を行わず、正確に1回の読み取りだけで済みます。
- Webサーバーアプリは、各リクエストごとにログに1行追加する。 シリアル: 追加操作のみが重要であり、ファイルの末尾への追加はシリアルファイルが最も高速に行う操作である。

A sequential file can be read by sequential access and also by direct access.
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Sequential access serves serial and sequential files; direct access serves sequential and random files. Only a serial file is limited to one method.
Put the steps of fetching one account from a random file in order.
難易度 3/5 · 200 コイン + 今日初回達成時の小ボーナス
The key is turned into an initial position and the record there is checked. If its key differs, follow the collision-resolution strategy to find the requested record.
トレードオフと比較
| シリアル | シーケンシャル | ランダム | |
|---|---|---|---|
| レコードの順序 | 入力順 | キー順にソート済み | キーから計算 |
| レコードの追加 | 高速(追加) | 低速(レコードが移動) | 高速(スロットが空いている場合) |
| 1つのレコードの検索 | 遅い(全読取) | 速い(早期終了可能) | 最速(1回読取) |
| キー順での読出 | ソートが必要 | 自然な順 | ソートが必要 |
- 正解は常に主要な操作に基づいて論理的に導き出されます:このプログラムは主に何をしていますか?

Sequential file organisation is well suited to processing every record in turn.
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Direct access suits looking up a single record.
Match each situation to the file organisation that suits it.
難易度 2/5 · 140 コイン + 今日初回達成時の小ボーナス
Append only, process everything in order, or look one record up: the dominant operation picks the organisation.
このカードは修正されたため、翻訳が更新されるまで英語で表示されます。
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 sequential file ordered by title, so a search can stop when the title is found or passed instead of scanning 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.
To produce reports in key order, the best file organisation is:
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
A sequential file is already in key order, so reading it sequentially gives an in-order report.
A file organisation is chosen by looking at the program's ____ operation.
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Every organisation is fast at something and slow at something else, so the operation done most often decides.
キーの条件とハッシュが破綻する理由
- 直接アクセスにはキーが必要であり、そのキーは1つのレコードに対して一意でなければならない。氏名はキーにはならず、顧客番号はキーになり得る。
- ハッシュ化はそのキーを1回の計算でレコードアドレスに変換するため、ファイルの規模に関わらず、単一の読み取りでレコードに到達できる。
- 異なる2つのキーが同じアドレスにハッシュされることがある。これを衝突と呼び、アルゴリズムの欠陥ではない:可能なキーの数がアドレスより多い段階では避けられない現象である。
- 採点基準で言及された修正策はオーバーフロー領域であり、または共有されるレコードのチェーンに対するアドレスにポインタを格納することである。したがって、衝突によるコストは追加の読み込み1回のみとなり、レコードの喪失ではない。
- 誠実な比較は以下の通り:ハッシュはファイルが一杯になるまでほぼ一定のアクセス速度を保つが、衝突が蓄積するにつれて性能が低下する。順次アクセスは減速しないが、本来速いわけではない。

Two records hash to the same address. Which are true? Select すべて that apply.
難易度 2/5 · 140 コイン + 今日初回達成時の小ボーナス
A collision need not lose a record, but resolving it can require additional reads. Collisions are unavoidable if there are more possible keys than addresses.
見落としやすいポイント
- シリアルは入力順であり、シーケンシャルはキーでソート済みである。これらは同義語ではなく、試験ではこの違いを厳密に問う。
- 組織形式とはレコードの配置方法であり、アクセスとはプログラムが特定のレコードに到達する方法である。問題文はどちらかを指定する。
- シーケンシャルファイルは両方のアクセス方法に対応できるが、シリアルファイルは順次アクセスのみに対応する。
- 「速いから」ではなく主要な操作に基づいて正当性を説明せよ。どの点において速いか、なぜ速いかを具体的に述べよ。
このカードは修正されたため、翻訳が更新されるまで英語で表示されます。
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: initial position computed from the record key, with extra reads possible after collisions
- 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
何が問題でしたか?この内容はサイトの運営チームだけが確認します。