File organisation and access
도입됨
15:07
사용자 정의 데이터 타입
평범한 문자열 필드는 허구적 데이터를 기꺼이 저장합니다. 차량 유형을 묻고 someone이 Bananas를 입력하면 프로그램은 아무런 불만 없이 이를 수락합니다. 하지만 만약 당신이…
영어 내레이션 · 영어와 중국어 자막 전환 가능
이 수업의 내용
| 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.
- 이 교훈은 파일 조직, 두 가지 접근 방법(access methods), 그리고 프로그램의 대부분이 수행하는 작업에 따라 선택하는 방법입니다.

세 가지 조직
- 직렬 파일(serial file) 은 추가된 순서대로 레코드를 유지하며, 정렬은 없습니다. 추가(appending)은 빠르지만, 검색(searching)은 시작에서부터 읽어야 합니다. 로그(logs) 및 감사 기록(audit trails)에 사용됩니다.
- 연속 파일(sequential file) 은 키 필드(key field)에 의해 정렬된 레코드를 유지합니다. 검색이 빠릅니다. 초기에 멈출 수 있거나 이분 탐색(binary-search)을 할 수 있기 때문입니다. 삽입(inserting)은 느립니다. 나중에 오는 레코드를 이동해야 하기 때문입니다. 일괄 업데이트(batch update)되는 마스터 파일에 사용됩니다.
- 임의(random) 또는 직접 접근(direct-access) 파일은 각 레코드를 레코드 키로부터 계산된 위치에 유지합니다. 보통 해시(hash)를 사용합니다. 키에 의한 조회(lookup)는 매우 빠르지만, 키 순서로 읽는 것은 불편합니다. 대규모 조회 표와 고객 계좌에 사용됩니다.

직렬: 도착 순서, 그 이상은 없습니다

연속: 같은 레코드들, 키 순서로


두 가지 접근 방법
- **순차 접근(sequential access)**은 파일의 시작점에서 원하는 레코드까지 읽습니다. 이는 직렬(serial) 파일에서 허용되는 유일한 접근 방식이며, **순차文件(sequential file)**이 배치 처리될 때 사용되는 방법입니다.
- **직접 접근(direct access)**은 이전 내용을 읽지 않고Known한 위치로 바로 이동합니다. 이는 랜덤(random) 파일을 읽는 방식이며, 키(key)의 위치를 알고 있거나 인덱싱되어 있을 경우 순차 파일도 직접 읽을 수 있습니다.
- 따라서 syllabus 매칭은 다음과 같습니다: 직렬 및 순차 파일에는 순차 접근을, 순차 및 랜덤 파일에는 직접 접근을 사용합니다.

랜덤: 키가 어디를 찾아야 하는지 알려줍니다

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.
worked example: 조직 선택하기
-
- payslip program은 매달 employee-number 순서로 모든 employee record를 한 번씩 읽어 payslip을 생성합니다. 어떤 조직과 접근 방식이며, 그 이유는 무엇인가?*
- 순차적 조직과 순차적 접근: 모든 레코드를 처리하므로 점프하는 이점이 없으며, 키 순서로 저장하면 정렬 단계 없이 payslip이 순서대로 출력됩니다.
-
- ATM은 account number로 한 account를 1초 이내에 가져와야 합니다.* 랜덤 조직과 직접 접근: 위치가 account number에서 계산되므로 수백만 개의 레코드를 검색할 필요 없이 정확히 한 번의 읽기만으로 충분합니다.
-
- 웹 서버 앱은 요청마다 로그에 한 줄을 추가합니다.* 직렬: 추가만 중요하며, 직렬 파일의 끝부분에 추가하는 것이 가장 빠른 작업입니다.

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.
트레이드오프, 나란히 보기
| 직렬 | 순차 | 랜덤 | |
|---|---|---|---|
| 레코드 순서 | 추가된 순서 | 키로 정렬됨 | 키에서 계산됨 |
| 레코드 추가 | 빠름, 추가 | 느림, 레코드 이동 | 빠름, 슬롯이 비어있을 때 |
| 하나의 레코드 찾기 | 느림, 모두 읽음 | 빠름, 미리 멈출 수 있음 | 가장 빠름, 한 번 읽음 |
| 키 순서로 읽기 | 정렬 필요 | 자연스러움 | 정렬 필요 |
- 정답은 항상 주요 연산을 근거로 논리적으로 설명해야 합니다: 이 프로그램이 가장 많이 수행하는 작업이 무엇입니까?

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: 변경 사항 정당화하기
-
- 도서관의 책 파일은 직렬입니다. 특정 제목을 찾는 데 시간이 걸립니다. 변경 사항을 제안하고 정당화하십시오.*
- ISBN을 주소로 해시하여 랜덤 파일로 재조직하면, 전체 파일을 스캔하는 대신 한 번의 직접 읽기로 검색이 가능합니다.
- 도서관이 제목 순서로 카탈로그를 인쇄한다면, 제목에 따른 순차적 조직이 두 가지 모두를 합리적으로 처리할 수 있습니다: 카탈로그는 정렬이 필요 없고, 검색은 미리 멈추거나 이진 검색을 할 수 있습니다.
- 조직을 명시하고, 접근 방식을 명시하며, 문제에서 언급한 작업과 연결하십시오.
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.
키가 되어야 할 것, 그리고 해시가 실패하는 이유
- 직접 접근에는 키가 필요하며, 키는 하나의 레코드에 대해 유일성(unique) 을 가져야 합니다. 성(surname)은 키가 아닙니다. 고객 번호가 키입니다.
- **해시(hashing)**는 이 키를 하나의 연산으로 레코드 주소로 변환하여, 파일 크기가 아무리 커도 단일 읽기로 레코드에 도달할 수 있게 합니다.
- 서로 다른 두 개의 키가 같은 주소로 해시될 수 있습니다. 이를 충돌(collision) 이라고 하며, 이는 알고리즘의 결함이 아닙니다: 가능한 키의 수가 주소보다 많으면 불가피한 현상입니다.
- 만점 답안에서 제시하는 해결책은 오버플로우 영역(overflow area) 또는 공유하는 레코드 체인의 주소를 가리키는 포인터(pointer) 를 주소에 저장하는 것입니다. 따라서 충돌은 레코드 손실 대신 추가적인 한 번의 읽기 비용으로 발생합니다.
- 따라서 정직한 비교는 다음과 같습니다: 해시는 파일이 가득 차기 전까지는 거의 일정하게 접근 속도를 유지하지만, 충돌이 쌓이면 성능이 저하됩니다. 순차 접근은 절대 저하되지 않으나, 본래 빠르지 않았습니다.

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
어떤 문제가 있었나요? 사이트 팀만 이 내용을 볼 수 있습니다.